Skip to content

Commit

Permalink
Disable compiler launcher on external projects and multi stage clang
Browse files Browse the repository at this point in the history
When using compiler caching program like ccache, there is no point to
use them on external projects or multi-stage clang builds. As these
builds uses fresh from source code toolchain and will pollute the build
cache. If a compiler launcher is still required, a user can explicity
define `CMAKE_C_COMPILER_LAUNCHER` and `CMAKE_CXX_COMPILER_LAUNCHER` in
`CLANG_BOOTSTRAP_PASSTHROUGH` and `LLVM_EXTERNAL_PROJECT_PASSTHROUGH`
flags to enable compiler launcher in these builds.

Differential Revision: https://reviews.llvm.org/D144603
  • Loading branch information
zeroomega committed Apr 24, 2023
1 parent 7b85bff commit e38cdc5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 0 additions & 2 deletions clang/CMakeLists.txt
Expand Up @@ -660,8 +660,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
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
Expand Down
15 changes: 13 additions & 2 deletions llvm/cmake/modules/LLVMExternalProjectUtils.cmake
Expand Up @@ -165,6 +165,19 @@ function(llvm_ExternalProject_Add name source_dir)
endforeach()
endforeach()

# Populate the non-project-specific passthrough variables
foreach(variableName ${LLVM_EXTERNAL_PROJECT_PASSTHROUGH})
if(DEFINED ${variableName})
if("${${variableName}}" STREQUAL "")
set(value "")
else()
string(REPLACE ";" "|" value "${${variableName}}")
endif()
list(APPEND PASSTHROUGH_VARIABLES
-D${variableName}=${value})
endif()
endforeach()

if(ARG_USE_TOOLCHAIN AND NOT CMAKE_CROSSCOMPILING)
if(CLANG_IN_TOOLCHAIN)
if(is_msvc_target)
Expand Down Expand Up @@ -327,8 +340,6 @@ function(llvm_ExternalProject_Add name source_dir)
-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_EXPORT_COMPILE_COMMANDS=1
${cmake_args}
${PASSTHROUGH_VARIABLES}
Expand Down

0 comments on commit e38cdc5

Please sign in to comment.