Hi Rafael, I looked at the code which you pushed a while ago to check for the gold linker. Code below: execute_process( COMMAND ${CMAKE_C_COMPILER} -Wl,--version OUTPUT_VARIABLE stdout ERROR_QUIET) if("${stdout}" MATCHES "GNU gold") set(LLVM_LINKER_IS_GOLD ON) endif() I was trying to build runtime libraries (compiler-rt) for ARM using clang which includes this code. A while ago, I saw the error message until geek4civic fixed it with ERROR_QUIET. I usually specify my sysroot and tool chain(linker) through CFLAGS. To fortify the logic, ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -Wl, --version would be ideal than ${CMAKE_C_COMPILER} -Wl, --version which works mostly for gnu compilers. Let me know, I can push a patch execute_process( - COMMAND ${CMAKE_C_COMPILER} -Wl,--version + COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -Wl,--version OUTPUT_VARIABLE stdout ERROR_QUIET) if("${stdout}" MATCHES "GNU gold") set(LLVM_LINKER_IS_GOLD ON) endif() --Sumanth G -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150127/48f5aace/attachment.html>
On Wed, Jan 28, 2015 at 2:27 AM, Sumanth Gundapaneni < sgundapa at codeaurora.org> wrote:> Hi Rafael, > > I looked at the code which you pushed a while ago to > check for the gold linker. > > Code below: > > execute_process( > > COMMAND ${CMAKE_C_COMPILER} -Wl,--version > > OUTPUT_VARIABLE stdout > > ERROR_QUIET) > > if("${stdout}" MATCHES "GNU gold") > > set(LLVM_LINKER_IS_GOLD ON) > > endif() > > > > > > I was trying to build runtime libraries (compiler-rt) for ARM using > “clang” which includes this code. > > A while ago, I saw the error message until geek4civic fixed it with > “ERROR_QUIET”. > > I usually specify my sysroot and tool chain(linker) through CFLAGS. > > To fortify the logic, “${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -Wl, > --version” would be ideal than “${CMAKE_C_COMPILER} -Wl, --version” which > works mostly for gnu compilers. > > Let me know, I can push a patch > > > > execute_process( > > - COMMAND ${CMAKE_C_COMPILER} -Wl,--version > > + COMMAND “${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS}” -Wl,--version > > OUTPUT_VARIABLE stdout > > ERROR_QUIET) > > if("${stdout}" MATCHES "GNU gold") > > set(LLVM_LINKER_IS_GOLD ON) > > endif() >While this may be convenient I don't think it's strictly correct. CFLAGS != LDFLAGS I think if extra flags are going to be passed it should be LD specific since that's what this is intended to check. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150128/9cee3fd6/attachment.html>
I reacted as per my case. You need CFLAGS in order to what linker you might be using. In case of clang, you can use “-fuse-ld” to control the invocation of linker. In my opinion, it is not necessary to carry forward LDFLAGS unless you want to control specific parts of the linker. In my case, I have a cross compiler for ARM and I usually compile the code with Clang –sysroot=<path_to_sysroot> --gcc-toolchain=<path_to_toolchain> -target=<triple> file.c Where I pass “–sysroot=<path_to_sysroot> --gcc-toolchain=<path_to_toolchain> -target=<triple>” as CMAKE_C_FLAGS :) With out –gcc-toolchain, clang cannot find the linker and picks the system linker which is usually /usr/bin/ld on a linux system. --Sumanth G From: C Bergström [mailto:cbergstrom at pathscale.com] Sent: Tuesday, January 27, 2015 11:51 AM To: Sumanth Gundapaneni Cc: llvmdev at cs.uiuc.edu; Rafael Ávila de Espíndola; Takumi NAKAMURA Subject: Re: [LLVMdev] CMake: Gold linker detection On Wed, Jan 28, 2015 at 2:27 AM, Sumanth Gundapaneni <sgundapa at codeaurora.org <mailto:sgundapa at codeaurora.org> > wrote: Hi Rafael, I looked at the code which you pushed a while ago to check for the gold linker. Code below: execute_process( COMMAND ${CMAKE_C_COMPILER} -Wl,--version OUTPUT_VARIABLE stdout ERROR_QUIET) if("${stdout}" MATCHES "GNU gold") set(LLVM_LINKER_IS_GOLD ON) endif() I was trying to build runtime libraries (compiler-rt) for ARM using “clang” which includes this code. A while ago, I saw the error message until geek4civic fixed it with “ERROR_QUIET”. I usually specify my sysroot and tool chain(linker) through CFLAGS. To fortify the logic, “${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -Wl, --version” would be ideal than “${CMAKE_C_COMPILER} -Wl, --version” which works mostly for gnu compilers. Let me know, I can push a patch execute_process( - COMMAND ${CMAKE_C_COMPILER} -Wl,--version + COMMAND “${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS}” -Wl,--version OUTPUT_VARIABLE stdout ERROR_QUIET) if("${stdout}" MATCHES "GNU gold") set(LLVM_LINKER_IS_GOLD ON) endif() While this may be convenient I don't think it's strictly correct. CFLAGS != LDFLAGS I think if extra flags are going to be passed it should be LD specific since that's what this is intended to check. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150127/c0a574aa/attachment.html>
Apparently Analagous Threads
- [LLVMdev] CMake: Gold linker detection
- [LLVMdev] [PATCH] CMake add_version_info_from_vcs SVN_REPOSITORY
- Guidance on cross compiling LLVM with mingw-w64 and cmake
- LLVM cross-compilation cmake issues
- [LLVMdev] Building past few days with Clang++ and Clang produces errors on Cmake for Debian Linux