On 11/01/2016 15:26, Brad King wrote:

What is adding -m64 to CMAKE_STATIC_LINKER_FLAGS?  That value is indeed
meant to be used to pass flags to "ar" because CMake (for historical
reasons) abuses the term "linker" to refer to the archiver used for a
static library.

That's been added by in a CMakeLists.txt via an include of a common cmake script for setting up the per-platform compilation flags.

https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/HadoopCommon.cmake

elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
# Solaris flags. 64-bit compilation is mandatory, and is checked earlier. hadoop_add_compiler_flags("-m64 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -D_XOPEN_SOURCE=500")
    hadoop_add_linker_flags("-m64")

which calls:

# Add flags to all the CMake compiler variables
macro(hadoop_add_compiler_flags FLAGS)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
endmacro()

# Add flags to all the CMake linker variables
macro(hadoop_add_linker_flags FLAGS)
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAGS}")
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FLAGS}")
    set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${FLAGS}")
endmacro()

So is the answer here to add -m64 just to CMAKE_EXE_LINKER_FLAGS and CMAKE_SHARED_LINKER_FLAGS and not to CMAKE_STATIC_LINKER_FLAGS? Are CMAKE_STATIC_LINKER_FLAGS only ever used with ar?

But I'm struggling to understand when passing in linker flags to ar
*ever* makes sense, at least on *nix platforms.

The name "LINK_FLAGS" is used as a placeholder there to share the
implementation with similar substitutions done in actual link line
generation.  See above about the naming.

The question here is what changed between 2.8.6 and 3.3.2 that causes
-m64 to start showing up in CMAKE_STATIC_LINKER_FLAGS.

Yes indeed, if I'd been able to figure that out I think I'd have been able to figure out how to change the CMake macros to get round the problem.

It's not the only problem I have hit with CMake's Solaris support, see for example https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/HadoopCommon.cmake#L194

# CMAKE_SYSTEM_PROCESSOR is set to the output of 'uname -p', which on Solaris is # the 'lowest' ISA supported, i.e. 'i386' or 'sparc'. However in order for the # standard CMake modules to look in the right places it needs to reflect the required # compilation mode, i.e. 64 bit. We therefore force it to either 'amd64' or 'sparcv9'.

There seems to be an assumption baked into CMake that if the underlying OS is *nix and is 32-bit then all executables that run on it are 32 bit and if it is 64-bit then all the executables are 64-bit as well, so looking at 'uname -p' is sufficient to determine the type of executables that should be produced. Unfortunately that's not correct for either Solaris or Linux.

Thanks,

--
Alan Burlison
--
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to