Index: clang/CMakeLists.txt =================================================================== --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -635,7 +635,29 @@ 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") + message(STATUS "Disabling LTO and LLD for stage3 builds since LLD does not support ${LLVM_NATIVE_ARCH}") + set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "" FORCE) + set(BOOTSTRAP_LLVM_ENABLE_LTO OFF CACHE BOOL "" FORCE) + 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 CACHE BOOL "" FORCE) + else() + set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "" FORCE) + set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "" FORCE) + 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 @@ -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