Repository navigation
Conversation
|
|
||
| action_configs = [objcopy_embed_data_action] if is_bsd else [] | ||
| extra_default_link_flags = [] | ||
| if cpu == "openbsd": |
There was a problem hiding this comment.
do I even want to know why this is stuffed into cpu?
There was a problem hiding this comment.
I think separately we should probably pass through the constraints for OS here, since we would need that to have the correct condition for both arm64 (currently not supported) and x86_64, but I just figured I wouldn't mess with it right now, this has been here since the beginning
|
Measured on FreeBSD 14.3, where On OpenBSD 7.9 I get the same set you have, one library at a time: nothing netbsd and dragonfly are not in |
|
can you clarify if you're saying this works for you on freebsd/openbsd, or what libraries are missing otherwise |
|
dragonfly bsd would need a new entry here first probably https://github.com/bazelbuild/platforms/blob/27e914a43e306c61e8584a6c6bcd9c1123e9024c/os/BUILD#L16-L30 |
This mirrors this behavior from the clang driver: https://github.com/llvm/llvm-project/blob/3e892fad65730692057da27bebb2e34d3ad7bde7/clang/lib/Driver/ToolChains/OpenBSD.cpp#L365-L366 The same does not apply for freebsd (I didn't check netbsd which isn't supported here right now). Alternatively we could use clang++ for linking directly instead of clang, which would add these automatically, but that would make it harder to disable these in the case you are linking pure C Fixes bazelbuild#857
a4f692a to
70575fb
Compare
|
Yes, both. With this change I have now built Bazel from source, with no each verified by running the resulting binary on a genrule. On FreeBSD the Agreed on dragonfly — |
DragonFly BSD has no constraint_value here, so nothing can select on it and no toolchain can name it. Rules that already handle the other BSDs run into this from the outside: bazelbuild/rules_cc#859 adds link flags for FreeBSD and OpenBSD, and DragonFly cannot join them until the constraint exists. The host platform extension has the same gap from the inside. The JVM reports os.name as "DragonFlyBSD" there, which Bazel lowercases to "dragonflybsd", so _translate_os falls through and returns None. A host platform on DragonFly then carries a cpu constraint and no os constraint at all, which is worse than carrying a wrong one: the absence is silent, and nothing can select on it either way. Measured on DragonFly 6.4.2 with openjdk21: $ uname -s DragonFly $ java -XshowSettings:properties -version 2>&1 | grep os.name os.name = DragonFlyBSD Note that uname and the JVM disagree on the spelling, so startswith() matters here rather than being a stylistic choice.
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.
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.
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.
This mirrors this behavior from the clang driver:
https://github.com/llvm/llvm-project/blob/3e892fad65730692057da27bebb2e34d3ad7bde7/clang/lib/Driver/ToolChains/OpenBSD.cpp#L365-L366
The same does not apply for freebsd (I didn't check netbsd which isn't
supported here right now).
Alternatively we could use clang++ for linking directly instead of
clang, which would add these automatically, but that would make it
harder to disable these in the case you are linking pure C
Fixes #857