-
Notifications
You must be signed in to change notification settings - Fork 94
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++ cc_binary segfaults on macos-12 #226
Comments
You likely need to pass macos_minimum_os to make sure the binary is built for your version and not a newer one. You can check the binary with vtool to see what version it's targeting |
You mean it builds for something other than my current os? By default? 🤯
But even when using
because there was no change for Bazel:
|
probably worth verifying the compile commands do correctly have the minimal OS version baked into them. is the crash report the same as the original post? |
What exactly is the expected effect of passing The commands run for compiling and linking are this:
But even when I add
Why isn't the C++ standard library just added to the linker command line as it is done for Linux? |
I missed that adding the C++ stdlib explicitly fixes things. I don't know why that's generally not passed by default. I think it might have to do with the cc toolchain doesn't know if it's linking a C++ or a C binary right now I don't think. with the apple toolchain from the apple_support repo this isn't a problem since we use clang++ to link C++ binaries, where the default toolchain uses the non ++ version |
Description of the problem / feature request:
The most basic cc hello world example produces a segfaulting binary on macos-12, when using rules_cc > 0.0.4.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
WORKSPACE:
BUILD:
hello.cc:
What operating system are you running Bazel on?
macos-12 (on Github Actions)
What's the output of
bazel info release
?release 6.5.0
What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?
I am using rules_cc 0.0.9 (See WORKSPACE above), also tried 0.0.5 - 0.0.8 -- all of them fail in the same way. Version 0.0.1 works (that was the version we were using, but wanted to upgrade to the latest. 0.0.4 is the last version that works)
What Bazel options do you use to trigger the issue? What C++ toolchain do you use?
No added options (just -s to see the commands).
The project is using the local_config_cc toolchain created by rules_cc.
Have you found anything relevant by searching the web?
No.
Any other information, logs, or outputs that you want to share?
Here is a CI run: https://github.com/avdv/testproject/actions/runs/9612425632/job/26513036166
The build succeeds on Ubuntu, but fails on macos with:
Inside a tmate session I could see that the acutal command that it used to link was this:
So, this does not specify any C++ libraries at all, resulting in dynamic resolution at runtime:
The cc toolchain's config has
link_libs = ["-lstdc++", "-lm"]
but that is not passed to the linker command....After adding
linkopts = ["-lstdc++"]
to thecc_binary
rule, the binary works.The text was updated successfully, but these errors were encountered: