Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add layering_check support for macOS #22259

Closed

Conversation

keith
Copy link
Member

@keith keith commented May 6, 2024

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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

@keith keith requested a review from fmeum May 6, 2024 20:11
@github-actions github-actions bot added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels May 6, 2024
Copy link
Collaborator

@fmeum fmeum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to run this target to update the lockfile:

name = "update_default_lock_file",

Looks good! The faster find wouldn't work on Linux, so the amount of "fork"ing looks just right.

@keith keith force-pushed the ks/add-layering_check-support-for-macos branch 6 times, most recently from 67c225a to d0cdc1d Compare May 6, 2024 22:07
@keith keith force-pushed the ks/add-layering_check-support-for-macos branch from d0cdc1d to e59f370 Compare May 14, 2024 20:03
@keith
Copy link
Member Author

keith commented May 14, 2024

@pzembrod could you take a look? 🙏🏻

@pzembrod
Copy link
Contributor

@keith I left a few comments on your push, because apparently GitHub's UI succeeded in confusing me. ;-)

@comius
Copy link
Contributor

comius commented May 15, 2024

@keith I left a few comments on your push, because apparently GitHub's UI succeeded in confusing me. ;-)

I can't find the comments, but I'm ok if @keith can.

@comius comius added awaiting-user-response Awaiting a response from the author and removed awaiting-review PR is awaiting review from an assigned reviewer labels May 15, 2024
@brentleyjones
Copy link
Contributor

@comius here: e59f370

tools/cpp/unix_cc_toolchain_config.bzl Outdated Show resolved Hide resolved
@@ -534,7 +534,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
["/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"],
)

generate_modulemap = is_clang and not darwin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was disabled before on MacOS because it was too slow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

tools/cpp/generate_system_module_map.sh Outdated Show resolved Hide resolved
@@ -144,11 +144,6 @@ EOF
}

function test_bazel_layering_check() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking: the related test/feature test_bazel_layering_check_header_only() still doesn't work on MacOS?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't want to change it in this PR too since it's unrelated, but I think we can enable it afterwards #22370

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

@pzembrod
Copy link
Contributor

I moved my comments over to the PR

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 symlinks
   pointing to other files within the SDK. This adds a fork in the
   script to run a version that works with Apple SDKs. The time
   difference on my machine is 41s->6s. 6s is still pretty long so if
   desired we can put this behavior behind an env var for users to opt
   in with.

I've added a hermetic version of this to the apple_support toolchain,
but similar to the Linux setup here the modulemap file includes absolute
paths.
@keith keith force-pushed the ks/add-layering_check-support-for-macos branch from e59f370 to 0286a53 Compare May 15, 2024 19:24
@keith keith requested a review from pzembrod May 15, 2024 19:24
@@ -144,11 +144,6 @@ EOF
}

function test_bazel_layering_check() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

@pzembrod pzembrod added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-user-response Awaiting a response from the author labels May 17, 2024
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label May 21, 2024
@meteorcloudy
Copy link
Member

This seems to break Bazel postsubmit: https://buildkite.com/bazel/bazel-bazel/builds/28021#018f9a8b-8711-4f02-af8a-c29a1e7c6255

//src/test/shell/bazel:bazel_bootstrap_distfile_tar_test

# Configuration: 7c706e29d44fb244031cd9f1b5563076a031b073c9a89bd361b0680404c6068b
# Execution platform: //:default_host_platform
�[1mexternal/grpc~/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc:42:10: �[0m�[0;1;31merror: �[0m�[1mmodule grpc~//:grpc_resolver_dns_ares does not depend on a module exporting 'ares.h'�[0m
#include <ares.h>
�[0;1;32m         ^
�[0m1 error generated.
�[32m[1,873 / 4,221]�[0m 36 actions running

@keith
Copy link
Member Author

keith commented May 21, 2024

I think we can either patch gRPC to disable the layering check for that target, or we can try and update it (not sure how hard that is for bazel?) wdyt?

@keith keith deleted the ks/add-layering_check-support-for-macos branch May 21, 2024 16:27
@keith
Copy link
Member Author

keith commented May 21, 2024

submitted #22468 because the upgrade is non-trivial and requires protocolbuffers/protobuf#16884

@keith
Copy link
Member Author

keith commented May 21, 2024

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label May 21, 2024
copybara-service bot pushed a commit that referenced this pull request May 21, 2024
*** Reason for rollback ***

Broke Bazel postsubmit: https://buildkite.com/bazel/bazel-bazel/builds/28021#018f9a8b-8711-4f02-af8a-c29a1e7c6255

#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
@iancha1992
Copy link
Member

@bazel-io fork 7.2.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label May 21, 2024
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request May 21, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

PiperOrigin-RevId: 635735410
Change-Id: Icb3f30dd7319f147b0db54b3b42d4dc9032dc1a0
keith added a commit to keith/bazel that referenced this pull request May 21, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

This reverts commit 1f1b4fd.
@keith
Copy link
Member Author

keith commented May 21, 2024

got reverted, new version here #22475

keith added a commit to keith/bazel that referenced this pull request May 21, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

This reverts commit 1f1b4fd.
keith added a commit to keith/bazel that referenced this pull request May 24, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

This reverts commit 1f1b4fd.
keith added a commit to keith/bazel that referenced this pull request May 24, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

This reverts commit 1f1b4fd.
copybara-service bot pushed a commit that referenced this pull request May 24, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes #22259.

This reverts commit 1f1b4fd.

Partial commit for third_party/*, see #22475.

Change-Id: I801121e36de1504c17adfa4736c49c88d470fec0
Signed-off-by: Hee Cha <heec@google.com>
keith added a commit to keith/bazel that referenced this pull request May 25, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

This reverts commit 1f1b4fd.
copybara-service bot pushed a commit that referenced this pull request May 28, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes #22259.

This reverts commit 1f1b4fd.

Closes #22475.

PiperOrigin-RevId: 637969838
Change-Id: I7d4940a820e3741836239493222ba8d06c4d70e4
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request May 28, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

This reverts commit 1f1b4fd.

Closes bazelbuild#22475.

PiperOrigin-RevId: 637969838
Change-Id: I7d4940a820e3741836239493222ba8d06c4d70e4
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request May 28, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

This reverts commit 1f1b4fd.

Partial commit for third_party/*, see bazelbuild#22475.

Change-Id: I801121e36de1504c17adfa4736c49c88d470fec0
Signed-off-by: Hee Cha <heec@google.com>
github-merge-queue bot pushed a commit that referenced this pull request May 28, 2024
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 symlinks
pointing to other files within the SDK. This adds a fork in the script
to run a version that works with Apple SDKs. The time difference on my
machine is 41s->6s. 6s is still pretty long so if desired we can put
this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain,
but similar to the Linux setup here the modulemap file includes absolute
paths.

Closes #22259.

This reverts commit 1f1b4fd.

Partial commit for third_party/*, see #22475.

Change-Id: I801121e36de1504c17adfa4736c49c88d470fec0
Signed-off-by: Hee Cha <heec@google.com>

Commit
de0a37c

Signed-off-by: Hee Cha <heec@google.com>
Co-authored-by: Keith Smiley <keithbsmiley@gmail.com>
iancha1992 pushed a commit to bazel-io/bazel that referenced this pull request May 28, 2024
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 symlinks pointing to other files within the SDK. This adds a fork in the script to run a version that works with Apple SDKs. The time difference on my machine is 41s->6s. 6s is still pretty long so if desired we can put this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain, but similar to the Linux setup here the modulemap file includes absolute paths.

Closes bazelbuild#22259.

This reverts commit 1f1b4fd.

Closes bazelbuild#22475.

PiperOrigin-RevId: 637969838
Change-Id: I7d4940a820e3741836239493222ba8d06c4d70e4
github-merge-queue bot pushed a commit that referenced this pull request May 28, 2024
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 symlinks
pointing to other files within the SDK. This adds a fork in the script
to run a version that works with Apple SDKs. The time difference on my
machine is 41s->6s. 6s is still pretty long so if desired we can put
this behavior behind an env var for users to opt in with.

I've added a hermetic version of this to the apple_support toolchain,
but similar to the Linux setup here the modulemap file includes absolute
paths.

Closes #22259.

This reverts commit 1f1b4fd.

Closes #22475.

PiperOrigin-RevId: 637969838
Change-Id: I7d4940a820e3741836239493222ba8d06c4d70e4

Commit
6abdd2a

Co-authored-by: Keith Smiley <keithbsmiley@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants