[PATCH] D89942: Disable LTO and LLD for bootstrap builds on systems unsupported by LLD
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 17 05:42:42 PDT 2021
tbaeder updated this revision to Diff 331246.
tbaeder added a comment.
Here's a version that shells out to `uname -m` to get the arch. Setting both the `_LLD` and `_LTO` variable that often looks a bit odd but I didn't want to use other variables. Can change that of course.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89942/new/
https://reviews.llvm.org/D89942
Files:
clang/CMakeLists.txt
clang/cmake/caches/3-stage-base.cmake
Index: clang/cmake/caches/3-stage-base.cmake
===================================================================
--- clang/cmake/caches/3-stage-base.cmake
+++ clang/cmake/caches/3-stage-base.cmake
@@ -1,14 +1,34 @@
set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
-set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
-# Use LLD do have less requirements on system linker, unless we're on an apple
-# platform where the system compiler is to be prefered.
if(APPLE)
+ # Use LLD to have fewer requirements on system linker, unless we're on an apple
+ # platform where the system compiler is to be preferred.
+ set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
+ set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+elseif(CMAKE_HOST_UNIX)
+ # s390/SystemZ is unsupported by LLD, so don't try to enable LTO if it cannot
+ # work.
+ # We do our own uname business here since the appropriate variables from CMake
+ # and llvm are not yet available.
+ find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
+ if(CMAKE_UNAME)
+ exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR
+ RETURN_VALUE val)
+ endif(CMAKE_UNAME)
+
+ if("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "s390")
+ set(BOOTSTRAP_LLVM_ENABLE_LTO OFF CACHE BOOL "")
set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
-else()
+ else()
+ set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+ endif()
+
+else()
+ set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+ set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
endif()
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -636,6 +636,11 @@
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
if(BOOTSTRAP_LLVM_ENABLE_LLD)
+ # adding lld to clang-bootstrap-deps without having it enabled in
+ # LLVM_ENABLE_PROJECTS just generates a cryptic error message.
+ if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
+ message(FATAL_ERROR "LLD is enabled in the boostrap build, but lld is not in LLVM_ENABLE_PROJECTS")
+ endif()
add_dependencies(clang-bootstrap-deps lld)
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89942.331246.patch
Type: text/x-patch
Size: 2331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210317/9174c1b8/attachment.bin>
More information about the cfe-commits
mailing list