[clang] de98da2 - [CMake] Only include LTO on Apple targets

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 8 11:00:09 PDT 2021


Author: Petr Hosek
Date: 2021-06-08T11:00:01-07:00
New Revision: de98da2eced72eee791a93b076b70a7b22175abc

URL: https://github.com/llvm/llvm-project/commit/de98da2eced72eee791a93b076b70a7b22175abc
DIFF: https://github.com/llvm/llvm-project/commit/de98da2eced72eee791a93b076b70a7b22175abc.diff

LOG: [CMake] Only include LTO on Apple targets

We only need libLTO when using ld64.

Differential Revision: https://reviews.llvm.org/D103916

Added: 
    

Modified: 
    clang/cmake/caches/Fuchsia-stage2.cmake
    clang/cmake/caches/Fuchsia.cmake

Removed: 
    


################################################################################
diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake
index b019fb0da82b..9cf58a53eece 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -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 "")

diff  --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index 6f4ba5a92989..06c2ac8373b9 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -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()
 


        


More information about the cfe-commits mailing list