-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Support dynamically-linked FreeBSD libc when cross-compiling #23835
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
base: master
Are you sure you want to change the base?
Conversation
dac1fca
to
40dfc11
Compare
What is the delta installation size (both compressed and on disk)? |
Uncompressed Speaking of size savings: #21258 |
hmmmm, +13% / +24% is pretty bad for only gaining 1 new target. 14 megabytes of headers seems excessive. The files added look reasonable though. |
I think it looks worse than it actually is because we tend to take for granted the Linux situation of kernel and libc headers being separate. Some perspective:
In that light, I don't think it looks that bad actually. That said, there's definitely room to prune FreeBSD headers; some are really kernel-only, and there are probably still some that aren't strictly related to the kernel or libc. But pruning these is going to be a very manual and tedious process.
Also, just to be clear, this is adding all FreeBSD 14 targets:
|
zig-bootstrap works:
@mikdusan also verified that the resulting binary actually runs on FreeBSD 14. This should be ready for review. |
6edf506
to
12465d3
Compare
osreldate.h and sys/param.h were manually adjusted to not __FreeBSD_version since it will be defined by the compiler.
* NT_FREEBSD_ABI_TAG was manually adjusted from using a hardcoded value to using __FreeBSD_version which will be defined by the compiler. * GCJ stuff was removed. * HAVE_CTORS definitions were removed.
Currently covers version 1.7 (FreeBSD 14.0.0).
Based on data in std.zig.target.
…raries. Only works for FreeBSD 14+. Note that we still default to targeting FreeBSD 13. Contributes to ziglang#2876.
The driver doesn't support it, and FreeBSD 13+ on PPC64 uses ELFv2 anyway.
I agree, thanks for sharing this additional insight! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
…ibc.so. These symbols are defined in the statically-linked startup code. The real libc.so.7 contains strong references to them, so they need to be put into the dynamic symbol table.
We don't yet have a direct syscall layer in std.os.freebsd.
libc update instructions: https://github.com/ziglang/zig/wiki/Updating-libc#freebsd
ABI tooling: https://github.com/ziglang/libc-abi-tools/tree/main/freebsd
Caveats:
abilists
file, not minor/patch._init
/_fini
because it's 2025 and people should be using.init_array
/.fini_array
.Contributes to #2876.
My next priority will be dynamically-linked libc for NetBSD (#2877), after which I'll look at static linking for both.