[PATCH] D126699: [CMake] Skip linker check if the LLVM_LINKER_WORKS is set
Pavel Samolysov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 31 06:52:57 PDT 2022
psamolysov created this revision.
psamolysov added reviewers: phosek, mstorsjo, ruiu, RKSimon, thieta, ldionne.
psamolysov added a project: LLVM.
Herald added a subscriber: mgorny.
Herald added a project: All.
psamolysov requested review of this revision.
Herald added a subscriber: llvm-commits.
CMake has a set of 'CMAKE_<LANG>_COMPILER_WORKS' variables to skip checking
of the corresponding compiler during the configuration phase what is used by
LLVM to build runtimes: the `llvm/runtimes/CMakeLists.txt` file contains calls
of the `llvm_ExternalProject_Add` function to build the runtime components and
on these calls all the 'CMAKE_<LANG>_COMPILER_WORKS' variables are set to
'ON'.
The patch introduces a new similar variable 'LLVM_LINKER_WORKS' that is used
to skip checking of the used linker if the 'LLVM_USE_LINKER' variable is set.
The check should be skipped during building runtime components for non-host
environments: at this time the required libraries (libunwind, builtins, crt,
etc.) are not ready and the check will false positive fail.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126699
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/runtimes/CMakeLists.txt
Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -245,6 +245,7 @@
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
-DLLVM_BUILD_TOOLS=${LLVM_BUILD_TOOLS}
+ -DLLVM_LINKER_WORKS=ON
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_CXX_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
@@ -355,6 +356,7 @@
-DLLVM_DEFAULT_TARGET_TRIPLE=${target}
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
+ -DLLVM_LINKER_WORKS=ON
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_CXX_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -302,13 +302,15 @@
endif()
if( LLVM_USE_LINKER )
- set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
- set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fuse-ld=${LLVM_USE_LINKER}")
- check_cxx_source_compiles("int main() { return 0; }" CXX_SUPPORTS_CUSTOM_LINKER)
- if ( NOT CXX_SUPPORTS_CUSTOM_LINKER )
- message(FATAL_ERROR "Host compiler does not support '-fuse-ld=${LLVM_USE_LINKER}'")
+ if( NOT DEFINED LLVM_LINKER_WORKS )
+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fuse-ld=${LLVM_USE_LINKER}")
+ check_cxx_source_compiles("int main() { return 0; }" CXX_SUPPORTS_CUSTOM_LINKER)
+ if ( NOT CXX_SUPPORTS_CUSTOM_LINKER )
+ message(FATAL_ERROR "Host compiler does not support '-fuse-ld=${LLVM_USE_LINKER}'")
+ endif()
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endif()
- set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
append("-fuse-ld=${LLVM_USE_LINKER}"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126699.433071.patch
Type: text/x-patch
Size: 2588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220531/072d7f68/attachment.bin>
More information about the llvm-commits
mailing list