[CMake] Only include LTO on Apple targets

We only need libLTO when using ld64.

Differential Revision: https://reviews.llvm.org/D103916
This commit is contained in:
Petr Hosek 2021-06-08 10:47:23 -07:00
parent 3787ee4571
commit de98da2ece
2 changed files with 18 additions and 3 deletions

View File

@ -10,11 +10,15 @@ set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
if(NOT APPLE)
# TODO: Remove this once we switch to ld64.lld.
set(LLVM_ENABLE_LLD ON CACHE BOOL "")
endif()
set(LLVM_ENABLE_LTO ON CACHE BOOL "")
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
set(LLVM_ENABLE_PIC OFF CACHE BOOL "")
if(NOT APPLE)
# TODO: Remove this once we switch to ld64.lld.
set(LLVM_ENABLE_PIC OFF CACHE BOOL "")
endif()
set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
@ -32,6 +36,7 @@ endif()
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
if(NOT APPLE)
# TODO: Remove this once we switch to ld64.lld.
set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
endif()
@ -292,10 +297,14 @@ set(LLVM_TOOLCHAIN_TOOLS
sancov
CACHE STRING "")
if(APPLE)
# TODO: Remove this once we switch to ld64.lld.
set(target_components LTO)
endif()
set(LLVM_DISTRIBUTION_COMPONENTS
clang
lld
LTO
clang-apply-replacements
clang-doc
clang-format
@ -307,5 +316,6 @@ set(LLVM_DISTRIBUTION_COMPONENTS
clangd
builtins
runtimes
${target_components}
${LLVM_TOOLCHAIN_TOOLS}
CACHE STRING "")

View File

@ -9,7 +9,10 @@ set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm;polly" CACHE STRING "
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
set(LLVM_ENABLE_PIC OFF CACHE BOOL "")
if(NOT APPLE)
# TODO: Remove this once we switch to ld64.lld.
set(LLVM_ENABLE_PIC OFF CACHE BOOL "")
endif()
set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
@ -24,6 +27,7 @@ endif()
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
if(NOT APPLE)
# TODO: Remove this once we switch to ld64.lld.
set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
endif()
@ -114,6 +118,7 @@ endif()
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
if(NOT APPLE)
# TODO: Remove this once we switch to ld64.lld.
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
endif()