Skip to content

Commit

Permalink
Automated rollback of commit a50cca5.
Browse files Browse the repository at this point in the history
*** 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
  • Loading branch information
googlewalt authored and copybara-github committed Mar 22, 2023
1 parent b0fc11d commit 699e403
Show file tree
Hide file tree
Showing 27 changed files with 122 additions and 4,537 deletions.
2 changes: 0 additions & 2 deletions .bazelci/postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ 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 @@ -266,7 +265,6 @@ 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: 0 additions & 2 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ 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 @@ -256,7 +255,6 @@ 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: 0 additions & 2 deletions src/create_embedded_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
('*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
4 changes: 3 additions & 1 deletion src/main/starlark/builtins_bzl/common/objc/objc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

"""objc_library Starlark implementation replacing native"""

load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
load("@_builtins//:common/objc/compilation_support.bzl", "compilation_support")
load("@_builtins//:common/objc/attrs.bzl", "common_attrs")
load("@_builtins//:common/objc/objc_common.bzl", "extensions")
load("@_builtins//:common/objc/semantics.bzl", "semantics")
load("@_builtins//:common/objc/transitions.bzl", "apple_crosstool_transition")
load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
load(":common/cc/cc_info.bzl", "CcInfo")

objc_internal = _builtins.internal.objc_internal
Expand Down Expand Up @@ -55,6 +56,7 @@ 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)
semantics.check_toolchain_supports_objc_compile(ctx, cc_toolchain)

common_variables = compilation_support.build_common_variables(
ctx = ctx,
Expand Down
19 changes: 19 additions & 0 deletions src/main/starlark/builtins_bzl/common/objc/semantics.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@

"""Semantics for Bazel Objc rules"""

load(":common/cc/cc_common.bzl", "cc_common")

def _check_toolchain_supports_objc_compile(ctx, cc_toolchain):
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
language = "objc",
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")

def _get_licenses_attr():
# TODO(b/182226065): Change to applicable_licenses
return {}
Expand All @@ -25,6 +43,7 @@ def _get_repo():
return "bazel_tools"

semantics = struct(
check_toolchain_supports_objc_compile = _check_toolchain_supports_objc_compile,
get_semantics = _get_semantics,
get_repo = _get_repo,
get_licenses_attr = _get_licenses_attr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ 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 @@ -235,9 +233,6 @@ 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 @@ -261,9 +256,6 @@ 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,6 +1223,7 @@ 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 @@ -1255,6 +1256,7 @@ 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 @@ -1287,6 +1289,7 @@ 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 @@ -1319,6 +1322,7 @@ 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 @@ -1351,6 +1355,7 @@ 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 @@ -1383,6 +1388,7 @@ 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 @@ -1415,6 +1421,7 @@ 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 @@ -1448,6 +1455,7 @@ 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 @@ -1481,6 +1489,7 @@ 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 @@ -1514,6 +1523,7 @@ 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 @@ -1547,6 +1557,7 @@ 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 @@ -1580,6 +1591,7 @@ 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.assertEqual(stdout[0], 'cc_library-compile for @aaa~1.0//:lib_aaa')
self.assertIn('cc_library-compile for @aaa~1.0//:lib_aaa', stdout)
self.assertIn('Target: @my_repo//:lib_aaa', stdout)

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

Expand Down
Loading

0 comments on commit 699e403

Please sign in to comment.