[PATCH] D144603: Add option to disable compiler launcher on external projects
Haowei Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 22 16:56:00 PST 2023
haowei created this revision.
haowei added a reviewer: phosek.
Herald added a subscriber: abrachet.
Herald added a project: All.
haowei requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
When using compiler caching program like ccache, there are cases that a user would like to disable using it when building external projects like the 2nd stage clang or compiler runtimes to avoid polluting the cache due to using a fresh from source toolchain. This patch adds "LLVM_DISABLE_COMPILER_LAUNCHER_FOR_EXT_PROJECT" option so the compiler launcher can be disabled in these cases.
I would appreciate it if someone can suggest a better name for this option.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144603
Files:
clang/CMakeLists.txt
clang/cmake/caches/Fuchsia-stage2.cmake
clang/cmake/caches/Fuchsia.cmake
llvm/cmake/modules/LLVMExternalProjectUtils.cmake
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===================================================================
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -302,6 +302,13 @@
list(APPEND compiler_args -DCMAKE_ASM_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
endif()
+ set(C_COMPILER_LAUNCHER ${CMAKE_C_COMPILER_LAUNCHER})
+ set(CXX_COMPILER_LAUNCHER ${CMAKE_CXX_COMPILER_LAUNCHER})
+ if (LLVM_DISABLE_COMPILER_LAUNCHER_FOR_EXT_PROJECT)
+ set(C_COMPILER_LAUNCHER "")
+ set(CXX_COMPILER_LAUNCHER "")
+ endif()
+
ExternalProject_Add(${name}
DEPENDS ${ARG_DEPENDS} llvm-config
${name}-clobber
@@ -327,8 +334,8 @@
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
- -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
- -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
+ -DCMAKE_C_COMPILER_LAUNCHER=${C_COMPILER_LAUNCHER}
+ -DCMAKE_CXX_COMPILER_LAUNCHER=${CXX_COMPILER_LAUNCHER}
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
${cmake_args}
${PASSTHROUGH_VARIABLES}
Index: clang/cmake/caches/Fuchsia.cmake
===================================================================
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -16,6 +16,7 @@
set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_DISABLE_COMPILER_LAUNCHER_FOR_EXT_PROJECT ON CACHE BOOL "")
# Passthrough stage1 flags to stage1.
set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===================================================================
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -23,6 +23,7 @@
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
+set(LLVM_DISABLE_COMPILER_LAUNCHER_FOR_EXT_PROJECT ON CACHE BOOL "")
if(WIN32)
set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -661,14 +661,18 @@
LLVM_VERSION_SUFFIX
LLVM_BINUTILS_INCDIR
CLANG_REPOSITORY_STRING
- CMAKE_C_COMPILER_LAUNCHER
- CMAKE_CXX_COMPILER_LAUNCHER
CMAKE_MAKE_PROGRAM
CMAKE_OSX_ARCHITECTURES
CMAKE_BUILD_TYPE
LLVM_ENABLE_PROJECTS
LLVM_ENABLE_RUNTIMES)
+ if (NOT LLVM_DISABLE_COMPILER_LAUNCHER_FOR_EXT_PROJECT)
+ list(APPEND _BOOTSTRAP_DEFAULT_PASSTHROUGH
+ CMAKE_C_COMPILER_LAUNCHER
+ CMAKE_CXX_COMPILER_LAUNCHER)
+ endif()
+
# We don't need to depend on compiler-rt/libcxx if we're building instrumented
# because the next stage will use the same compiler used to build this stage.
if(NOT LLVM_BUILD_INSTRUMENTED)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144603.499670.patch
Type: text/x-patch
Size: 3102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230223/f7f90118/attachment.bin>
More information about the cfe-commits
mailing list