Skip to content

Commit d9ef6bc

Browse files
committed
[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
1 parent fee9054 commit d9ef6bc

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

clang/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,11 @@ if (CLANG_ENABLE_BOOTSTRAP)
640640
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
641641

642642
if(BOOTSTRAP_LLVM_ENABLE_LLD)
643+
# adding lld to clang-bootstrap-deps without having it enabled in
644+
# LLVM_ENABLE_PROJECTS just generates a cryptic error message.
645+
if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
646+
message(FATAL_ERROR "LLD is enabled in the boostrap build, but lld is not in LLVM_ENABLE_PROJECTS")
647+
endif()
643648
add_dependencies(clang-bootstrap-deps lld)
644649
endif()
645650

clang/cmake/caches/3-stage-base.cmake

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
22
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
33
set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
4-
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
54

6-
# Use LLD do have less requirements on system linker, unless we're on an apple
7-
# platform where the system compiler is to be prefered.
85
if(APPLE)
6+
# Use LLD to have fewer requirements on system linker, unless we're on an apple
7+
# platform where the system compiler is to be preferred.
8+
set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
9+
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
10+
elseif(CMAKE_HOST_UNIX)
11+
# s390/SystemZ is unsupported by LLD, so don't try to enable LTO if it
12+
# cannot work.
13+
# We do our own uname business here since the appropriate variables from CMake
14+
# and llvm are not yet available.
15+
find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
16+
if(CMAKE_UNAME)
17+
exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR
18+
RETURN_VALUE val)
19+
endif(CMAKE_UNAME)
20+
21+
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "s390")
22+
set(BOOTSTRAP_LLVM_ENABLE_LTO OFF CACHE BOOL "")
923
set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
10-
else()
24+
else()
25+
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
1126
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
27+
endif()
28+
29+
else()
30+
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
31+
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
1232
endif()
1333

1434

0 commit comments

Comments
 (0)