View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015235CMakeCMakepublic2014-11-06 11:572015-05-04 09:05
ReporterAndrew Aladjev 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionduplicate 
PlatformLinuxOSGentooOS Version2.2
Product VersionCMake 3.0.2 
Target VersionFixed in Version 
Summary0015235: CMAKE_LD_FLAGS from toolchain is ignored by compiler's check
DescriptionI want to use gcc's thread sanitizer. I have toolchain.cmake

set (CMAKE_SYSTEM_NAME "Linux")
set (CMAKE_C_COMPILER "gcc-4.8.3")
set (CMAKE_C_FLAGS "-fPIE -Werror -Wno-maybe-uninitialized -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING "gcc-4.8.3 thread cflags")
set (CMAKE_LD_FLAGS "-pie")
Steps To Reproducecmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake ..

/usr/bin/gcc-4.8.3 -fPIE -Werror -Wno-maybe-uninitialized -fsanitize=thread -fno-omit-frame-pointer
CMakeFiles/cmTryCompileExec3265698553.dir/testCCompiler.c.o -o cmTryCompileExec3265698553 -rdynamic

gcc-4.8.3: error: -fsanitize=thread linking must be done with -pie or -shared

CMAKE_C_FLAGS works, but CMAKE_LD_FLAGS is ignored.
TagsNo tags attached.
Attached Files

 Relationships
related to 0014066closedBrad King Provided CMAKE_*_LINKER_FLAGS ignored during configuration step 

  Notes
(0037159)
Brad King (manager)
2014-11-06 12:50

The variable is called CMAKE_EXE_LINKER_FLAGS. This works for me:

$ cat toolchain.cmake
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_C_COMPILER /usr/bin/cc)
set(CMAKE_C_FLAGS "-fPIE -fsanitize=thread" CACHE STRING "thread cflags")
set(CMAKE_EXE_LINKER_FLAGS "-pie" CACHE STRING "thread ldflags")
(0037308)
Hinterwaeldler (reporter)
2014-11-27 21:12

Within my cmake update the same thing happens close to the described problem above, but happens only on a deploy machine (both debian testing with cmake 3.0.2)
The difference: I use the exe linker flag but the result seems to be the same (as described form brad king)

As this has not been seen on the developer machine yet i played around a little bit with cmake call and make call.
No real solution so far, but at leas a workaround, which seems to work:
1. Trigger the cmake call
2. Touch the Toolchain-file
3. Trigger the make

One line call:
rm -rf build ; mkdir build ; cd build ; cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-file.cmake .. ; touch ../Toolchain-file.cmake ; make VERBOSE=1 # to see if the flags are appended correctly

btw. i've appended appended a few message logouts to determine the current flags. Every of them looks like expected, but the links.txt does not contain any of the assinged values
(0037468)
Brad King (manager)
2014-12-16 10:11

The solution in 0014066 should address this too.
(0038701)
Robert Maynard (manager)
2015-05-04 09:05

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-11-06 11:57 Andrew Aladjev New Issue
2014-11-06 12:50 Brad King Note Added: 0037159
2014-11-27 21:12 Hinterwaeldler Note Added: 0037308
2014-12-01 08:36 Brad King Relationship added related to 0014066
2014-12-16 10:11 Brad King Note Added: 0037468
2014-12-16 10:11 Brad King Status new => resolved
2014-12-16 10:11 Brad King Resolution open => duplicate
2015-05-04 09:05 Robert Maynard Note Added: 0038701
2015-05-04 09:05 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team