[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
Thu Oct 22 03:03:54 PDT 2020


tbaeder created this revision.
tbaeder added a reviewer: serge-sans-paille.
Herald added subscribers: cfe-commits, pengfei, kristof.beyls, inglorion, mgorny.
Herald added a project: clang.
tbaeder requested review of this revision.

I tried doing a stage3 build on SystemZ/s390 but ran into the unfortunate problem that LLD does not support SystemZ, so the stage3 build can't use LLD and also can't use LTO.
Implementing the logic to only use LTO/LLD on non-SystemZ  system inside the `3-stage-base.cmake` was not possible however since none of the variables to check are set at that point. According to https://cmake.org/cmake/help/latest/manual/cmake.1.html#options, a cache file passed to `cmake -C` should consist of `set()` calls to populate the cache.

I'm not sure if the previous `if (APPLE)` check worked on apple systems at all. I'm also not sure if setting any of the `BOOTSTRAP_` variables inside a non-cache cmake file should happen at all.

I did test this patch on x86_64, s390, ppc64le and aarch64, but I'm not sure if SystemZ/s390 is the only problematic architecture and if there is a better way of checking whether we're on a non-lld-supported arch.

Anyway, happy to hear comments on this patch. Thanks!


Repository:
  rG LLVM Github Monorepo

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,16 +1,6 @@
 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)
-    set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
-else()
-    set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
-endif()
-
 
 set(CLANG_BOOTSTRAP_TARGETS
   clang
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -656,6 +656,22 @@
   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 linker
+  if ("${LLVM_NATIVE_ARCH}" MATCHES "SystemZ")
+    message(STATUS "Disabling LTO for stage3 builds since LLD does not support ${LLVM_NATIVE_ARCH}")
+    set(BOOTSTRAP_LLVM_ENABLE_LTO OFF CACHE BOOL "")
+  elseif(APPLE)
+    # Use LLD do have less requirements on system linker, unless we're on an apple
+    # platform where the system compiler is to be prefered.
+    message(STATUS "Using system linker for stage3 builds on Apple")
+    set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
+  else()
+    set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+    set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+  endif()
+  message(STATUS "Stage3 builds: LLD: ${BOOTSTRAP_LLVM_ENABLE_LLD}. LTO: ${BOOTSTRAP_LLVM_ENABLE_LTO}")
+
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
     add_dependencies(clang-bootstrap-deps lld)
   endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89942.299906.patch
Type: text/x-patch
Size: 1973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201022/d6bc055a/attachment.bin>


More information about the cfe-commits mailing list