[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
Tue Mar 16 05:36:21 PDT 2021


tbaeder updated this revision to Diff 330954.
tbaeder added a comment.

Dropped the `FORCE` stuff since we can just set the variable directly and that shouldn't make a difference as far was I know. And the warning now only appears if either LTO or LLD are enabled.


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
@@ -3,15 +3,6 @@
 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)
-    set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
-else()
-    set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
-endif()
-
-
 set(CLANG_BOOTSTRAP_TARGETS
   clang
   check-all
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -635,7 +635,31 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
+  # We want LLD for LTO, but LLD does not support SystemZ, so disable
+  # LTO here and use the installed system linker
+  if ("${LLVM_NATIVE_ARCH}" MATCHES "SystemZ")
+    if (BOOTSTRAP_LLVM_ENABLE_LLD OR BOOTSTRAP_LLVM_ENABLE_LTO)
+      message(STATUS "Disabling LTO and LLD for stage3 builds since LLD does not support ${LLVM_NATIVE_ARCH}")
+    endif()
+    set(BOOTSTRAP_LLVM_ENABLE_LLD OFF)
+    set(BOOTSTRAP_LLVM_ENABLE_LTO OFF)
+  elseif(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
+    message(STATUS "Using system linker for stage3 builds on Apple")
+    set(BOOTSTRAP_LLVM_ENABLE_LLD OFF)
+  else()
+    set(BOOTSTRAP_LLVM_ENABLE_LLD ON)
+    set(BOOTSTRAP_LLVM_ENABLE_LTO ON)
+  endif()
+  message(STATUS "Stage3 builds: LLD: ${BOOTSTRAP_LLVM_ENABLE_LLD}. LTO: ${BOOTSTRAP_LLVM_ENABLE_LTO}")
+
   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.330954.patch
Type: text/x-patch
Size: 2283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210316/70f22724/attachment.bin>


More information about the cfe-commits mailing list