Skip to content

Commit ffef360

Browse files
googlewaltfweikert
authored andcommitted
Automated rollback of commit a50cca5.
*** Reason for rollback *** Roll forward with fix *** Original change description *** Automated rollback of commit d56dc18. *** Reason for rollback *** Breaks builds internally. *** Original change description *** Move Apple toolchain setup to apple_support This moves the CC toolchain for building Apple platforms besides macOS to the apple_support repo bazelbuild/apple_support#113 The default unix toolchain is now used if someone wants to build for macOS without the apple_support toolc *** PiperOrigin-RevId: 518560017 Change-Id: I00a106b68eac982e3d903531d5db48ae053f9301
1 parent eca642f commit ffef360

27 files changed

+122
-4537
lines changed

.bazelci/postsubmit.yml

-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ tasks:
202202
- "//third_party/ijar/..."
203203
- "//tools/android/..."
204204
- "//tools/aquery_differ/..."
205-
- "//tools/osx/crosstool/..."
206205
- "//tools/python/..."
207206
# C++ coverage is not supported on macOS yet.
208207
- "-//src/test/shell/bazel:bazel_cc_code_coverage_test"
@@ -266,7 +265,6 @@ tasks:
266265
- "//third_party/ijar/..."
267266
- "//tools/android/..."
268267
- "//tools/aquery_differ/..."
269-
- "//tools/osx/crosstool/..."
270268
- "//tools/python/..."
271269
# C++ coverage is not supported on macOS yet.
272270
- "-//src/test/shell/bazel:bazel_cc_code_coverage_test"

.bazelci/presubmit.yml

-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ tasks:
192192
- "//third_party/ijar/..."
193193
- "//tools/android/..."
194194
- "//tools/aquery_differ/..."
195-
- "//tools/osx/crosstool/..."
196195
- "//tools/python/..."
197196
# Re-enable once fixed: https://github.com/bazelbuild/bazel/issues/8162
198197
- "-//src/java_tools/buildjar/..."
@@ -256,7 +255,6 @@ tasks:
256255
- "//third_party/ijar/..."
257256
- "//tools/android/..."
258257
- "//tools/aquery_differ/..."
259-
- "//tools/osx/crosstool/..."
260258
- "//tools/python/..."
261259
# Re-enable once fixed: https://github.com/bazelbuild/bazel/issues/8162
262260
- "-//src/java_tools/buildjar/..."

src/create_embedded_tools.py

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
('*def_parser.exe', lambda x: 'tools/def_parser/def_parser.exe'),
4343
('*zipper.exe', lambda x: 'tools/zip/zipper/zipper.exe'),
4444
('*zipper', lambda x: 'tools/zip/zipper/zipper'),
45-
('*xcode*make_hashed_objlist.py',
46-
lambda x: 'tools/objc/make_hashed_objlist.py'),
4745
('*xcode*xcode-locator', lambda x: 'tools/objc/xcode-locator'),
4846
('*src/tools/xcode/*', lambda x: 'tools/objc/' + os.path.basename(x)),
4947
# --experimental_sibling_repository_layout=false

src/main/starlark/builtins_bzl/common/objc/objc_library.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
"""objc_library Starlark implementation replacing native"""
1616

17+
load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
1718
load("@_builtins//:common/objc/compilation_support.bzl", "compilation_support")
1819
load("@_builtins//:common/objc/attrs.bzl", "common_attrs")
1920
load("@_builtins//:common/objc/objc_common.bzl", "extensions")
21+
load("@_builtins//:common/objc/semantics.bzl", "semantics")
2022
load("@_builtins//:common/objc/transitions.bzl", "apple_crosstool_transition")
21-
load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
2223
load(":common/cc/cc_info.bzl", "CcInfo")
2324

2425
objc_internal = _builtins.internal.objc_internal
@@ -55,6 +56,7 @@ def _objc_library_impl(ctx):
5556
_validate_attributes(srcs = ctx.attr.srcs, non_arc_srcs = ctx.attr.non_arc_srcs, label = ctx.label)
5657

5758
cc_toolchain = cc_helper.find_cpp_toolchain(ctx)
59+
semantics.check_toolchain_supports_objc_compile(ctx, cc_toolchain)
5860

5961
common_variables = compilation_support.build_common_variables(
6062
ctx = ctx,

src/main/starlark/builtins_bzl/common/objc/semantics.bzl

+19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@
1414

1515
"""Semantics for Bazel Objc rules"""
1616

17+
load(":common/cc/cc_common.bzl", "cc_common")
18+
19+
def _check_toolchain_supports_objc_compile(ctx, cc_toolchain):
20+
feature_configuration = cc_common.configure_features(
21+
ctx = ctx,
22+
cc_toolchain = cc_toolchain,
23+
language = "objc",
24+
requested_features = ctx.features,
25+
unsupported_features = ctx.disabled_features,
26+
)
27+
28+
if not cc_common.action_is_enabled(
29+
feature_configuration = feature_configuration,
30+
action_name = "objc-compile",
31+
):
32+
fail("Compiling objc_library targets requires the Apple CC toolchain " +
33+
"which can be found here: https://github.com/bazelbuild/apple_support")
34+
1735
def _get_licenses_attr():
1836
# TODO(b/182226065): Change to applicable_licenses
1937
return {}
@@ -25,6 +43,7 @@ def _get_repo():
2543
return "bazel_tools"
2644

2745
semantics = struct(
46+
check_toolchain_supports_objc_compile = _check_toolchain_supports_objc_compile,
2847
get_semantics = _get_semantics,
2948
get_repo = _get_repo,
3049
get_licenses_attr = _get_licenses_attr,

src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java

-8
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public final class MockObjcSupport {
3939
"tvos_x86_64",
4040
"tvos_arm64");
4141

42-
private static final ImmutableList<String> DEFAULT_OSX_CROSSTOOL_DEPS_DIRS =
43-
ImmutableList.of("third_party/bazel/tools/osx/crosstool");
4442
public static final String DEFAULT_OSX_CROSSTOOL_DIR = "tools/osx/crosstool";
4543
private static final String MOCK_OSX_TOOLCHAIN_CONFIG_PATH =
4644
"com/google/devtools/build/lib/packages/util/mock/osx_cc_toolchain_config.bzl";
@@ -235,9 +233,6 @@ public static void setup(MockToolsConfig config) throws IOException {
235233
public static void setupCcToolchainConfig(
236234
MockToolsConfig config, CcToolchainConfig.Builder ccToolchainConfig) throws IOException {
237235
if (config.isRealFileSystem()) {
238-
for (String depDir : DEFAULT_OSX_CROSSTOOL_DEPS_DIRS) {
239-
config.linkTools(depDir);
240-
}
241236
config.linkTools(DEFAULT_OSX_CROSSTOOL_DIR);
242237
} else {
243238
CcToolchainConfig toolchainConfig = ccToolchainConfig.build();
@@ -261,9 +256,6 @@ public static void setupCcToolchainConfig(
261256

262257
public static void setupCcToolchainConfig(MockToolsConfig config) throws IOException {
263258
if (config.isRealFileSystem()) {
264-
for (String depDir : DEFAULT_OSX_CROSSTOOL_DEPS_DIRS) {
265-
config.linkTools(depDir);
266-
}
267259
config.linkTools(DEFAULT_OSX_CROSSTOOL_DIR);
268260
} else {
269261
new Crosstool(

src/test/java/com/google/devtools/build/lib/packages/util/mock/osx_cc_toolchain_config.bzl

+12
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,7 @@ def _impl(ctx):
12231223

12241224
if (ctx.attr.cpu == "x64_windows"):
12251225
objc_compile_action = action_config(
1226+
enabled = True,
12261227
action_name = ACTION_NAMES.objc_compile,
12271228
flag_sets = [
12281229
flag_set(
@@ -1255,6 +1256,7 @@ def _impl(ctx):
12551256
)
12561257
elif (ctx.attr.cpu == "ios_arm64"):
12571258
objc_compile_action = action_config(
1259+
enabled = True,
12581260
action_name = ACTION_NAMES.objc_compile,
12591261
flag_sets = [
12601262
flag_set(
@@ -1287,6 +1289,7 @@ def _impl(ctx):
12871289
)
12881290
elif (ctx.attr.cpu == "tvos_arm64"):
12891291
objc_compile_action = action_config(
1292+
enabled = True,
12901293
action_name = ACTION_NAMES.objc_compile,
12911294
flag_sets = [
12921295
flag_set(
@@ -1319,6 +1322,7 @@ def _impl(ctx):
13191322
)
13201323
elif (ctx.attr.cpu == "ios_armv7"):
13211324
objc_compile_action = action_config(
1325+
enabled = True,
13221326
action_name = ACTION_NAMES.objc_compile,
13231327
flag_sets = [
13241328
flag_set(
@@ -1351,6 +1355,7 @@ def _impl(ctx):
13511355
)
13521356
elif (ctx.attr.cpu == "watchos_armv7k"):
13531357
objc_compile_action = action_config(
1358+
enabled = True,
13541359
action_name = ACTION_NAMES.objc_compile,
13551360
flag_sets = [
13561361
flag_set(
@@ -1383,6 +1388,7 @@ def _impl(ctx):
13831388
)
13841389
elif (ctx.attr.cpu == "watchos_arm64_32"):
13851390
objc_compile_action = action_config(
1391+
enabled = True,
13861392
action_name = ACTION_NAMES.objc_compile,
13871393
flag_sets = [
13881394
flag_set(
@@ -1415,6 +1421,7 @@ def _impl(ctx):
14151421
)
14161422
elif (ctx.attr.cpu == "ios_i386"):
14171423
objc_compile_action = action_config(
1424+
enabled = True,
14181425
action_name = ACTION_NAMES.objc_compile,
14191426
flag_sets = [
14201427
flag_set(
@@ -1448,6 +1455,7 @@ def _impl(ctx):
14481455
)
14491456
elif (ctx.attr.cpu == "watchos_i386"):
14501457
objc_compile_action = action_config(
1458+
enabled = True,
14511459
action_name = ACTION_NAMES.objc_compile,
14521460
flag_sets = [
14531461
flag_set(
@@ -1481,6 +1489,7 @@ def _impl(ctx):
14811489
)
14821490
elif (ctx.attr.cpu == "watchos_x86_64"):
14831491
objc_compile_action = action_config(
1492+
enabled = True,
14841493
action_name = ACTION_NAMES.objc_compile,
14851494
flag_sets = [
14861495
flag_set(
@@ -1514,6 +1523,7 @@ def _impl(ctx):
15141523
)
15151524
elif (ctx.attr.cpu == "ios_x86_64"):
15161525
objc_compile_action = action_config(
1526+
enabled = True,
15171527
action_name = ACTION_NAMES.objc_compile,
15181528
flag_sets = [
15191529
flag_set(
@@ -1547,6 +1557,7 @@ def _impl(ctx):
15471557
)
15481558
elif (ctx.attr.cpu == "tvos_x86_64"):
15491559
objc_compile_action = action_config(
1560+
enabled = True,
15501561
action_name = ACTION_NAMES.objc_compile,
15511562
flag_sets = [
15521563
flag_set(
@@ -1580,6 +1591,7 @@ def _impl(ctx):
15801591
)
15811592
elif (ctx.attr.cpu == "darwin_x86_64"):
15821593
objc_compile_action = action_config(
1594+
enabled = True,
15831595
action_name = ACTION_NAMES.objc_compile,
15841596
flag_sets = [
15851597
flag_set(

src/test/py/bazel/bzlmod/bzlmod_query_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def testAqueryModuleRepoTargetsBelow(self):
9292
allow_failure=False)
9393
# This label is stringified into a "purpose" in some action before it
9494
# reaches aquery code, so can't decanonicalize it.
95-
self.assertEqual(stdout[0], 'cc_library-compile for @aaa~1.0//:lib_aaa')
95+
self.assertIn('cc_library-compile for @aaa~1.0//:lib_aaa', stdout)
9696
self.assertIn('Target: @my_repo//:lib_aaa', stdout)
9797

9898
def testAqueryModuleRepoTransitiveDeps(self):

src/test/shell/bazel/apple/BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ sh_test(
3838
"//:workspace-file",
3939
"//src/test/shell/bazel:test-deps",
4040
],
41-
shard_count = 3,
4241
tags = ["no_windows"],
4342
)
4443

0 commit comments

Comments
 (0)