View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013069CMakeCMakepublic2012-03-28 16:212013-01-09 10:55
ReporterBen Boeckel 
Assigned ToPeter Collingbourne 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 2.8.8 
Target VersionCMake 2.8.9Fixed in VersionCMake 2.8.9 
Summary0013069: Ninja: CMAKE_<LANG>_FLAGS_<TYPE> flags not applied to executable commands
DescriptionWhen compiling with custom flags which are applied per-build type, they are not added to the linker line with the Ninja generator. The commands run by ninja and make are pasted below for comparison.

With ninja:
[1/6] /usr/lib64/ccache/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -MMD -MF CMakeFiles/lib.dir/lib.c.o.d -o CMakeFiles/lib.dir/lib.c.o -c ../lib.c
[2/6] /usr/lib64/ccache/gcc -Dlib_shared_EXPORTS -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -fPIC -MMD -MF CMakeFiles/lib_shared.dir/lib.c.o.d -o CMakeFiles/lib_shared.dir/lib.c.o -c ../lib.c
[3/6] : && /usr/lib64/ccache/gcc -fPIC -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -shared -Wl,-soname,liblib_shared.so -o liblib_shared.so CMakeFiles/lib_shared.dir/lib.c.o && :
[4/6] : && /home/boeckb/code/cmake/build/bin/cmake -E remove liblib.a && /usr/bin/ar cr liblib.a CMakeFiles/lib.dir/lib.c.o && /usr/bin/ranlib liblib.a && :
[5/6] /usr/lib64/ccache/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -MMD -MF CMakeFiles/flags.dir/flags.c.o.d -o CMakeFiles/flags.dir/flags.c.o -c ../flags.c
[6/6] : && /usr/lib64/ccache/gcc -fPIC CMakeFiles/flags.dir/flags.c.o -o flags -rdynamic liblib.a && :

With Unix Makefiles:
/usr/lib64/ccache/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -o CMakeFiles/lib.dir/lib.c.o -c /home/boeckb/misc/code/sb/ninja/lib.c
/usr/bin/ar cr liblib.a CMakeFiles/lib.dir/lib.c.o
/usr/bin/ranlib liblib.a
/usr/lib64/ccache/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -o CMakeFiles/flags.dir/flags.c.o -c /home/boeckb/misc/code/sb/ninja/flags.c
/usr/lib64/ccache/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" CMakeFiles/flags.dir/flags.c.o -o flags -rdynamic liblib.a
/usr/lib64/ccache/gcc -Dlib_shared_EXPORTS -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -fPIC -o CMakeFiles/lib_shared.dir/lib.c.o -c /home/boeckb/misc/code/sb/ninja/lib.c
/usr/lib64/ccache/gcc -fPIC -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -shared -Wl,-soname,liblib_shared.so -o liblib_shared.so CMakeFiles/lib_shared.dir/lib.c.o
Steps To ReproduceAttached tarball with CMakeLists and shell script used to track down the error.

Run the shell script as:

cmake=/path/to/cmake sh mktrees.sh
Additional Informationcmake-2.8.8-git58db6ac
ninja-master-gitabd33d5
TagsNo tags attached.
Attached Filesbz2 file icon ninja-flags.tar.bz2 [^] (1,048 bytes) 2012-03-28 16:21
patch file icon cmake-0001-Ninja-Fix-13069-CMAKE_-LANG-_FLAGS_-TYPE-flags-not-a.patch [^] (1,350 bytes) 2012-04-26 07:11 [Show Content]

 Relationships

  Notes
(0029347)
Zaheer Chothia (reporter)
2012-04-26 07:11

Attached is a patch which resolves this issue. Note this also addresses a similar issue with CMAKE_SHARED_LIBRARY_<LANG>_FLAGS_<TYPE>.
Thanks very much for the isolated testcase! For reference, these are the commands executed once the fix has been applied:

With ninja:
[1/6] /usr/bin/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -MMD -MT CMakeFiles/lib.dir/lib.c.o -MF CMakeFiles/lib.dir/lib.c.o.d -o CMakeFiles/lib.dir/lib.c.o -c ../lib.c
[2/6] /usr/bin/gcc -Dlib_shared_EXPORTS -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -fPIC -MMD -MT CMakeFiles/lib_shared.dir/lib.c.o -MF CMakeFiles/lib_shared.dir/lib.c.o.d -o CMakeFiles/lib_shared.dir/lib.c.o -c ../lib.c
[3/6] : && /home/zchothia/cmake_ninja_flags_bug13069/CMake_git/build_debug/bin/cmake -E remove liblib.a && /usr/bin/ar cr liblib.a CMakeFiles/lib.dir/lib.c.o && /usr/bin/ranlib liblib.a && :
[4/6] : && /usr/bin/gcc -fPIC -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -shared -Wl,-soname,liblib_shared.so -o liblib_shared.so CMakeFiles/lib_shared.dir/lib.c.o && :
[5/6] /usr/bin/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -MMD -MT CMakeFiles/flags.dir/flags.c.o -MF CMakeFiles/flags.dir/flags.c.o.d -o CMakeFiles/flags.dir/flags.c.o -c ../flags.c
[6/6] : && /usr/bin/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -fPIC CMakeFiles/flags.dir/flags.c.o -o flags -rdynamic liblib.a && :

With Unix Makefiles:
/usr/bin/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -o CMakeFiles/lib.dir/lib.c.o -c /home/zchothia/cmake_ninja_flags_bug13069/testcase/lib.c
/usr/bin/ar cr liblib.a CMakeFiles/lib.dir/lib.c.o
/usr/bin/ranlib liblib.a
/usr/bin/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -o CMakeFiles/flags.dir/flags.c.o -c /home/zchothia/cmake_ninja_flags_bug13069/testcase/flags.c
/usr/bin/gcc -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" CMakeFiles/flags.dir/flags.c.o -o flags -rdynamic liblib.a
/usr/bin/gcc -Dlib_shared_EXPORTS -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -fPIC -o CMakeFiles/lib_shared.dir/lib.c.o -c /home/zchothia/cmake_ninja_flags_bug13069/testcase/lib.c
/usr/bin/gcc -fPIC -g -O0 -pg -fprofile-arcs -ftest-coverage -DFLAG=\"Debug\" -shared -Wl,-soname,liblib_shared.so -o liblib_shared.so CMakeFiles/lib_shared.dir/lib.c.o

Tested with:
cmake-master-git8bb46ee
ninja-master-git16cab01
(0029488)
Peter Collingbourne (developer)
2012-05-16 18:10

I've pushed a commit to next which should fix this bug. Note that as far as I can tell CMake does not use CMAKE_SHARED_LIBRARY_<LANG>_FLAGS_<TYPE> so I did not apply that part of your patch.
(0029891)
Peter Kuemmel (developer)
2012-07-03 06:40

Verified.

And I've added it as 'BuildTypeFlag' test.
(0032014)
Robert Maynard (manager)
2013-01-09 10:55

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

 Issue History
Date Modified Username Field Change
2012-03-28 16:21 Ben Boeckel New Issue
2012-03-28 16:21 Ben Boeckel File Added: ninja-flags.tar.bz2
2012-03-28 17:07 Brad King Assigned To => Peter Collingbourne
2012-03-28 17:07 Brad King Status new => assigned
2012-04-26 07:11 Zaheer Chothia Note Added: 0029347
2012-04-26 07:11 Zaheer Chothia File Added: cmake-0001-Ninja-Fix-13069-CMAKE_-LANG-_FLAGS_-TYPE-flags-not-a.patch
2012-05-16 18:10 Peter Collingbourne Note Added: 0029488
2012-07-03 06:40 Peter Kuemmel Note Added: 0029891
2012-07-03 06:40 Peter Kuemmel Status assigned => resolved
2012-07-03 06:40 Peter Kuemmel Resolution open => fixed
2012-08-09 16:54 David Cole Fixed in Version => CMake 2.8.9
2012-08-09 16:54 David Cole Target Version => CMake 2.8.9
2013-01-09 10:55 Robert Maynard Note Added: 0032014
2013-01-09 10:55 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team