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