Implement --enable_remaining_fdo_absolute_paths, --enable_propeller_optimize_absolute_paths flags The previous flag enable_fdo_profile_absolute_path didn't disable all the uses. The new flags disable usages of absolute paths. There's no immediate goal to flip the flags. The flags may help fix/test the tooling that currently uses absolute paths. PiperOrigin-RevId: 627662949 Change-Id: If8f48f149fa726689c53d8cfb24e1a81bb2f77e7
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index b789bbf..f2485a7 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
@@ -195,6 +195,12 @@ throw new InvalidConfigurationException(e); } } else { + if (!cppOptions.enableFdoProfileAbsolutePath) { + throw new InvalidConfigurationException( + "Please use --fdo_profile instead of an absolute path set with --fdo_optimize. Using" + + " absolute paths may be temporary reenabled with" + + " --enable_fdo_profile_absolute_path"); + } fdoPath = PathFragment.create(cppOptions.getFdoOptimize()); if (!fdoPath.isAbsolute()) { throw new InvalidConfigurationException( @@ -213,6 +219,12 @@ PathFragment csFdoAbsolutePath = null; if (cppOptions.csFdoAbsolutePathForBuild != null) { + if (!cppOptions.enableFdoProfileAbsolutePath) { + throw new InvalidConfigurationException( + "Please use --cs_fdo_optimize instead of an absolute path set with" + + " --cs_fdo_absolute_path.Using absolute paths may be temporary reenabled with" + + " --enable_fdo_profile_absolute_path"); + } csFdoAbsolutePath = PathFragment.create(cppOptions.csFdoAbsolutePathForBuild); if (!csFdoAbsolutePath.isAbsolute()) { throw new InvalidConfigurationException( @@ -229,6 +241,12 @@ PathFragment propellerOptimizeAbsoluteCCProfile = null; if (cppOptions.propellerOptimizeAbsoluteCCProfile != null) { + if (!cppOptions.enablePropellerOptimizeAbsolutePath) { + throw new InvalidConfigurationException( + "Please use --propeller_optimize instead of an absolute path set with" + + " --propeller_optimize_absolute_cc_profile.Using absolute paths may be temporary" + + " reenabled with --enable_fdo_profile_absolute_path"); + } propellerOptimizeAbsoluteCCProfile = PathFragment.create(cppOptions.propellerOptimizeAbsoluteCCProfile); if (!propellerOptimizeAbsoluteCCProfile.isAbsolute()) { @@ -246,6 +264,12 @@ PathFragment propellerOptimizeAbsoluteLdProfile = null; if (cppOptions.propellerOptimizeAbsoluteLdProfile != null) { + if (!cppOptions.enablePropellerOptimizeAbsolutePath) { + throw new InvalidConfigurationException( + "Please use --propeller_optimize instead of an absolute path set with" + + " --propeller_optimize_absolute_ld_profile. Using absolute paths may be temporary" + + " reenabled with --enable_fdo_profile_absolute_path"); + } propellerOptimizeAbsoluteLdProfile = PathFragment.create(cppOptions.propellerOptimizeAbsoluteLdProfile); if (!propellerOptimizeAbsoluteLdProfile.isAbsolute()) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index aa45372..8b9b65f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
@@ -460,11 +460,28 @@ public Label csFdoProfileLabel; @Option( + name = "enable_remaining_fdo_absolute_paths", + defaultValue = "true", + documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, + effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, + help = "If set, any use of absolute paths for FDO will raise an error.") + public boolean enableFdoProfileAbsolutePath; + + @Option( + name = "enable_propeller_optimize_absolute_paths", + defaultValue = "true", + documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, + effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, + help = "If set, any use of absolute paths for propeller optimize will raise an error.") + public boolean enablePropellerOptimizeAbsolutePath; + + @Option( name = "propeller_optimize_absolute_cc_profile", defaultValue = "null", documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, - help = "Absolute path name of cc_profile file for Propeller Optimized builds.") + help = "Absolute path name of cc_profile file for Propeller Optimized builds.", + deprecationWarning = "Deprecated. Use --propeller_optimize instead.") public String propellerOptimizeAbsoluteCCProfile; @Option( @@ -472,7 +489,8 @@ defaultValue = "null", documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, - help = "Absolute path name of ld_profile file for Propeller Optimized builds.") + help = "Absolute path name of ld_profile file for Propeller Optimized builds.", + deprecationWarning = "Deprecated. Use --propeller_optimize instead.") public String propellerOptimizeAbsoluteLdProfile; @Option(