Repository navigation
Conversation
This is enforced on bsd in order to use $ORIGIN in library paths. Linux does nothing with this so we don't set it there. Fixes bazelbuild#854
Member
Author
|
i tested on openbsd to verify |
trybka
approved these changes
Sep 1, 2026
zakinko
added a commit
to zakinko/rules_cc
that referenced
this pull request
Sep 16, 2026
FreeBSD and OpenBSD have been routed to a static toolchain since 2016, one that writes in the compiler path, the builtin include directories and the link libraries, while every other Unix gets those probed. NetBSD and DragonFly never got a name at all and fell through to the autoconfigured path by accident, which works apart from the toolchain being called "k8". Run the autoconfiguration on all four. Four things it did not know how to do there: - Find the C driver, since the BSDs install it as cc and a gcc-first search would prefer one from ports or pkgsrc over the compiler the system was built with. - Name the BSD libcs for //cc/libc, which stopped at NetBSD. - Set DF_ORIGIN. Bazel puts $ORIGIN in the RPATH it generates and OpenBSD's ld.so only expands it when that flag is set; glibc and musl expand it either way, so the need is invisible on Linux. The static toolchain carried -z origin (bazelbuild#855, for bazelbuild#854) and the autoconfigured one did not. - Leave the C++ standard libraries outside --as-needed on OpenBSD. The driver expands -lstdc++ to -lc++ -lc++abi -lpthread there, and libpthread is only reached through the other two, so wrapping the expansion drops it and the binary dies at startup on undefined pthread_* symbols (bazelbuild#857). I had claimed the link libraries needed no change, on the strength of cc -### showing the driver substituting the platform's C++ runtime for -lstdc++. That was the wrong measurement: cc -### prints what the driver passes to the linker, not what survives the link. @c2qd caught it with an objdump of the NEEDED entries and a binary that failed to start. The static toolchain stays behind BAZEL_USE_LEGACY_BSD_TOOLCHAIN=1, the way the legacy macOS toolchain does. It is offered only for FreeBSD and OpenBSD, which are the two BUILD.static.bsd describes.
zakinko
added a commit
to zakinko/rules_cc
that referenced
this pull request
Sep 17, 2026
FreeBSD and OpenBSD have been routed to a static toolchain since 2016, one that writes in the compiler path, the builtin include directories and the link libraries, while every other Unix gets those probed. NetBSD and DragonFly never got a name at all and fell through to the autoconfigured path by accident, which works apart from the toolchain being called "k8". Run the autoconfiguration on all four. Four things it did not know how to do there: - Find the C driver, since the BSDs install it as cc and a gcc-first search would prefer one from ports or pkgsrc over the compiler the system was built with. - Name the BSD libcs for //cc/libc, which stopped at NetBSD. - Set DF_ORIGIN. Bazel puts $ORIGIN in the RPATH it generates and OpenBSD's ld.so only expands it when that flag is set; glibc and musl expand it either way, so the need is invisible on Linux. The static toolchain carried -z origin (bazelbuild#855, for bazelbuild#854) and the autoconfigured one did not. - Leave the C++ standard libraries outside --as-needed on OpenBSD. The driver expands -lstdc++ to -lc++ -lc++abi -lpthread there, and libpthread is only reached through the other two, so wrapping the expansion drops it and the binary dies at startup on undefined pthread_* symbols (bazelbuild#857). I had claimed the link libraries needed no change, on the strength of cc -### showing the driver substituting the platform's C++ runtime for -lstdc++. That was the wrong measurement: cc -### prints what the driver passes to the linker, not what survives the link. @c2qd caught it with an objdump of the NEEDED entries and a binary that failed to start. The static toolchain stays behind BAZEL_USE_LEGACY_BSD_TOOLCHAIN=1, the way the legacy macOS toolchain does. It is offered only for FreeBSD and OpenBSD, which are the two BUILD.static.bsd describes.
zakinko
added a commit
to zakinko/rules_cc
that referenced
this pull request
Sep 23, 2026
FreeBSD and OpenBSD have been routed to a static toolchain since 2016, one that writes in the compiler path, the builtin include directories and the link libraries, while every other Unix gets those probed. NetBSD and DragonFly never got a name at all and fell through to the autoconfigured path by accident, which works apart from the toolchain being called "k8". Run the autoconfiguration on all four. Four things it did not know how to do there: - Find the C driver, since the BSDs install it as cc and a gcc-first search would prefer one from ports or pkgsrc over the compiler the system was built with. - Name the BSD libcs for //cc/libc, which stopped at NetBSD. - Set DF_ORIGIN. Bazel puts $ORIGIN in the RPATH it generates and OpenBSD's ld.so only expands it when that flag is set; glibc and musl expand it either way, so the need is invisible on Linux. The static toolchain carried -z origin (bazelbuild#855, for bazelbuild#854) and the autoconfigured one did not. - Leave the C++ standard libraries outside --as-needed on OpenBSD. The driver expands -lstdc++ to -lc++ -lc++abi -lpthread there, and libpthread is only reached through the other two, so wrapping the expansion drops it and the binary dies at startup on undefined pthread_* symbols (bazelbuild#857). I had claimed the link libraries needed no change, on the strength of cc -### showing the driver substituting the platform's C++ runtime for -lstdc++. That was the wrong measurement: cc -### prints what the driver passes to the linker, not what survives the link. @c2qd caught it with an objdump of the NEEDED entries and a binary that failed to start. The static toolchain stays behind BAZEL_USE_LEGACY_BSD_TOOLCHAIN=1, the way the legacy macOS toolchain does. It is offered only for FreeBSD and OpenBSD, which are the two BUILD.static.bsd describes.
3405691582
added a commit
to 3405691582/android-cuttlefish
that referenced
this pull request
Oct 7, 2026
On OpenBSD the BSD toolchain in rules_cc drives the link with clang rather than clang++ and only passes -lc++, so libc++abi, libpthread and libm are missing from every C++ link. rules_cc fixed this in 0.2.24 (bazelbuild/rules_cc#859: -lc++abi and -lpthread when cpu is openbsd, -lm on both BSDs) and also links with -z origin there (bazelbuild/rules_cc#855), which OpenBSD's ld.so needs before it will expand $ORIGIN in a run path. 0.2.25 is the first version with both on the registry and the one Bazel pins at head. Bazel 8.5.1 and 9.2.0 both generate @local_config_cc from rules_cc, so the toolchain config changes on Linux as well. While we are here, move the bazel_skylib and bazel_features pins up to what the graph already resolves to, 1.9.0 (wanted by apple_support, which the new rules_cc brings in) and 1.50.0 (wanted by rules_cc itself); that silences the two --check_direct_dependencies warnings without changing the resolved module graph.
3405691582
added a commit
to 3405691582/android-cuttlefish
that referenced
this pull request
Oct 8, 2026
On OpenBSD the BSD toolchain in rules_cc drives the link with clang rather than clang++ and only passes -lc++, so libc++abi, libpthread and libm are missing from every C++ link. rules_cc fixed this in 0.2.24 (bazelbuild/rules_cc#859: -lc++abi and -lpthread when cpu is openbsd, -lm on both BSDs) and also links with -z origin there (bazelbuild/rules_cc#855), which OpenBSD's ld.so needs before it will expand $ORIGIN in a run path. 0.2.25 is the first version with both on the registry and the one Bazel pins at head. Bazel 8.5.1 and 9.2.0 both generate @local_config_cc from rules_cc, so the toolchain config changes on Linux as well. While we are here, move the bazel_skylib and bazel_features pins up to what the graph already resolves to, 1.9.0 (wanted by apple_support, which the new rules_cc brings in) and 1.50.0 (wanted by rules_cc itself); that silences the two --check_direct_dependencies warnings without changing the resolved module graph.
3405691582
added a commit
to 3405691582/android-cuttlefish
that referenced
this pull request
Oct 10, 2026
On OpenBSD the BSD toolchain in rules_cc drives the link with clang rather than clang++ and only passes -lc++, so libc++abi, libpthread and libm are missing from every C++ link. rules_cc fixed this in 0.2.24 (bazelbuild/rules_cc#859: -lc++abi and -lpthread when cpu is openbsd, -lm on both BSDs) and also links with -z origin there (bazelbuild/rules_cc#855), which OpenBSD's ld.so needs before it will expand $ORIGIN in a run path. 0.2.25 is the first version with both on the registry and the one Bazel pins at head. Bazel 8.5.1 and 9.2.0 both generate @local_config_cc from rules_cc, so the toolchain config changes on Linux as well. While we are here, move the bazel_skylib and bazel_features pins up to what the graph already resolves to, 1.9.0 (wanted by apple_support, which the new rules_cc brings in) and 1.50.0 (wanted by rules_cc itself); that silences the two --check_direct_dependencies warnings without changing the resolved module graph.
zakinko
added a commit
to zakinko/rules_cc
that referenced
this pull request
Nov 14, 2026
FreeBSD and OpenBSD have been routed to a static toolchain since 2016, one that writes in the compiler path, the builtin include directories and the link libraries, while every other Unix gets those probed. NetBSD and DragonFly never got a name at all and fell through to the autoconfigured path by accident, which works apart from the toolchain being called "k8". Run the autoconfiguration on all four. Four things it did not know how to do there: - Find the C driver, since the BSDs install it as cc and a gcc-first search would prefer one from ports or pkgsrc over the compiler the system was built with. - Name the BSD libcs for //cc/libc, which stopped at NetBSD. - Set DF_ORIGIN. Bazel puts $ORIGIN in the RPATH it generates and OpenBSD's ld.so only expands it when that flag is set; glibc and musl expand it either way, so the need is invisible on Linux. The static toolchain carried -z origin (bazelbuild#855, for bazelbuild#854) and the autoconfigured one did not. - Leave the C++ standard libraries outside --as-needed on OpenBSD. The driver expands -lstdc++ to -lc++ -lc++abi -lpthread there, and libpthread is only reached through the other two, so wrapping the expansion drops it and the binary dies at startup on undefined pthread_* symbols (bazelbuild#857). I had claimed the link libraries needed no change, on the strength of cc -### showing the driver substituting the platform's C++ runtime for -lstdc++. That was the wrong measurement: cc -### prints what the driver passes to the linker, not what survives the link. @c2qd caught it with an objdump of the NEEDED entries and a binary that failed to start. The static toolchain stays behind BAZEL_USE_LEGACY_BSD_TOOLCHAIN=1, the way the legacy macOS toolchain does. It is offered only for FreeBSD and OpenBSD, which are the two BUILD.static.bsd describes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is enforced on bsd in order to use $ORIGIN in library paths. Linux
does nothing with this so we don't set it there.
Fixes #854