forward ccache to cmake via CMAKE_<LANG>_COMPILER_LAUNCHER - #267
Merged
Conversation
When CXX/CC is configured with a leading compiler launcher (e.g. CXX='ccache g++'), splitCompilerVar treated 'ccache' as the compiler and demoted the real compiler to a flag. CMake then ran the launcher directly during its assembler probe (ccache ... -Wa,-v), which ccache rejects with 'invalid option -- W', aborting the oneTBB build. Extract a leading ccache/sccache launcher from CC/CXX and forward it via CMAKE_<LANG>_COMPILER_LAUNCHER, the variable CMake provides for exactly this purpose.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When R is configured with a compiler launcher baked into
CXX(orCC) -- e.g.CXX = "ccache g++"-- building the bundled oneTBB fails during cmake configuration with:Root cause
splitCompilerVar()insrc/install.libs.Rtreats the first token ofCXXas the compiler, soCXX = "ccache g++"was forwarded to cmake asCMAKE_CXX_COMPILER=ccachewithg++demoted intoCMAKE_CXX_FLAGS. oneTBB'sGNU.cmakethen probes the assembler with${CMAKE_CXX_COMPILER} ... -Wa,-v, i.e.ccache ... -Wa,-v. ccache rejects-W(invalid option -- 'W'), the version regex fails to match, and the leftover error text is fed to cmake'smath(), which aborts the build.Fix
CMake models compiler launchers via the dedicated
CMAKE_<LANG>_COMPILER_LAUNCHERvariable, not as part of the compiler command. This PR addsextractCompilerLauncher(), which pulls a leadingccache/sccachelauncher (path- and.exe-tolerant) out ofCC/CXXbefore splitting, and forwards it via-DCMAKE_C_COMPILER_LAUNCHER=/-DCMAKE_CXX_COMPILER_LAUNCHER=. The real compiler is left in place, so cmake's compiler/assembler probes run against it as intended, while ccache still wraps the actual compilation.Tests
Adds cases to
tests/test-install-libs.Rcovering launcher extraction (ccache, path-qualifiedccachewith trailing flags,sccache), and the no-op paths (plain compiler, unset variable).