Skip to content

Commit

Permalink
Remove 'darwin' CPU value
Browse files Browse the repository at this point in the history
This is another attempt to remove the legacy 'darwin' CPU string which actually means darwin_x86_64. The previous attempt was reverted here bazelbuild@e96b8ca

RELNOTES[INC]: Remove 'darwin' as a CPU value, use 'darwin_x86_64' instead

Closes bazelbuild#17547.

PiperOrigin-RevId: 520324475
Change-Id: I1de3dcfb4fc8d3920ef507ec12960058d24bcdcb
  • Loading branch information
keith authored and fweikert committed May 25, 2023
1 parent 057e67f commit ad918ec
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 38 deletions.
4 changes: 2 additions & 2 deletions site/en/concepts/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ flags:
--apple_platform_type=ios
//platforms:ios

# Maps "--cpu=darwin --apple_platform_type=macos" to "//platform:macos".
--cpu=darwin
# Maps "--cpu=darwin_x86_64 --apple_platform_type=macos" to "//platform:macos".
--cpu=darwin_x86_64
--apple_platform_type=macos
//platforms:macos
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public String convert(String input) throws OptionsParsingException {
case DARWIN:
switch (CPU.getCurrent()) {
case X86_64:
return "darwin";
return "darwin_x86_64";
case AARCH64:
return "darwin_arm64";
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ public enum ApplePlatform implements ApplePlatformApi {
ImmutableSet.of("tvos_arm64");
private static final ImmutableSet<String> CATALYST_TARGET_CPUS =
ImmutableSet.of("catalyst_x86_64");
// "darwin" is included because that's currently the default when on macOS, and
// migrating it would be a breaking change more details:
// https://github.com/bazelbuild/bazel/pull/7062
private static final ImmutableSet<String> MACOS_TARGET_CPUS =
ImmutableSet.of("darwin_x86_64", "darwin_arm64", "darwin_arm64e", "darwin");
ImmutableSet.of("darwin_x86_64", "darwin_arm64", "darwin_arm64e");

private static final ImmutableSet<String> BIT_32_TARGET_CPUS =
ImmutableSet.of("ios_i386", "ios_armv7", "ios_armv7s", "watchos_i386", "watchos_armv7k");
Expand Down Expand Up @@ -267,7 +264,7 @@ public boolean isImmutable() {

@Override
public String toString() {
return name().toLowerCase();
return name().toLowerCase(Locale.ROOT);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _WATCHOS_DEVICE_TARGET_CPUS = ["watchos_armv7k", "watchos_arm64_32"]
_TVOS_SIMULATOR_TARGET_CPUS = ["tvos_x86_64", "tvos_sim_arm64"]
_TVOS_DEVICE_TARGET_CPUS = ["tvos_arm64"]
_CATALYST_TARGET_CPUS = ["catalyst_x86_64"]
_MACOS_TARGET_CPUS = ["darwin_x86_64", "darwin_arm64", "darwin_arm64e", "darwin"]
_MACOS_TARGET_CPUS = ["darwin_x86_64", "darwin_arm64", "darwin_arm64e"]

def _strip_extension(file):
if file.extension == "":
Expand Down
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ios_cpus = struct(
TVOS_SIMULATOR_TARGET_CPUS = ["tvos_x86_64", "tvos_sim_arm64"],
TVOS_DEVICE_TARGET_CPUS = ["tvos_arm64"],
CATALYST_TARGET_CPUS = ["catalyst_x86_64"],
MACOS_TARGET_CPUS = ["darwin_x86_64", "darwin_arm64", "darwin_arm64e", "darwin"],
MACOS_TARGET_CPUS = ["darwin_x86_64", "darwin_arm64", "darwin_arm64e"],
)

cpp_file_types = struct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static final boolean isNotCcLabel(String label) {
private BazelMockCcSupport() {}

private static final ImmutableList<String> CROSSTOOL_ARCHS =
ImmutableList.of("piii", "k8", "armeabi-v7a", "ppc", "darwin");
ImmutableList.of("piii", "k8", "armeabi-v7a", "ppc", "darwin_x86_64");

@Override
protected String getRealFilesystemCrosstoolTopPath() {
Expand Down Expand Up @@ -94,7 +94,7 @@ private static ImmutableList<CcToolchainConfig> getToolchainConfigs() {
result.add(CcToolchainConfig.builder().build());

if (OS.getCurrent() == OS.DARWIN) {
result.add(CcToolchainConfig.getCcToolchainConfigForCpu("darwin"));
result.add(CcToolchainConfig.getCcToolchainConfigForCpu("darwin_x86_64"));
result.add(CcToolchainConfig.getCcToolchainConfigForCpu("darwin_arm64"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,7 @@ public void writeOSX() throws IOException {
StringBuilder compilerMap =
new StringBuilder()
.append("'k8': ':cc-compiler-darwin_x86_64',\n")
.append("'aarch64': ':cc-compiler-darwin_x86_64',\n")
.append("'darwin': ':cc-compiler-darwin_x86_64',\n");
.append("'aarch64': ':cc-compiler-darwin_x86_64',\n");
Set<String> seenCpus = new LinkedHashSet<>();
for (CcToolchainConfig toolchain : ccToolchainConfigList) {
if (seenCpus.add(toolchain.getTargetCpu())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,8 @@ public void testExpandLabelInLinkoptsAgainstSrc() throws Exception {

@Test
public void testCcLibraryWithDashStaticOnDarwin() throws Exception {
getAnalysisMock().ccSupport().setupCcToolchainConfigForCpu(mockToolsConfig, "darwin");
useConfiguration("--cpu=darwin");
getAnalysisMock().ccSupport().setupCcToolchainConfigForCpu(mockToolsConfig, "darwin_x86_64");
useConfiguration("--cpu=darwin_x86_64");
checkError(
"badlib",
"lib_with_dash_static",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void testThatHostCrosstoolTopCommandLineArgumentWorks() throws Exception
" 'k8|gcc-4.4.0': '//b:toolchain_b',",
" 'k8|compiler': '//b:toolchain_b',",
" 'x64_windows|windows_msys64': '//b:toolchain_b',",
" 'darwin|compiler': '//b:toolchain_b',",
" 'darwin_x86_64|compiler': '//b:toolchain_b',",
"})",
"cc_toolchain(",
" name = 'toolchain_b',",
Expand Down
7 changes: 1 addition & 6 deletions src/test/shell/bazel/apple/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ filegroup(
visibility = ["//src/test/shell/bazel:__pkg__"],
)

config_setting(
name = "darwin",
values = {"host_cpu": "darwin"},
)

sh_library(
name = "apple_common",
testonly = 1,
Expand All @@ -21,7 +16,7 @@ filegroup(
name = "objc-deps",
testonly = 1,
srcs = select({
":darwin": [
"//src/conditions:darwin": [
"//tools/osx:xcode-locator",
],
"//conditions:default": [],
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/lib_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def get_cpu_value(repository_ctx):
arch = repository_ctx.os.arch
if os_name.startswith("mac os"):
# Check if we are on x86_64 or arm64 and return the corresponding cpu value.
return "darwin" + ("_arm64" if arch == "aarch64" else "")
return "darwin_" + ("arm64" if arch == "aarch64" else "x86_64")
if os_name.find("freebsd") != -1:
return "freebsd"
if os_name.find("openbsd") != -1:
Expand Down
16 changes: 2 additions & 14 deletions tools/osx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,19 @@ DARWIN_XCODE_LOCATOR_COMPILE_COMMAND = """
genrule(
name = "xcode-locator-genrule",
srcs = select({
":darwin": ["xcode_locator.m"],
":darwin_x86_64": ["xcode_locator.m"],
":darwin_arm64": ["xcode_locator.m"],
":darwin_arm64e": ["xcode_locator.m"],
"//src/conditions:darwin": ["xcode_locator.m"],
"//conditions:default": ["xcode_locator_stub.sh"],
}),
outs = ["xcode-locator"],
cmd = select({
":darwin": DARWIN_XCODE_LOCATOR_COMPILE_COMMAND,
":darwin_x86_64": DARWIN_XCODE_LOCATOR_COMPILE_COMMAND,
":darwin_arm64": DARWIN_XCODE_LOCATOR_COMPILE_COMMAND,
":darwin_arm64e": DARWIN_XCODE_LOCATOR_COMPILE_COMMAND,
"//src/conditions:darwin": DARWIN_XCODE_LOCATOR_COMPILE_COMMAND,
"//conditions:default": "cp $< $@",
}),
local = 1,
output_to_bindir = 1,
)

# TODO(cparsons): Consolidate with config_settings under //src
config_setting(
name = "darwin",
values = {"cpu": "darwin"},
visibility = ["//visibility:public"],
)

config_setting(
name = "darwin_x86_64",
values = {"cpu": "darwin_x86_64"},
Expand Down

0 comments on commit ad918ec

Please sign in to comment.