The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=14066 ====================================================================== Reported By: Alexandru Ciobanu Assigned To: ====================================================================== Project: CMake Issue ID: 14066 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2013-04-08 16:19 EDT Last Modified: 2013-04-08 16:19 EDT ====================================================================== Summary: Provided CMAKE_*_LINKER_FLAGS ignored during configuration step Description: It seems that if one provides -DCMAKE_C_FLAGS to cmake, these flags are used during the try-compile steps as part of configuration step, while the provided linker flags like CMAKE_EXE_LINKER_FLAGS are ignored during the try-compile steps.
Interestingly, providing the flags via LDFLAGS environment variable, works. Using the attached tiny repro case: 1. cd build 2. CC=clang cmake -DCMAKE_C_FLAGS="-fsanitize=thread -fPIE" -DCMAKE_EXE_LINKER_FLAGS="-pie" .. results in the following error (full error log is attached): The C compiler "clang" is not able to compile a simple test program. [...] /home/builder/rogue_nightly_build/build_utils/llvm/llvm-relass-install/bin/clang -fsanitize=thread -fPIE CMakeFiles/cmTryCompileExec998602180.dir/testCCompiler.c.o -o cmTryCompileExec998602180 -rdynamic clang-3: error: invalid argument '-fsanitize=thread' only allowed with '-pie' [...] Alternatively, if one uses LDFLAGS for the same purpose, there is no error: 1. cd build 2. LDFLAGS="-pie" CC=clang cmake -DCMAKE_C_FLAGS="-fsanitize=thread -fPIE" .. results in a successful configuration. We found this case because we use clang's ThreadSanitizer, which is a tool that detects race condition with threads and has the following requirement: - compiler should use -fsanitize=thread -fPIE - linker should use -fsanitize=thread -pie Additional Information: 1. cd build 2. CC=clang cmake -DCMAKE_C_FLAGS="-fsanitize=thread -fPIE" -DCMAKE_EXE_LINKER_FLAGS="-pie" .. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2013-04-08 16:19 Alexandru CiobanuNew Issue 2013-04-08 16:19 Alexandru CiobanuFile Added: cmake.link.flags.repro.tar.gz ====================================================================== -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers