cpp fdo: Use correct PRODUCT_NAME for path when extracting a profile.
Profiles with a root 'blaze-fdo' didn't get correctly symlinked to execRoot/_fdo in bazel.
TESTED=./compile.sh all; +manual FDO builds.
--
Change-Id: I5cd69970523db4de15d5b6ddf7af4a072bbca0f5
Reviewed-on: https://bazel-review.googlesource.com/#/c/3490/
MOS_MIGRATED_REVID=120811529
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 18f2cf1..545619e 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
@@ -20,6 +20,7 @@
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
+import com.google.devtools.build.lib.Constants;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Root;
import com.google.devtools.build.lib.analysis.AnalysisEnvironment;
@@ -253,9 +254,10 @@
lipoMode = LipoMode.OFF;
}
- Root fdoRoot = (fdoProfile == null)
- ? null
- : Root.asDerivedRoot(execRoot, execRoot.getRelative("blaze-fdo"));
+ Root fdoRoot =
+ (fdoProfile == null)
+ ? null
+ : Root.asDerivedRoot(execRoot, execRoot.getRelative(Constants.PRODUCT_NAME + "-fdo"));
PathFragment fdoRootExecPath = fdoProfile == null
? null
@@ -331,9 +333,12 @@
execRoot.getRelative(getLLVMProfilePath(fdoProfile, fdoRootExecPath)), fdoProfile);
} else {
Path zipFilePath = new ZipFileSystem(fdoProfile).getRootDirectory();
- if (!zipFilePath.getRelative("blaze-out").isDirectory()) {
- throw new ZipException("FDO zip files must be zipped directly above 'blaze-out' " +
- "for the compiler to find the profile");
+ String outputSymlinkName = Constants.PRODUCT_NAME + "-out";
+ if (!zipFilePath.getRelative(outputSymlinkName).isDirectory()) {
+ throw new ZipException(
+ "FDO zip files must be zipped directly above '"
+ + outputSymlinkName
+ + "' for the compiler to find the profile");
}
ImmutableSet.Builder<PathFragment> gcdaFilesBuilder = ImmutableSet.builder();
ImmutableMultimap.Builder<PathFragment, PathFragment> importsBuilder =