Support dynamically-linked NetBSD libc when cross-compiling#23913
Support dynamically-linked NetBSD libc when cross-compiling#23913alexrp merged 22 commits intoziglang:masterfrom
Conversation
|
I should note that libc++ currently fails to cross-compile for NetBSD even with this PR, meaning that I can't really make progress on zig-bootstrap. It's some obscure issue in locale code, and I don't feel particularly motivated to investigate that nightmare fuel right now. |
Ok well, I did, and apparently when the cc @brad0 I've seen you do some NetBSD work upstream in LLVM, maybe you'd be interested in this. |
This didn't cause any problems in practice, but doing it this way is technically more correct.
We want the latest unversioned inclusion that fits the target version. This theoretically matters because it might have a different global vs weak linkage compared to an older inclusion.
* mips64/mips64el on NetBSD are soft float; we have no support for this yet. * powerpc64 does not appear to be a thing. * riscv32/riscv64 have not seen official releases yet.
…rgets. This allows ubsan-rt to build.
* powerpc64 does not appear to be a thing. * riscv32/riscv64 have not had actual releases yet.
sys/param.h was manually adjusted to not define __NetBSD_Version__ since it will be defined by the compiler.
* sysident_assym.h was manually expanded.
* The ELF_NOTE_MARCH_DESC and ELF_NOTE_MARCH_DESCSZ macros will be defined
by the compiler.
* Legacy .init/.fini stuff was removed.
* GCJ nonsense was removed.
Currently covers version 10.1.
Based on data in std.zig.target.
We don't yet have a direct syscall layer in std.os.netbsd.
…aries. Only works for NetBSD 10.1+. Note that we still default to targeting NetBSD 9. Contributes to #2877.
|
@mikdusan has verified that a cross-compiled program works on NetBSD. This should be ready for review. As mentioned above, there's still more work to be done in libc++ for zig-bootstrap to work for NetBSD, however. |
libc update instructions: https://github.com/ziglang/zig/wiki/Updating-libc#netbsd
ABI tooling: https://github.com/ziglang/libc-abi-tools/tree/main/netbsd
Caveats:
.init/.finibecause it's 2025 and people should be using.init_array/.fini_array.Contributes to #2877.
Release Notes
Zig now allows cross-compiling to NetBSD 10.1+ by providing stub libraries for dynamic libc, similar to how cross-compilation for glibc is handled. Additionally, all system and libc headers are provided.