Skip to content

Commit

Permalink
Automated rollback of commit d56dc18.
Browse files Browse the repository at this point in the history
*** 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 toolchain, but it doesn't handle as many platform specific features as the previous toolchain.

Fixes bazelbuild#1...

***

PiperOrigin-RevId: 516486823
Change-Id: If9b2542699cf8704e0a511e684d8519468ddd937
  • Loading branch information
zhengwei143 authored and copybara-github committed Mar 14, 2023
1 parent 6d004a3 commit a50cca5
Show file tree
Hide file tree
Showing 26 changed files with 4,536 additions and 110 deletions.
2 changes: 2 additions & 0 deletions .bazelci/postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ tasks:
- "//third_party/ijar/..."
- "//tools/android/..."
- "//tools/aquery_differ/..."
- "//tools/osx/crosstool/..."
- "//tools/python/..."
# C++ coverage is not supported on macOS yet.
- "-//src/test/shell/bazel:bazel_cc_code_coverage_test"
Expand Down Expand Up @@ -265,6 +266,7 @@ tasks:
- "//third_party/ijar/..."
- "//tools/android/..."
- "//tools/aquery_differ/..."
- "//tools/osx/crosstool/..."
- "//tools/python/..."
# C++ coverage is not supported on macOS yet.
- "-//src/test/shell/bazel:bazel_cc_code_coverage_test"
Expand Down
2 changes: 2 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ tasks:
- "//third_party/ijar/..."
- "//tools/android/..."
- "//tools/aquery_differ/..."
- "//tools/osx/crosstool/..."
- "//tools/python/..."
# Re-enable once fixed: https://github.com/bazelbuild/bazel/issues/8162
- "-//src/java_tools/buildjar/..."
Expand Down Expand Up @@ -255,6 +256,7 @@ tasks:
- "//third_party/ijar/..."
- "//tools/android/..."
- "//tools/aquery_differ/..."
- "//tools/osx/crosstool/..."
- "//tools/python/..."
# Re-enable once fixed: https://github.com/bazelbuild/bazel/issues/8162
- "-//src/java_tools/buildjar/..."
Expand Down
2 changes: 2 additions & 0 deletions src/create_embedded_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
('*def_parser.exe', lambda x: 'tools/def_parser/def_parser.exe'),
('*zipper.exe', lambda x: 'tools/zip/zipper/zipper.exe'),
('*zipper', lambda x: 'tools/zip/zipper/zipper'),
('*xcode*make_hashed_objlist.py',
lambda x: 'tools/objc/make_hashed_objlist.py'),
('*xcode*xcode-locator', lambda x: 'tools/objc/xcode-locator'),
('*src/tools/xcode/*', lambda x: 'tools/objc/' + os.path.basename(x)),
# --experimental_sibling_repository_layout=false
Expand Down
10 changes: 0 additions & 10 deletions src/main/starlark/builtins_bzl/common/objc/objc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ load("@_builtins//:common/objc/attrs.bzl", "common_attrs")
load("@_builtins//:common/objc/objc_common.bzl", "extensions")
load("@_builtins//:common/objc/transitions.bzl", "apple_crosstool_transition")
load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
load(":common/cc/cc_common.bzl", "cc_common")
load(":common/cc/cc_info.bzl", "CcInfo")

objc_internal = _builtins.internal.objc_internal
Expand Down Expand Up @@ -56,15 +55,6 @@ def _objc_library_impl(ctx):
_validate_attributes(srcs = ctx.attr.srcs, non_arc_srcs = ctx.attr.non_arc_srcs, label = ctx.label)

cc_toolchain = cc_helper.find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)

if not cc_common.action_is_enabled(feature_configuration = feature_configuration, action_name = "objc-compile"):
fail("Compiling objc_library targets requires the Apple CC toolchain which can be found here: https://github.com/bazelbuild/apple_support")

common_variables = compilation_support.build_common_variables(
ctx = ctx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public final class MockObjcSupport {
"tvos_x86_64",
"tvos_arm64");

private static final ImmutableList<String> DEFAULT_OSX_CROSSTOOL_DEPS_DIRS =
ImmutableList.of("third_party/bazel/tools/osx/crosstool");
public static final String DEFAULT_OSX_CROSSTOOL_DIR = "tools/osx/crosstool";
private static final String MOCK_OSX_TOOLCHAIN_CONFIG_PATH =
"com/google/devtools/build/lib/packages/util/mock/osx_cc_toolchain_config.bzl";
Expand Down Expand Up @@ -233,6 +235,9 @@ public static void setup(MockToolsConfig config) throws IOException {
public static void setupCcToolchainConfig(
MockToolsConfig config, CcToolchainConfig.Builder ccToolchainConfig) throws IOException {
if (config.isRealFileSystem()) {
for (String depDir : DEFAULT_OSX_CROSSTOOL_DEPS_DIRS) {
config.linkTools(depDir);
}
config.linkTools(DEFAULT_OSX_CROSSTOOL_DIR);
} else {
CcToolchainConfig toolchainConfig = ccToolchainConfig.build();
Expand All @@ -256,6 +261,9 @@ public static void setupCcToolchainConfig(

public static void setupCcToolchainConfig(MockToolsConfig config) throws IOException {
if (config.isRealFileSystem()) {
for (String depDir : DEFAULT_OSX_CROSSTOOL_DEPS_DIRS) {
config.linkTools(depDir);
}
config.linkTools(DEFAULT_OSX_CROSSTOOL_DIR);
} else {
new Crosstool(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,6 @@ def _impl(ctx):

if (ctx.attr.cpu == "x64_windows"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1256,7 +1255,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "ios_arm64"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1289,7 +1287,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "tvos_arm64"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1322,7 +1319,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "ios_armv7"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1355,7 +1351,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "watchos_armv7k"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1388,7 +1383,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "watchos_arm64_32"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1421,7 +1415,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "ios_i386"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1455,7 +1448,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "watchos_i386"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1489,7 +1481,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "watchos_x86_64"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1523,7 +1514,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "ios_x86_64"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1557,7 +1547,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "tvos_x86_64"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down Expand Up @@ -1591,7 +1580,6 @@ def _impl(ctx):
)
elif (ctx.attr.cpu == "darwin_x86_64"):
objc_compile_action = action_config(
enabled = True,
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
Expand Down
2 changes: 1 addition & 1 deletion src/test/py/bazel/bzlmod/bzlmod_query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def testAqueryModuleRepoTargetsBelow(self):
allow_failure=False)
# This label is stringified into a "purpose" in some action before it
# reaches aquery code, so can't decanonicalize it.
self.assertIn('cc_library-compile for @aaa~1.0//:lib_aaa', stdout)
self.assertEqual(stdout[0], 'cc_library-compile for @aaa~1.0//:lib_aaa')
self.assertIn('Target: @my_repo//:lib_aaa', stdout)

def testAqueryModuleRepoTransitiveDeps(self):
Expand Down
1 change: 1 addition & 0 deletions src/test/shell/bazel/apple/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sh_test(
"//:workspace-file",
"//src/test/shell/bazel:test-deps",
],
shard_count = 3,
tags = ["no_windows"],
)

Expand Down
Loading

0 comments on commit a50cca5

Please sign in to comment.