Skip to content

Commit 1f1b4fd

Browse files
meteorcloudycopybara-github
authored andcommitted
Automated rollback of commit 0a65893.
*** Reason for rollback *** Broke Bazel postsubmit: https://buildkite.com/bazel/bazel-bazel/builds/28021#018f9a8b-8711-4f02-af8a-c29a1e7c6255 bazelbuild#22259 (comment) *** Original change description *** Add layering_check support for macOS There were 2 things with the previous implementation that needed to be improved here: 1. Apple Clang has a bug where it doesn't pass module compiler flags to the underlying -cc1 invocation, so we have to manually pass them directly to that invocation with -Xclang 2. The previous search script was too aggressive and slow for macOS. The macOS SDK has tons of files that aren't headers, and tons of symlin... *** RELNOTES: PiperOrigin-RevId: 635852793 Change-Id: I03b0831706a555bbcf141742aefa3bf48ed0caf3
1 parent c186760 commit 1f1b4fd

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

src/test/shell/bazel/bazel_layering_check_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ EOF
144144
}
145145

146146
function test_bazel_layering_check() {
147+
if is_darwin; then
148+
echo "This test doesn't run on Darwin. Skipping."
149+
return
150+
fi
151+
147152
local -r clang_tool=$(which clang)
148153
if [[ ! -x ${clang_tool:-/usr/bin/clang_tool} ]]; then
149154
echo "clang not installed. Skipping test."
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
# Copyright 2020 The Bazel Authors. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,19 +17,10 @@ set -eu
1717

1818
echo 'module "crosstool" [system] {'
1919

20-
if [[ "$OSTYPE" == darwin* ]]; then
21-
for dir in $@; do
22-
find "$dir" -type f \( -name "*.h" -o -name "*.def" -o -path "*/c++/*" \) \
23-
| LANG=C sort -u | while read -r header; do
24-
echo " textual header \"${header}\""
25-
done
20+
for dir in $@; do
21+
find -L "${dir}" -type f 2>/dev/null | LANG=C sort | uniq | while read header; do
22+
echo " textual header \"${header}\""
2623
done
27-
else
28-
for dir in $@; do
29-
find -L "${dir}" -type f 2>/dev/null | LANG=C sort -u | while read -r header; do
30-
echo " textual header \"${header}\""
31-
done
32-
done
33-
fi
24+
done
3425

3526
echo "}"

tools/cpp/unix_cc_configure.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
534534
["/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"],
535535
)
536536

537-
generate_modulemap = is_clang
537+
generate_modulemap = is_clang and not darwin
538538
if generate_modulemap:
539539
repository_ctx.file("module.modulemap", _generate_system_module_map(
540540
repository_ctx,

tools/cpp/unix_cc_toolchain_config.bzl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _target_os_version(ctx):
3636
xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig]
3737
return xcode_config.minimum_os_for_platform_type(platform_type)
3838

39-
def layering_check_features(compiler, is_macos):
39+
def layering_check_features(compiler):
4040
if compiler != "clang":
4141
return []
4242
return [
@@ -53,10 +53,8 @@ def layering_check_features(compiler, is_macos):
5353
],
5454
flag_groups = [
5555
flag_group(
56-
# macOS requires -Xclang because of a bug in Apple Clang
57-
flags = (["-Xclang"] if is_macos else []) + [
56+
flags = [
5857
"-fmodule-name=%{module_name}",
59-
] + (["-Xclang"] if is_macos else []) + [
6058
"-fmodule-map-file=%{module_map_file}",
6159
],
6260
),
@@ -88,7 +86,7 @@ def layering_check_features(compiler, is_macos):
8886
]),
8987
flag_group(
9088
iterate_over = "dependent_module_map_files",
91-
flags = (["-Xclang"] if is_macos else []) + [
89+
flags = [
9290
"-fmodule-map-file=%{dependent_module_map_files}",
9391
],
9492
),
@@ -1489,7 +1487,7 @@ def _impl(ctx):
14891487
unfiltered_compile_flags_feature,
14901488
treat_warnings_as_errors_feature,
14911489
archive_param_file_feature,
1492-
] + layering_check_features(ctx.attr.compiler, is_macos = False)
1490+
] + layering_check_features(ctx.attr.compiler)
14931491
else:
14941492
# macOS artifact name patterns differ from the defaults only for dynamic
14951493
# libraries.
@@ -1530,7 +1528,7 @@ def _impl(ctx):
15301528
treat_warnings_as_errors_feature,
15311529
archive_param_file_feature,
15321530
generate_linkmap_feature,
1533-
] + layering_check_features(ctx.attr.compiler, is_macos = True)
1531+
]
15341532

15351533
parse_headers_action_configs, parse_headers_features = parse_headers_support(
15361534
parse_headers_tool_path = ctx.attr.tool_paths.get("parse_headers"),

0 commit comments

Comments
 (0)