add OpenBSD libc as a cross compilation target
Extracted from #514.
This is needed for OpenBSD to become a tier 1 target.
The example set by glibc can be followed.
See also this wiki page: https://github.com/ziglang/zig/wiki/Updating-libc
@andrewrk is that link broken? It leads to a "create new page" for me.
Is this the right wiki page? https://github.com/ziglang/zig/wiki/Updating-libc
same issue in : #2877 (NetBSD) and #2878 (OpenBSD)
I fixed the link in andrew's comment.
What should I do to add OpenBSD libc? This project can fetch openbsd libc files.
@locriacyber, openbsd-ziglibc is getting real libc and headers files. I think what is expected here is to get only functions stubs.
not header files? openbsd use clang as the compiler and I think it has its own libc headers. Given how OpenBSD has no ABI guarantee, every version of OpenBSD has its own libc.a libc.so to link with.
to build C program (using zig compiler), you need both (libc stubs and header files). to build ZIG program (using zig compiler), you need only libc stubs (assuming no C dependency).
openbsd-ziglibc extracts the whole sets of C headers which are normally installed (~50 Mo for only one OS version and only one architecture).
(and not all architectures are using clang as compiler, but it is another discussion)
What do you mean by "libc stubs" in case of OpenBSD? The symbol table of libc?
Just stating for the record that, while I will be tackling both #2876 and #2877, it's very unlikely that I'll work on this one. As far as I can tell, OpenBSD has no support whatsoever for building on anything but OpenBSD; on the other hand, I was able to cross-compile both FreeBSD and NetBSD on Linux.
If an OpenBSD user wants to tackle this, however, I'm happy to help with everything but actually building libc.
just for reference, at some point I was able to cross compile from Linux (I have not check if it is still working). see https://github.com/semarie/openbsd-ziglibc
it is a shell script (runnable on Linux after few modification), which will download objects/libs files from openbsd server, and create a environment suitable for ZIG_LIBC.
The reason we need to build from source is that, in a release tarball/image, it is nearly impossible to separate the kernel + libc headers from all the other headers coming from various libraries.