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() 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