[llvm] r292047 - Add a LLVM_USE_LINKER that defines the linker to use when building LLVM
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 14 19:21:30 PST 2017
Author: mehdi_amini
Date: Sat Jan 14 21:21:30 2017
New Revision: 292047
URL: http://llvm.org/viewvc/llvm-project?rev=292047&view=rev
Log:
Add a LLVM_USE_LINKER that defines the linker to use when building LLVM
Summary:
This string parameter is passed to -fuse-ld when linking. It can be
an absolute path to your custom linker, otherwise clang will look for
`ld.{name}`.
Reviewers: davide, tejohnson, pcc
Subscribers: llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D28738
Modified:
llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
llvm/trunk/docs/CMake.rst
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=292047&r1=292046&r2=292047&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Sat Jan 14 21:21:30 2017
@@ -147,9 +147,19 @@ function(add_flag_or_print_warning flag
endif()
endfunction()
-if(LLVM_ENABLE_LLD)
- check_cxx_compiler_flag("-fuse-ld=lld" CXX_SUPPORTS_LLD)
- append_if(CXX_SUPPORTS_LLD "-fuse-ld=lld"
+if( LLVM_ENABLE_LLD )
+ if ( LLVM_USE_LINKER )
+ message(FATAL_ERROR "LLVM_ENABLE_LLD and LLVM_USE_LINKER can't be set at the same time")
+ endif()
+ set(LLVM_USE_LINKER "lld")
+endif()
+
+if( LLVM_USE_LINKER )
+ check_cxx_compiler_flag("-fuse-ld=${LLVM_USE_LINKER}" CXX_SUPPORTS_CUSTOM_LINKER)
+ if ( NOT CXX_SUPPORTS_CUSTOM_LINKER )
+ message(FATAL_ERROR "Host compiler does not support '-fuse-ld=${LLVM_USE_LINKER}'")
+ endif()
+ append("-fuse-ld=${LLVM_USE_LINKER}"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
Modified: llvm/trunk/docs/CMake.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.rst?rev=292047&r1=292046&r2=292047&view=diff
==============================================================================
--- llvm/trunk/docs/CMake.rst (original)
+++ llvm/trunk/docs/CMake.rst Sat Jan 14 21:21:30 2017
@@ -382,6 +382,18 @@ LLVM-specific variables
lines, enabling link-time optimization. Possible values are ``Off``,
``On``, ``Thin`` and ``Full``. Defaults to OFF.
+**LLVM_USE_LINKER**:STRING
+ Add ``-fuse-ld={name}`` to the link invocation. The possible value depend on
+ your compiler, for clang the value can be an absolute path to your custom
+ linker, otherwise clang will prefix the name with ``ld.`` and apply its usual
+ search. For example to link LLVM with the Gold linker, cmake can be invoked
+ with ``-DLLVM_USE_LINKER=gold``.
+
+**LLVM_ENABLE_LLD**:BOOL
+ This option is equivalent to `-DLLVM_USE_LINKER=lld`, except during a 2-stage
+ build where a dependency is added from the first stage to the second ensuring
+ that lld is built before stage2 begins.
+
**LLVM_PARALLEL_COMPILE_JOBS**:STRING
Define the maximum number of concurrent compilation jobs.
More information about the llvm-commits
mailing list