View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013960CMakeCMakepublic2013-02-27 14:362016-06-10 14:31
ReporterLebedev Roman 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformGNU/LinuxOSGentooOS Version
Product VersionCMake 2.8.10.2 
Target VersionFixed in Version 
Summary0013960: CMake does not always detect clang toolchain linker
Descriptiondev-util/cmake-2.8.10.2-r2
sys-devel/clang, sys-devel/llvm checked out from trunk on 11:00:56 PM 02/27/2013
Steps To ReproduceThis command doesn't works: CC=clang CXX=clang++ CFLAGS="-O0 -flto" CXXFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" cmake ../ &>build.log; make -i -k -j7 VERBOSE=1 &>>build.log
But this one does: CC=clang CXX=clang++ CFLAGS="-O0 -flto" CXXFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" cmake -D_CMAKE_TOOLCHAIN_PREFIX=x86_64-pc-linux-gnu- ../ &>build.log; make -i -k -j7 VERBOSE=1 &>>build.log
TagsNo tags attached.
Attached Files? file icon CMakeCXXCompiler-bad.cmake [^] (1,401 bytes) 2013-02-27 14:36
log file icon CMakeOutput-bad.log [^] (23,361 bytes) 2013-02-27 14:37
? file icon CMakeCXXCompiler-good.cmake [^] (1,572 bytes) 2013-02-27 14:37
log file icon CMakeOutput-good.log [^] (28,534 bytes) 2013-02-27 14:37
log file icon build-bad.log [^] (835,004 bytes) 2013-02-27 14:40
log file icon build-good.log [^] (786,446 bytes) 2013-02-27 14:41
log file icon CMakeError-bad.log [^] (25,748 bytes) 2013-02-27 15:34
log file icon CMakeError-good.log [^] (25,734 bytes) 2013-02-27 15:39

 Relationships
related to 0015737closedBrad King Use of redhat-hardened-ld breaks CMake's Fortran compiler library detection for gfortran 

  Notes
(0032398)
Lebedev Roman (reporter)
2013-02-27 14:48

The problem lies in empty CMAKE_CXX_IMPLICIT_LINK_LIBRARIES
(0032399)
Bill Hoffman (manager)
2013-02-27 14:58

In the one that works this library links to c++ and m:

Linking C shared library libdarktable.so
-lstdc++ -lm

The other is missing that.

set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;m;c")
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2;/usr/lib64;/lib64;/usr/x86_64-pc-linux-gnu/lib;/lib;/usr/lib")
vs

set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")


The trouble seems to be in the CMakeOutput-bad.log file here:


  ignore line: [ "/usr/bin/x86_64-pc-linux-gnu-ld" -export-dynamic --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTryCompileExec1866823997 /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/crtbegin.o -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../.. -L/lib -L/usr/lib -plugin /usr/bin/../lib64/llvm/LLVMgold.so -plugin-opt=mcpu=x86-64 CMakeFiles/cmTryCompileExec1866823997.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/crtend.o /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/crtn.o]
  ignore line: [gmake[1]: Leaving directory `/home/pinipini/darktable/build/CMakeFiles/CMakeTmp']
  ignore line: []


Working one does this:

  link line: [ "/usr/bin/x86_64-pc-linux-gnu-ld" -export-dynamic --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTryCompileExec3835301014 /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/crtbegin.o -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../.. -L/lib -L/usr/lib -plugin /usr/bin/../lib64/llvm/LLVMgold.so -plugin-opt=mcpu=x86-64 CMakeFiles/cmTryCompileExec3835301014.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/crtend.o /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/crtn.o]
(0032400)
Brad King (manager)
2013-02-27 15:24

Please attach CMakeFiles/CMakeOutput.log and CMakeFiles/CMakeError.log from the failing and working trees.
(0032401)
Brad King (manager)
2013-02-27 15:28

Oops, I see CMakeOutput.log is already there.

From CMakeOutput-bad.log:

 Parsed CXX implicit link information from above output:
   link line regex: [^( *|.*[/\])(ld|ld|collect2)[^/\]*( |$)]

From CMakeOutput-good.log:

 Parsed CXX implicit link information from above output:
   link line regex: [^( *|.*[/\])(x86_64-pc-linux-gnu-ld|ld|collect2)[^/\]*( |$)]

The bad one has CMAKE_LINKER set to "ld" and the good one has it set to x86_64-pc-linux-gnu-ld.
(0032402)
Brad King (manager)
2013-02-27 15:30

Re 0013960:0032401: The good one found the "right" linker because of your -D_CMAKE_TOOLCHAIN_PREFIX=x86_64-pc-linux-gnu- workaround.

Any idea how we can find the right linker for this toolchain automatically?
(0032403)
Brad King (manager)
2013-02-27 15:36

Re 0013960:0032402: While we still need an approach to set CMAKE_LINKER correctly, here is a patch that may help find the implicit link information even without the proper CMAKE_LINKER in this case.

diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake                               

index 80e0218..fa03630 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -29,7 +29,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
   endif()
   # Construct a regex to match linker lines.  It must match both the
   # whole line and just the command (argv[0]).
-  set(linker_regex "^( *|.*[/\\])(${linker}|ld|collect2)[^/\\]*( |$)")
+  set(linker_regex "^( *|.*[/\\])(${linker}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)")
   set(linker_exclude_regex "collect2 version ")
   set(log "${log}  link line regex: [${linker_regex}]\n")
   string(REGEX REPLACE "\r?\n" ";" output_lines "${text}")
(0032973)
Matthias Maier (reporter)
2013-05-04 19:17

I can confirm this issue.
The workaround by Brad King in the last comment - relaxing the linker_regex in CMakeParseImplicitLinkInfo.cmake does mitigate the problem.
(0032977)
Brad King (manager)
2013-05-06 09:00

I've applied the patch from 0013960:0032403:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a2bc47df [^]

Moving this issue to backlog for future handling of the larger problem of detecting CMAKE_LINKER.
(0042240)
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2013-02-27 14:36 Lebedev Roman New Issue
2013-02-27 14:36 Lebedev Roman File Added: CMakeCXXCompiler-bad.cmake
2013-02-27 14:37 Lebedev Roman File Added: CMakeOutput-bad.log
2013-02-27 14:37 Lebedev Roman File Added: CMakeCXXCompiler-good.cmake
2013-02-27 14:37 Lebedev Roman File Added: CMakeOutput-good.log
2013-02-27 14:40 Lebedev Roman File Added: build-bad.log
2013-02-27 14:41 Lebedev Roman File Added: build-good.log
2013-02-27 14:48 Lebedev Roman Note Added: 0032398
2013-02-27 14:58 Bill Hoffman Note Added: 0032399
2013-02-27 15:24 Brad King Note Added: 0032400
2013-02-27 15:28 Brad King Note Added: 0032401
2013-02-27 15:30 Brad King Note Added: 0032402
2013-02-27 15:31 Brad King Summary Building of Darktable master by clang fails => CMake does not always detect clang toolchain linker
2013-02-27 15:34 Lebedev Roman File Added: CMakeError-bad.log
2013-02-27 15:36 Brad King Note Added: 0032403
2013-02-27 15:39 Lebedev Roman File Added: CMakeError-good.log
2013-05-04 19:17 Matthias Maier Note Added: 0032973
2013-05-06 09:00 Brad King Note Added: 0032977
2013-05-06 09:00 Brad King Status new => backlog
2015-09-11 13:32 Brad King Relationship added related to 0015737
2016-06-10 14:28 Kitware Robot Note Added: 0042240
2016-06-10 14:28 Kitware Robot Status backlog => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:28 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team