Skip to content

Commit

Permalink
Remove the command line option --apple_grte_top.
Browse files Browse the repository at this point in the history
RELNOTES[INC]: The --apple_compiler command line option is not available anymore.

PiperOrigin-RevId: 557386253
Change-Id: Ib55a44cc9d44cd13d6e492517333a5a385e2d9f0
  • Loading branch information
lberki authored and Copybara-Service committed Aug 16, 2023
1 parent 0ed8f66 commit fb4106b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 46 deletions.
Expand Up @@ -195,20 +195,6 @@ public class AppleCommandLineOptions extends FragmentOptions {
/** The default Catalyst CPU value. */
public static final String DEFAULT_CATALYST_CPU = "x86_64";

@Option(
name = "apple_grte_top",
defaultValue = "null",
converter = LabelConverter.class,
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {
OptionEffectTag.CHANGES_INPUTS,
OptionEffectTag.LOADING_AND_ANALYSIS,
OptionEffectTag.LOSES_INCREMENTAL_STATE,
},
help = "The Apple target grte_top."
)
public Label appleLibcTop;

@Option(
name = "apple_crosstool_top",
defaultValue = "@bazel_tools//tools/cpp:toolchain",
Expand Down
Expand Up @@ -465,7 +465,7 @@ public static ImmutableMap<String, BuildOptions> handleApplePlatforms(

// The cpu flag will be set by platform mapping if a mapping exists.
splitOptions.get(PlatformOptions.class).platforms = ImmutableList.of(platform);
setAppleCrosstoolTransitionPlatformConfiguration(buildOptions, splitOptions, platform);
setAppleCrosstoolTransitionPlatformConfiguration(splitOptions, platform);
AppleCommandLineOptions appleCommandLineOptions =
splitOptions.get(AppleCommandLineOptions.class);
// Set the configuration distinguisher last, as the method
Expand Down Expand Up @@ -749,7 +749,7 @@ private static void setAppleCrosstoolTransitionCpuConfiguration(
toOptions.cpu = cpu;
toCppOptions.crosstoolTop = appleOptions.appleCrosstoolTop;

setAppleCrosstoolTransitionSharedConfiguration(from, to);
setAppleCrosstoolTransitionSharedConfiguration(to);

// Ensure platforms aren't set so that platform mapping can take place.
to.get(PlatformOptions.class).platforms = ImmutableList.of();
Expand All @@ -759,14 +759,13 @@ private static void setAppleCrosstoolTransitionCpuConfiguration(
* Sets configuration fields required for a transition that uses apple_platforms in place of the
* default platforms to find the appropriate CROSSTOOL and C++ configuration options.
*
* @param from options from the originating configuration
* @param to options for the destination configuration. This instance will be modified to so the
* destination configuration uses the apple crosstool
* @param platform {@code --platforms} value for toolchain selection in the destination
* configuration
*/
private static void setAppleCrosstoolTransitionPlatformConfiguration(
BuildOptionsView from, BuildOptionsView to, Label platform) {
BuildOptionsView to, Label platform) {
PlatformOptions toPlatformOptions = to.get(PlatformOptions.class);
ImmutableList<Label> incomingPlatform = ImmutableList.of(platform);

Expand All @@ -783,26 +782,23 @@ private static void setAppleCrosstoolTransitionPlatformConfiguration(
// The cpu flag will be set by platform mapping if a mapping exists.
to.get(PlatformOptions.class).platforms = incomingPlatform;

setAppleCrosstoolTransitionSharedConfiguration(from, to);
setAppleCrosstoolTransitionSharedConfiguration(to);
}

/**
* Sets a common set of configuration fields required for a transition that needs to find the
* appropriate CROSSTOOL and C++ configuration options.
*
* @param from options from the originating configuration
* @param to options for the destination configuration. This instance will be modified to so the
* destination configuration uses the apple crosstool
*/
private static void setAppleCrosstoolTransitionSharedConfiguration(
BuildOptionsView from, BuildOptionsView to) {
private static void setAppleCrosstoolTransitionSharedConfiguration(BuildOptionsView to) {
to.get(AppleCommandLineOptions.class).configurationDistinguisher =
ConfigurationDistinguisher.APPLE_CROSSTOOL;

AppleCommandLineOptions appleOptions = from.get(AppleCommandLineOptions.class);
CppOptions toCppOptions = to.get(CppOptions.class);
toCppOptions.cppCompiler = null;
toCppOptions.libcTopLabel = appleOptions.appleLibcTop;
toCppOptions.libcTopLabel = null;

// OSX toolchains do not support fission.
toCppOptions.fissionModes = ImmutableList.of();
Expand Down
3 changes: 1 addition & 2 deletions src/main/starlark/builtins_bzl/common/objc/transitions.bzl
Expand Up @@ -97,7 +97,7 @@ def _output_dictionary(settings, cpu, platform_type, platforms):
),
"//command_line_option:platforms": platforms,
"//command_line_option:fission": [],
"//command_line_option:grte_top": settings["//command_line_option:apple_grte_top"],
"//command_line_option:grte_top": None,
}

def _apple_crosstool_transition_impl(settings, attr):
Expand Down Expand Up @@ -127,7 +127,6 @@ _apple_rule_base_transition_inputs = [
"//command_line_option:apple_crosstool_top",
"//command_line_option:crosstool_top",
"//command_line_option:apple_split_cpu",
"//command_line_option:apple_grte_top",
"//command_line_option:cpu",
"//command_line_option:ios_multi_cpus",
"//command_line_option:macos_cpus",
Expand Down
Expand Up @@ -64,7 +64,6 @@
import com.google.devtools.common.options.OptionsParsingException;
import java.util.Collection;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -1540,25 +1539,6 @@ public void testFilesToCompileOutputGroup() throws Exception {
checkFilesToCompileOutputGroup(RULE_TYPE);
}

@Test
@Ignore("apple_grte_top isn't being applied because the cpu doesn't change")
public void testSysrootArgSpecifiedWithGrteTopFlag() throws Exception {
MockObjcSupport.setup(mockToolsConfig);
useConfiguration("--cpu=ios_x86_64", "--apple_grte_top=//x");
scratch.file(
"x/BUILD",
"objc_library(",
" name = 'objc',",
" srcs = ['source.m'],",
")",
"filegroup(",
" name = 'everything',",
" srcs = ['header.h'],",
")");
CommandAction compileAction = compileAction("//x:objc", "source.o");
assertThat(compileAction.getArguments()).contains("--sysroot=x");
}

@Test
public void testDefaultEnabledFeatureIsUsed() throws Exception {
// Although using --cpu=ios_x86_64, it transitions to darwin_x86_64, so the actual
Expand Down

0 comments on commit fb4106b

Please sign in to comment.