Skip to content

Commit 059fd10

Browse files
committed
normalize single-token compiler vars in tbb build
when a Makevars sets e.g. 'CXX=$(CCACHE) g++' with CCACHE empty, the value expands to ' g++' with a leading space. splitCompilerVar() would tokenize this to a single token and return early without re-setting the variable, leaving the leading space in place and forwarding an invalid '-DCMAKE_CXX_COMPILER= g++' to cmake, breaking the bundled tbb build. re-set the compiler from the parsed tokens even when there are no trailing flags; scan() has already stripped surrounding whitespace.
1 parent d637cbe commit 059fd10

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/install.libs.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,13 @@ splitCompilerVar <- function(compilerVar, flagsVar) {
340340
return(FALSE)
341341

342342
tokens <- scan(text = compiler, what = character(), quiet = TRUE)
343-
if (length(tokens) < 2L)
343+
if (length(tokens) == 0L)
344344
return(FALSE)
345345

346+
# always re-set the compiler from the parsed tokens, even when there are
347+
# no trailing flags: scan() strips surrounding whitespace, so this also
348+
# normalizes values like ' g++' (produced when e.g. '$(CCACHE) g++'
349+
# expands with an empty CCACHE), which CMake would otherwise reject
346350
setenv(compilerVar, tokens[[1L]])
347351

348352
oldFlags <- Sys.getenv(flagsVar)

0 commit comments

Comments
 (0)