-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
C++ rules broken on macOS 12 Monterey and command line developer tools #14273
Comments
A simpler workaround than setting noa@Noas-MacBook-Air stage1 % BAZEL_LINKOPTS=-lc++ bazelisk build //main:hello-world
INFO: Analyzed target //main:hello-world (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //main:hello-world up-to-date:
bazel-bin/main/hello-world
INFO: Elapsed time: 0.078s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
% ./bazel-bin/main/hello-world
Hello world
Sun Nov 14 20:22:54 2021 |
The As I don't have access to a macOS 11 Big Sur, it is a bit unclear what has changed, but it seems like a good idea to me to have the |
This will cause the values passed in the link_libs parameters to not get silently dropped on macOS 12 Monterey, and fix the problem where the command line dev tools toolchain will output C++ binaries fails to start with a segmentation fault error. Fixes: bazelbuild#14273
On macOS, Bazel should be using |
Thanks for the fix, we should cherry-pick it for 5.0. |
@meteorcloudy Can this get into a 4.2.2 as well? I believe it qualifies as OS support. |
This will cause the values passed in the link_libs parameters to not get silently dropped on macOS 12 Monterey, and fix the problem where the command line dev tools toolchain will output C++ binaries fails to start with a segmentation fault error. Fixes: bazelbuild#14273 Closes bazelbuild#14275. PiperOrigin-RevId: 411840375
@meteorcloudy I cherry-picked the commit that landed to master and opened a PR to land it in |
@brentleyjones I agree that it looks bad that all released bazel versions fails to compile the example cpp hello world in the current stable macOS release that has been out for almost a month. One aspect that makes macOS boxes with just the developer tools so common is that as soon as a developer types for example 'git' in a Terminal window, a popup will suggest installing the developer tools. |
@nresare can you submit the 4.x PR as well? Not sure if they'll accept it but it should be the exact same as the others |
@nresare Thanks, merged! |
Also cherry-picking this for 4.2.2 |
This will cause the values passed in the link_libs parameters to not get silently dropped on macOS 12 Monterey, and fix the problem where the command line dev tools toolchain will output C++ binaries fails to start with a segmentation fault error. Fixes: #14273 Closes #14275. PiperOrigin-RevId: 411840375
This will cause the values passed in the link_libs parameters to not get silently dropped on macOS 12 Monterey, and fix the problem where the command line dev tools toolchain will output C++ binaries fails to start with a segmentation fault error. Fixes: bazelbuild#14273 Closes bazelbuild#14275. PiperOrigin-RevId: 411840375
This will cause the values passed in the link_libs parameters to not get silently dropped on macOS 12 Monterey, and fix the problem where the command line dev tools toolchain will output C++ binaries fails to start with a segmentation fault error. Fixes: #14273 Closes #14275. PiperOrigin-RevId: 411840375
This will cause the values passed in the link_libs parameters to not get silently dropped on macOS 12 Monterey, and fix the problem where the command line dev tools toolchain will output C++ binaries fails to start with a segmentation fault error. Fixes: bazelbuild#14273 Closes bazelbuild#14275. PiperOrigin-RevId: 411840375
Description of the problem / feature request:
There are mainly two ways to install the basic apple provided clang compiler toolchain on macOS. Either you install the Command Line developer tools by invoking
xcode-select --install
, or you install the full XCode development environment, which includes a graphical IDE and tooling for application development on all of Apple's operating systems. The latter is a significantly larger download at >10GiB.Bazel 4.2.1 will detect and use the C++ compiler and linker that is available through the command line tools, but as of macOS 12 Monterey, attempting to build C++ binaries will succeed but the resulting binaries will fail on startup with a Segmentation Fault error. This is because the linker invocation generating the binary is not invoked with the -lc++ flag, indicating that the libc++ library should be loaded by the dynamic linker on startup.
The suggested solution to this problem is to install the full XCode IDE, which apparently works around this problem, but it would be neat to have this work out-of-the-box
Feature requests: what underlying problem are you trying to solve with this feature?
Make bazel more user friendly by having it build functional c++ binaries without non-obvious workarounds such as installing XCode on a pretty standard setup on one of the more common platforms.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
xcode-select --install
4.1
cd cpp-tutorial/stage1
4.2
bazelisk build //main:hello-world
./bazel-bin/main/hello-world
What operating system are you running Bazel on?
I have reproduce this with macOS 12.0.1 Monterey on an Apple Silicon M1 MacBook as well as an Intel MacBook Pro.
What's the output of
bazel info release
?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?
There are a few github issues describing issues building bazel with bazel on macOS Monterey, and problems with segfaulting binaries, but they seem to be closed with the recommendation to install XCode, which seems to me like a workaround.
Any other information, logs, or outputs that you want to share?
Running
bazel build --subcommands
reveals that the required linker flag-lc++
is missing from the linker invocation. Addinglinkopts = ["-lc++"],
to thecc_binary
rule will work around this problem.The text was updated successfully, but these errors were encountered: