Skip to content

Commit

Permalink
Remove legacy C++ toolchain Starlark APIs
Browse files Browse the repository at this point in the history
Since both --incompatible_disable_legacy_cpp_toolchain_skylark_api and --incompatible_disable_legacy_flags_cc_toolchain_api incompatible flags are flipped now, this code is no longer accessible. Thus removing. There is no user-visible impact of this cl.

#6380
#6434

RELNOTES: None.
PiperOrigin-RevId: 222252039
  • Loading branch information
hlopko authored and Copybara-Service committed Nov 20, 2018
1 parent d4fc00f commit 713de2f
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 1,159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,47 @@
public class BazelRulesModule extends BlazeModule {
/** This is where deprecated options go to die. */
public static class GraveyardOptions extends OptionsBase {
@Option(
name = "incompatible_disable_legacy_flags_cc_toolchain_api",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES,
OptionMetadataTag.DEPRECATED
},
help =
"Flag for disabling the legacy cc_toolchain Skylark API for accessing legacy "
+ "CROSSTOOL fields.")
public boolean disableLegacyFlagsCcToolchainApi;

@Option(
name = "incompatible_enable_legacy_cpp_toolchain_skylark_api",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES,
OptionMetadataTag.DEPRECATED
},
help = "Obsolete, no effect.")
public boolean enableLegacyToolchainSkylarkApi;

@Option(
name = "incompatible_disable_legacy_cpp_toolchain_skylark_api",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES,
OptionMetadataTag.DEPRECATED
},
help = "Obsolete, no effect.")
public boolean disableLegacyToolchainSkylarkApi;

@Deprecated
@Option(
name = "direct_run",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ public static ImmutableList<String> getCoptsFromOptions(
flagsBuilder.addAll(config.getCopts());

if (CppFileTypes.C_SOURCE.matches(sourceFilename)) {
flagsBuilder.addAll(config.getCOptions());
flagsBuilder.addAll(config.getConlyopts());
}

if (CppFileTypes.CPP_SOURCE.matches(sourceFilename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.google.devtools.build.lib.rules.cpp.Link.LinkingMode;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcToolchainProviderApi;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain;
Expand Down Expand Up @@ -745,14 +744,6 @@ public boolean supportsFission() {
return toolchainInfo.supportsFission();
}

@Override
// TODO(b/24373706): Remove this method once new C++ toolchain API is available
public ImmutableList<String> getUnfilteredCompilerOptionsWithSysroot(
Iterable<String> featuresNotUsedAnymore) throws EvalException {
cppConfiguration.checkForLegacyCompilationApiAvailability();
return toolchainInfo.getUnfilteredCompilerOptions(sysroot);
}

public ImmutableList<String> getUnfilteredCompilerOptions() {
return toolchainInfo.getUnfilteredCompilerOptions(/* sysroot= */ null);
}
Expand All @@ -767,19 +758,6 @@ public String getTargetOS() {
return toolchainInfo.getTargetOS();
}

@Override
public ImmutableList<String> getLinkOptionsWithSysroot() throws EvalException {
if (cppConfiguration == null) {
return ImmutableList.of();
}
cppConfiguration.checkForLegacyLinkingApiAvailability();
return cppConfiguration.getLinkOptionsDoNotUse(sysroot);
}

public ImmutableList<String> getLinkOptions() {
return cppConfiguration.getLinkOptionsDoNotUse(/* sysroot= */ null);
}

/**
* Returns test-only link options such that certain test-specific features can be configured
* separately (e.g. lazy binding).
Expand Down Expand Up @@ -925,107 +903,13 @@ public FdoMode getFdoMode() {
return fdoMode;
}

/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*/
@Override
public ImmutableList<String> getCompilerOptions() throws EvalException {
cppConfiguration.checkForLegacyCompilationApiAvailability();
return getLegacyCompileOptionsWithCopts();
}

/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* <p>Returns the list of additional C-specific options to use for compiling C. These should be go
* on the command line after the common options returned by {@link
* CcToolchainProvider#getLegacyCompileOptionsWithCopts()}.
*/
@Override
public ImmutableList<String> getCOptions() throws EvalException {
cppConfiguration.checkForLegacyCompilationApiAvailability();
return cppConfiguration.getCOptions();
}

/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* <p>Returns the list of additional C++-specific options to use for compiling C++. These should
* be on the command line after the common options returned by {@link #getCompilerOptions}.
*/
@Override
@Deprecated
public ImmutableList<String> getCxxOptionsWithCopts() throws EvalException {
cppConfiguration.checkForLegacyCompilationApiAvailability();
return ImmutableList.<String>builder()
.addAll(getLegacyCxxOptions())
.addAll(cppConfiguration.getCxxopts())
.build();
}

public ImmutableList<String> getLegacyCxxOptions() {
return ImmutableList.<String>builder()
.addAll(getToolchainCxxFlags())
.addAll(getCxxFlagsByCompilationMode().get(cppConfiguration.getCompilationMode()))
.build();
}

/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* <p>Returns the immutable list of linker options for fully statically linked outputs. Does not
* include command-line options passed via --linkopt or --linkopts.
*
* @param sharedLib true if the output is a shared lib, false if it's an executable
*/
@Override
@Deprecated
public ImmutableList<String> getFullyStaticLinkOptions(Boolean sharedLib) throws EvalException {
cppConfiguration.checkForLegacyLinkingApiAvailability();
if (!sharedLib) {
throw new EvalException(
Location.BUILTIN, "fully_static_link_options is deprecated, new uses are not allowed.");
}
return CppHelper.getFullyStaticLinkOptions(cppConfiguration, this, sharedLib);
}

/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* <p>Returns the immutable list of linker options for mostly statically linked outputs. Does not
* include command-line options passed via --linkopt or --linkopts.
*
* @param sharedLib true if the output is a shared lib, false if it's an executable
*/
@Override
@Deprecated
public ImmutableList<String> getMostlyStaticLinkOptions(Boolean sharedLib) throws EvalException {
cppConfiguration.checkForLegacyLinkingApiAvailability();
return CppHelper.getMostlyStaticLinkOptions(
cppConfiguration, this, sharedLib, /* shouldStaticallyLinkCppRuntimes= */ true);
}

/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* <p>Returns the immutable list of linker options for artifacts that are not fully or mostly
* statically linked. Does not include command-line options passed via --linkopt or --linkopts.
*
* @param sharedLib true if the output is a shared lib, false if it's an executable
*/
@Override
@Deprecated
public ImmutableList<String> getDynamicLinkOptions(Boolean sharedLib) throws EvalException {
cppConfiguration.checkForLegacyLinkingApiAvailability();
return CppHelper.getDynamicLinkOptions(cppConfiguration, this, sharedLib);
}

/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
Expand Down
Loading

0 comments on commit 713de2f

Please sign in to comment.