[clang] d9ef6bc - [clang] Disable LTO and LLD on SystemZ for stage3 builds

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 17 07:16:51 PDT 2021


Author: Timm Bäder
Date: 2021-03-17T15:15:41+01:00
New Revision: d9ef6bc42643ae4feab3f9eca97864d72034f2ce

URL: https://github.com/llvm/llvm-project/commit/d9ef6bc42643ae4feab3f9eca97864d72034f2ce
DIFF: https://github.com/llvm/llvm-project/commit/d9ef6bc42643ae4feab3f9eca97864d72034f2ce.diff

LOG: [clang] Disable LTO and LLD on SystemZ for stage3 builds

LLD does not support SystemZ, so it doesn't make sense to use it for
boostrap/stage3 builds, and using LTO in these cases won't work.

Differential Revision: https://reviews.llvm.org/D89942

Added: 
    

Modified: 
    clang/CMakeLists.txt
    clang/cmake/caches/3-stage-base.cmake

Removed: 
    


################################################################################
diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 7af05c331e94..aa38110b6d22 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -640,6 +640,11 @@ if (CLANG_ENABLE_BOOTSTRAP)
   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()
 

diff  --git a/clang/cmake/caches/3-stage-base.cmake b/clang/cmake/caches/3-stage-base.cmake
index 88ab5d77f16f..31391aa4defc 100644
--- a/clang/cmake/caches/3-stage-base.cmake
+++ b/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()
 
 


        


More information about the cfe-commits mailing list