aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java36
2 files changed, 32 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java
index d2b4145e74..a6c5f860b5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java
@@ -1450,6 +1450,7 @@ public final class CcCompilationHelper {
source.getLabel(),
usePic,
/* ccRelativeName= */ null,
+ /* outputName= */ null,
/* autoFdoImportPath= */ null,
/* gcnoFile= */ null,
/* dwoFile= */ null,
@@ -1475,6 +1476,7 @@ public final class CcCompilationHelper {
Label sourceLabel,
boolean usePic,
PathFragment ccRelativeName,
+ String outputName,
PathFragment autoFdoImportPath,
Artifact gcnoFile,
Artifact dwoFile,
@@ -1601,6 +1603,7 @@ public final class CcCompilationHelper {
ruleContext,
ccRelativeName,
autoFdoImportPath,
+ PathFragment.create(outputName),
usePic,
featureConfiguration,
fdoSupport);
@@ -1696,6 +1699,7 @@ public final class CcCompilationHelper {
sourceLabel,
/* usePic= */ pic,
ccRelativeName,
+ outputName,
module.getExecPath(),
gcnoFile,
dwoFile,
@@ -1744,6 +1748,7 @@ public final class CcCompilationHelper {
sourceLabel,
this.getGeneratePicActions(),
/* ccRelativeName= */ null,
+ /* outputName= */ null,
/* autoFdoImportPath= */ null,
/* gcnoFile= */ null,
/* dwoFile= */ null,
@@ -1853,6 +1858,7 @@ public final class CcCompilationHelper {
sourceLabel,
/* usePic= */ true,
ccRelativeName,
+ outputName,
sourceArtifact.getExecPath(),
gcnoFile,
dwoFile,
@@ -1920,6 +1926,7 @@ public final class CcCompilationHelper {
sourceLabel,
/* usePic= */ false,
ccRelativeName,
+ outputName,
sourceArtifact.getExecPath(),
gcnoFile,
noPicDwoFile,
@@ -2022,6 +2029,7 @@ public final class CcCompilationHelper {
sourceLabel,
usePic,
ccRelativeName,
+ outputName,
execPath,
/* gcnoFile= */ null,
/* dwoFile= */ null,
@@ -2136,6 +2144,7 @@ public final class CcCompilationHelper {
sourceLabel,
usePic,
ccRelativeName,
+ outputName,
source.getExecPath(),
/* gcnoFile= */ null,
/* dwoFile= */ null,
@@ -2153,6 +2162,7 @@ public final class CcCompilationHelper {
sourceLabel,
usePic,
ccRelativeName,
+ outputName,
source.getExecPath(),
/* gcnoFile= */ null,
/* dwoFile= */ null,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java
index 79d4dcf03a..890c68a364 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java
@@ -590,15 +590,20 @@ public class FdoSupport {
}
/**
- * Configures a compile action builder by setting up command line options and
- * auxiliary inputs according to the FDO configuration. This method does
- * nothing If FDO is disabled.
+ * Configures a compile action builder by setting up command line options and auxiliary inputs
+ * according to the FDO configuration. This method does nothing If FDO is disabled.
*/
@ThreadSafe
- public void configureCompilation(CppCompileActionBuilder builder,
- CcToolchainFeatures.Variables.Builder buildVariables, RuleContext ruleContext,
- PathFragment sourceName, PathFragment sourceExecPath, boolean usePic,
- FeatureConfiguration featureConfiguration, FdoSupportProvider fdoSupportProvider) {
+ public void configureCompilation(
+ CppCompileActionBuilder builder,
+ CcToolchainFeatures.Variables.Builder buildVariables,
+ RuleContext ruleContext,
+ PathFragment sourceName,
+ PathFragment sourceExecPath,
+ PathFragment outputName,
+ boolean usePic,
+ FeatureConfiguration featureConfiguration,
+ FdoSupportProvider fdoSupportProvider) {
// FDO is disabled -> do nothing.
if ((fdoInstrument == null) && (fdoRoot == null)) {
@@ -616,8 +621,9 @@ public class FdoSupport {
if (env.getSkyframeEnv().valuesMissing()) {
return;
}
- Iterable<Artifact> auxiliaryInputs = getAuxiliaryInputs(
- ruleContext, sourceName, sourceExecPath, usePic, fdoSupportProvider);
+ Iterable<Artifact> auxiliaryInputs =
+ getAuxiliaryInputs(
+ ruleContext, sourceName, sourceExecPath, outputName, usePic, fdoSupportProvider);
builder.addMandatoryInputs(auxiliaryInputs);
if (!Iterables.isEmpty(auxiliaryInputs)) {
if (featureConfiguration.isEnabled(CppRuleClasses.AUTOFDO)) {
@@ -636,11 +642,13 @@ public class FdoSupport {
}
}
- /**
- * Returns the auxiliary files that need to be added to the {@link CppCompileAction}.
- */
+ /** Returns the auxiliary files that need to be added to the {@link CppCompileAction}. */
private Iterable<Artifact> getAuxiliaryInputs(
- RuleContext ruleContext, PathFragment sourceName, PathFragment sourceExecPath, boolean usePic,
+ RuleContext ruleContext,
+ PathFragment sourceName,
+ PathFragment sourceExecPath,
+ PathFragment outputName,
+ boolean usePic,
FdoSupportProvider fdoSupportProvider) {
CcToolchainProvider toolchain =
CppHelper.getToolchainUsingDefaultCcToolchainAttribute(ruleContext);
@@ -661,7 +669,7 @@ public class FdoSupport {
ImmutableSet.Builder<Artifact> auxiliaryInputs = ImmutableSet.builder();
PathFragment objectName =
- FileSystemUtils.replaceExtension(sourceName, usePic ? ".pic.o" : ".o");
+ FileSystemUtils.appendExtension(outputName, usePic ? ".pic.o" : ".o");
Label lipoLabel = ruleContext.getLabel();
auxiliaryInputs.addAll(