Index: clang/CMakeLists.txt =================================================================== --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -636,6 +636,11 @@ 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() Index: clang/cmake/caches/3-stage-base.cmake =================================================================== --- clang/cmake/caches/3-stage-base.cmake +++ 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()