diff options
author | 2018-03-20 04:25:02 -0700 | |
---|---|---|
committer | 2018-03-20 04:26:54 -0700 | |
commit | 191add5b0e32c39faca09c25e6da6683a79dd8f7 (patch) | |
tree | 63d8ccae9263687c4de7a7fa84e08f78eef5230e /src/main/java | |
parent | 755a0a10e14c4fe4c2ff3b71af9f99d5d1a924cf (diff) |
Make FdoSupport use outputName to generate object file path
Object file path will no longer be derived from source file path directly.
This is a preparation change for[]
Related issue https://github.com/bazelbuild/bazel/issues/4149
RELNOTES: None
PiperOrigin-RevId: 189722421
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java | 10 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java | 36 |
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( |