Migrated from: https://github.com/ziglang/zig/issues/2879
Contribution instructions:
- Check if the function you want to implement exists in compiler-rt.
- If it does, just delete the implementation from all of the static libcs we bundle with Zig.
- But do be mindful of how the existing compiler-rt implementation performs vs the libc implementations.
- Otherwise, implement and export the function in an appropriate place in
lib/c, add tests intest/c, and delete the implementation from all of the static libcs we bundle with Zig.- It may not necessarily be meaningful to add tests if the function just trivially forwards to a Zig
stdfunction that is already thoroughly tested.
- It may not necessarily be meaningful to add tests if the function just trivially forwards to a Zig
- If it does, just delete the implementation from all of the static libcs we bundle with Zig.
- Run relevant test suites to make sure your changes didn't break anything.
zig build test-modules test-c-abi -Dtest-target-filter=musl -Dtest-target-filter=windows-gnuzig build test-libc-nsz -Dlibc-test-path=/path/to/libc-testwith libc-test- For more thorough testing, you can also pass
-fqemuand/or-fwasmtimeif you have these programs installed.
Notes:
- We currently bundle these static libcs with Zig:
lib/libc/musllib/libc/mingwlib/libc/wasi
- For musl, you can inspect
lib/libc/musl/libc.Sto see which exported symbols are part of the ABI and thus need to be provided by libzigc. These usually apply to wasi-libc too. - For MinGW-w64, keep in mind that it's only a partially static libc; most functions are still ultimately provided by UCRT DLLs. So there are only implementations of functions that UCRT for some reason lacks.
- Remember to remove deleted files from the lists in
src/libs/{mingw,musl,wasi_libc}.zig.
For API/ABI purposes, our targets are currently:
- musl: 1.2.5
- MinGW-w64:
38c8142f660b6ba11e7c408f2de1e9f8bfaf839e - wasi-libc:
c89896107d7b57aef69dcadede47409ee4f702ee