Skip to content

Commit

Permalink
Remove unflipping of cc_toolchain_resolution from android_split_trans…
Browse files Browse the repository at this point in the history
…ition

BEGIN_PUBLIC
Remove unflipping of cc_toolchain_resolution from android_split_transition

This is preparation to make --incompatible_enable_cc_toolchain_resolution a no-op. Android transitions need to keep it enabled.
END_PUBLIC

PiperOrigin-RevId: 586586969
Change-Id: Icb80b9a9b87ff9ed0b1f4a55933d8e37bdc5b040
  • Loading branch information
comius authored and copybara-github committed Nov 30, 2023
1 parent c3ed4b5 commit d8ed538
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.devtools.build.lib.analysis.starlark.FunctionTransitionUtil;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.packages.RuleTransitionData;
import com.google.devtools.build.lib.rules.cpp.CppOptions;

/**
* Ensures that Android binaries have a valid target platform by resetting the "--platforms" flag to
Expand All @@ -53,10 +52,7 @@ public static TransitionFactory<RuleTransitionData> create() {
@Override
public ImmutableSet<Class<? extends FragmentOptions>> requiresOptionFragments() {
return ImmutableSet.of(
AndroidConfiguration.Options.class,
PlatformOptions.class,
CoreOptions.class,
CppOptions.class);
AndroidConfiguration.Options.class, PlatformOptions.class, CoreOptions.class);
}

@Override
Expand All @@ -83,13 +79,6 @@ public BuildOptions patch(BuildOptionsView options, EventHandler eventHandler) {
}
}

// If we are using toolchain resolution for Android, also use it for CPP.
// This needs to be before the AndroidBinary is analyzed so that all native dependencies
// use the same configuration.
if (androidOptions.incompatibleUseToolchainResolution) {
newOptions.get(CppOptions.class).enableCcToolchainResolution = true;
}

if (androidOptions.androidPlatformsTransitionsUpdateAffected) {
ImmutableSet.Builder<String> affected = ImmutableSet.builder();
if (!options
Expand All @@ -98,10 +87,6 @@ public BuildOptions patch(BuildOptionsView options, EventHandler eventHandler) {
.equals(newOptions.get(PlatformOptions.class).platforms)) {
affected.add("//command_line_option:platforms");
}
if (options.get(CppOptions.class).enableCcToolchainResolution
!= newOptions.get(CppOptions.class).enableCcToolchainResolution) {
affected.add("//command_line_option:incompatible_enable_cc_toolchain_resolution");
}
FunctionTransitionUtil.updateAffectedByStarlarkTransition(
newOptions.get(CoreOptions.class), affected.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ private ImmutableMap<String, BuildOptions> handleAndroidCpu(
setCcFlagsFromAndroid(androidOptions, splitOptions);
// Ensure platforms aren't set so that platform mapping can take place.
splitOptions.get(PlatformOptions.class).platforms = ImmutableList.of();
// Because configuration is based on cpu flags we need to disable C++ toolchain resolution
splitOptions.get(CppOptions.class).enableCcToolchainResolution = false;
return handleDefaultSplit(splitOptions, androidOptions.cpu);
}

Expand All @@ -195,8 +193,6 @@ private ImmutableMap<String, BuildOptions> handleFatApkCpus(
setCcFlagsFromAndroid(androidOptions, splitOptions);
// Ensure platforms aren't set so that platform mapping can take place.
splitOptions.get(PlatformOptions.class).platforms = ImmutableList.of();
// Because configuration is based on cpu flags we need to disable C++ toolchain resolution
splitOptions.get(CppOptions.class).enableCcToolchainResolution = false;
result.put(cpu, splitOptions.underlying());
addNonCpuSplits(result, cpu, splitOptions);
}
Expand Down

0 comments on commit d8ed538

Please sign in to comment.