-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Bazel's use of -isystem gives incorrect search path on macOS #10472
Comments
FWIW this happened to me with previous bazel versions as well. |
Possibly relevant: https://groups.google.com/d/msg/bazel-discuss/V6ZsSsDwS9w/LMnBxiWaCgAJ |
Closing as a duplicate of #8984, please reopen if necessary. |
See also issue #8053 which includes the workaround of using |
Guys, could we reopen this? (The duplicate-ish issue is closed as stale; it's breaking google/boringssl on bazelci (we just spent a bunch of time on this over at rules_boost) ; and IMO the discussion here better captures the issue from the user perspective -> the implementation problem.) Some more context: boringssl currently fails on bazelci macOS x86_64, similar to protobuf before. Logs look like this, with header inclusion tearing between what I presume is brew installed openssl and //external/boringssl (named as openssl in the paths).
IMO this really shouldn't happen. As y'all say, Bazel-included external repos should really take precedence over system-installed libraries. And they would, except that Apple clang auto inserts As in the discussion linked above, I find myself thinking we should probably have (cc'ing @philwo and @hlopko and @rikbrown and @thundergolfer from the other issue in an attempt to unify. Also @keith bc, well, he's so fantastically great and helpful on all things Apple. Wishing all a great holiday in the meantime.) |
Thanks, Fabian! :) |
With this command I see |
^ The issue is that Apple clang adds that -I/usr/local/include regardless of flags, since it takes prescidence over the -isystems added by Bazel's I think the fixes--assuming we want to support Intel Apple or /usr/local/include are: |
Did that work? (for a quick workaround folks could do that locally in their projects) |
(I'm assuming you're asking about (2), i.e. adding I just did some tests against the original rules_boost case that brought me here, since bazelci made it easy to test on both Mac architectures :) (Backlinked above) The principle behind suppressing with However on arm64 (where it's unneeded in that test environment, since there's no /usr/local/include anyway) it gets prevented by Bazel ( Does that seem like the right way to go, Keith? Do you know where and how to weave this in from your prior work? If so, would you be down to just do? [As an aside, for me personally, the |
You could add |
I looked at that too but it also removes some important paths we'd have to recreate |
See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
* Make alias protocol_compiler visible * Workaround for broken macOS CI See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
See bazelbuild/bazel#10472 for further info.
Having the some problem on BCR. Workaround worked in bazelbuild/bazel-central-registry#1190. |
* Make alias protocol_compiler visible * Workaround for broken macOS CI See bazelbuild/bazel#10472 for further info.
* Update boringssl to 20240126-22d349c * review * set `--copt=-isystem/usr/local/include` for macos * upgrade platforms, add centos back in * try the other workaround mentioned in bazelbuild/bazel#10472 (comment)
see bazelbuild/bazel#10472 for more info on why this is needed. Without it, the build will try to use system headers which conflict with project defined headers in this build for boringssl
see bazelbuild/bazel#10472 for more info on why this is needed. Without it, the build will try to use system headers which conflict with project defined headers in this build for boringssl PiperOrigin-RevId: 627450385
see bazelbuild/bazel#10472 for more info on why this is needed. Without it, the build will try to use system headers which conflict with project defined headers in this build for boringssl PiperOrigin-RevId: 627450385
see bazelbuild/bazel#10472 for more info on why this is needed. Without it, the build will try to use system headers which conflict with project defined headers in this build for boringssl PiperOrigin-RevId: 627458516
This change rolls nearby-connections to 9065c0a9330b (9 revisions). cl/627563098 modified both SharedCredential and LocalCredential protos. And cl/615921095 changed the `signature_version` to strings. This CL updates the mojom representations. Note: A future CL will migrate these conversions to StructTraits (b/332745627) https://chromium.googlesource.com/external/github.com/google/nearby-connections.git/+log/ef924e5003e6..9065c0a9330b 2024-04-24 anthonyrueda@google.com [Presence] Add V1 encrypted adv hmac_key fields and update naming to align with latest changes to go/nearby-presence-spec > PiperOrigin-RevId: 627563098 > 2024-04-23 hais@google.com Remove unused include to fix OSS build > PiperOrigin-RevId: 627473304 > 2024-04-23 hais@google.com Fix copybara export of build rules for beto-core > PiperOrigin-RevId: 627464568 > 2024-04-23 hais@google.com Fix OSS bazel build on MacOS > see bazelbuild/bazel#10472 for more info on why this is needed. Without it, the build will try to use system headers which conflict with project defined headers in this build for boringssl > > PiperOrigin-RevId: 627458516 > 2024-04-23 hais@google.com Fix copybara export of beto-core headers > PiperOrigin-RevId: 627449838 > 2024-04-23 hais@google.com Update presence build rules and copybara export to OSS > - updates the build to be compatible with ldt in the open source repo > > PiperOrigin-RevId: 627415836 > 2024-04-23 awadhera@google.com Merge pull request #2468 from google/nwadih/fixMacOsBuild > Fix OSS bazel build on MacOS 2024-04-23 hais@google.com Automated Code Change > PiperOrigin-RevId: 627267684 > 2024-04-22 ftsui@google.com Fix TSAN errors. > PiperOrigin-RevId: 627186253 > Test: Manually verfied Quick Share, Phone Hub still WAI on DUT Fixed: b/311040986 Change-Id: Iddd18bc529782f9f7948d49da0ba12c6e1a4d627 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5503856 Reviewed-by: Ryan Hansberry <hansberry@chromium.org> Reviewed-by: Nasko Oskov <nasko@chromium.org> Commit-Queue: Crisrael Lucero <crisrael@google.com> Cr-Commit-Position: refs/heads/main@{#1297570}
Description of the problem:
Bazel's use of -isystem gives incorrect search path on macOS, specifically 10.15.2 (19C57) which is the system I have right now.
The observed behavior is that /usr/local/include is incorrectly searched before the directories local to external dependencies. If a dependency has two distinct versions both installed under /usr/local/include and specified in WORKSPACE as an external dependency, it probably won't compile nicely, or even if it compiles, the resulted binary is probably not what we intend it to be.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
1- Install latest version of protobuf with homebrew. This isn't specific to protobuf, but it happened to be one of the dependencies that I encountered.
2- Check out the protobuf examples. Again, this isn't specific to this example. I'm just too lazy to prepare and upload some code snippet somewhere.
3- Update WORKSPACE to something as follows. I'm just using an older version of protobuf to make the problem evident.
4- Build the example. The extra flags to bazel are to make this output reproducible as much as I can.
The exact errors are not significant to this issue. The important part is that the dependency-local files are #include-ing their corresponding header files with angle brackets <...> and the headers are incorrectly resolved to be under /usr/local/include.
What operating system are you running Bazel on?
macOS Catalina 10.15.2 (19C57)
What's the output of
bazel info release
?release 2.0.0
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?Have you found anything relevant by searching the web?
protocolbuffers/protobuf#5376 is definitely the same issue.
I did searches with "is:issue -isystem /usr/local/include" in the Bazel issues, but the results seemed too noisy for me to correlate any of them to this issue.
Any other information, logs, or outputs that you want to share?
I debugged this for a while, and my best guess so far is that there are two issues:
1- Bazel puts a space between -isystem and the path, which Clang doesn't seem like to take it that way. It also applies to -iquote.
2- The Clang I have here somehow adds "-I/usr/local/include" automatically. And since -I has higher precedence over -isystem, the search path will be wrong as long as we use -isystem for the external dependency directories.
To verify these two items, I simplified the bazel command line and tried these:
I used /Library/Developer/CommandLineTools/usr/bin/cpp in those commands because I was also suspecting https://github.com/Homebrew/brew/blob/master/Library/Homebrew/shims/super/cc but it looks innocent to me now.
The text was updated successfully, but these errors were encountered: