diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java index c5e4708f8102e7..198c3447af93ab 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java @@ -94,7 +94,13 @@ List getArguments( List commandLine = new ArrayList<>(); // first: The command name. - commandLine.add(getToolPath()); + if (pathMapper.isNoop()) { + commandLine.add(getToolPath()); + } else { + // getToolPath() ultimately returns a PathFragment's getSafePathString(), so its safe to + // reparse it here with no risk of e.g. altering a user-specified absolute path. + commandLine.add(pathMapper.map(PathFragment.create(getToolPath())).getSafePathString()); + } // second: The compiler options. if (parameterFilePath != null) {