Zig Version
0.16.0-dev.1871+eab93d357
Edited post (2026年05月04日)
As the following (specific) issue has been fixed, we should consider whether such an issue will occur again when removing more libc symbols. It may be smart to run zig-libc-test against the rest of compiler_rt.
Steps to Reproduce and Observed Behavior
First, compile a version of Zig which uses the compiler_rt implementation for some of the libc math functions. For example (edit: this branch has been fixed, so you should break it in another way):
git fetch -u https://codeberg.org/mercenary/zig 2879-rt:mercenary-2879-rt
git switch mercenary-2879-rt
stage3/bin/zig build -p stage4 -Dno-lib -Denable-llvm
Then, test stage4 against zig-libc-test:
zig="$(realpath stage4/bin/zig)"
cd /tmp/zig-libc-test
"$zig" build test -Dtarget=x86_64-linux-musl
The output is like this (edited for readability):
test
+- run exe log2 failure
error: ========= expected this stdout: =========
========= but found: ====================
/cache/p/#/src/math/sanity/log2.h:1: bad fp exception: RN log2(-0x1.02239f3c6a8f1p+3)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log2.h:3: bad fp exception: RN log2(-0x1.0c34b3e01e6e7p+3)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log2.h:4: bad fp exception: RN log2(-0x1.a206f0a19dcc4p+2)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log2.h:7: bad fp exception: RN log2(-0x1.a05cc754481d1p-2)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log2.h:10: bad fp exception: RN log2(-0x1.5b86ea8118a0ep-1)=nan, want INVALID got 0
/cache/p/#/src/math/special/log2.h:1: bad fp exception: RN log2(0x0p+0)=-inf, want DIVBYZERO got 0
/cache/p/#/src/math/special/log2.h:2: bad fp exception: RN log2(-0x0p+0)=-inf, want DIVBYZERO got 0
/cache/p/#/src/math/special/log2.h:3: bad fp exception: RN log2(-0x1p-100)=nan, want INVALID got 0
/cache/p/#/src/math/special/log2.h:5: bad fp exception: RN log2(-0x1p+0)=nan, want INVALID got 0
/cache/p/#/src/math/special/log2.h:7: bad fp exception: RN log2(-inf)=nan, want INVALID got 0
failed command: ./.zig-cache/o/1f8d705f5f07db37694239e72c4538c5/log2
test
+- run exe exp failure
error: ========= expected this stdout: =========
========= but found: ====================
/cache/p/#/src/math/crlibm/exp.h:42: bad fp exception: RN exp(0x1.62e42fefa39fp+9)=inf, want INEXACT|OVERFLOW got 0
/cache/p/#/src/math/crlibm/exp.h:44: bad fp exception: RU exp(0x1.62e42fefa39fp+9)=inf, want INEXACT|OVERFLOW got 0
/cache/p/#/src/math/crlibm/exp.h:46: bad fp exception: RD exp(0x1.62e42fefa39fp+9)=0x1.fffffffffffffp+1023, want INEXACT|OVERFLOW got 0
/cache/p/#/src/math/crlibm/exp.h:48: bad fp exception: RZ exp(0x1.62e42fefa39fp+9)=0x1.fffffffffffffp+1023, want INEXACT|OVERFLOW got 0
/cache/p/#/src/math/crlibm/exp.h:49: bad fp exception: RN exp(-0x1.74910d52d3051p+9)=0x1p-1074, want INEXACT|UNDERFLOW got INEXACT
[SNIP]
/cache/p/#/src/math/sanity/log10.h:7: bad fp exception: RN log10(-0x1.a05cc754481d1p-2)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log10.h:10: bad fp exception: RN log10(-0x1.5b86ea8118a0ep-1)=nan, want INVALID got 0
/cache/p/#/src/math/special/log10.h:1: bad fp exception: RN log10(0x0p+0)=-inf, want DIVBYZERO got 0
/cache/p/#/src/math/special/log10.h:2: bad fp exception: RN log10(-0x0p+0)=-inf, want DIVBYZERO got 0
/cache/p/#/src/math/special/log10.h:3: bad fp exception: RN log10(-0x1p-100)=nan, want INVALID got 0
/cache/p/#/src/math/special/log10.h:5: bad fp exception: RN log10(-0x1p+0)=nan, want INVALID got 0
/cache/p/#/src/math/special/log10.h:7: bad fp exception: RN log10(-inf)=nan, want INVALID got 0
failed command: ./.zig-cache/o/1926366952ad1c89b1a1f593c3d14688/log10
Build Summary: 501/511 steps succeeded (9 failed)
test transitive failure
+- run exe acoshf failure
+- run exe exp failure
+- run exe lgamma_r failure
+- run exe log10 failure
+- run exe log10f failure
+- run exe log2 failure
+- run exe log2f failure
+- run exe log failure
+- run exe logf failure
This issue blocks ziglang/zig!30648, which tries to remove libc functions in favor of the existing compiler_rt implementations, contributing to #2879. See also this comment in the PR.
Expected Behavior
I expect the compiler_rt implementations not to fail any additional tests, as compared to the musl implementations.
### Zig Version
0.16.0-dev.1871+eab93d357
### Edited post (2026年05月04日)
As the following (specific) issue has been fixed, we should consider whether such an issue will occur again when removing more _libc_ symbols. It [may be smart](https://codeberg.org/ziglang/zig/issues/30659#issuecomment-9541586) to run zig-libc-test against the rest of _compiler_rt_.
### Steps to Reproduce and Observed Behavior
First, compile a version of Zig which uses the _compiler_rt_ implementation for some of the _libc_ math functions. For example (**edit**: this branch has been fixed, so you should break it in another way):
```sh
git fetch -u https://codeberg.org/mercenary/zig 2879-rt:mercenary-2879-rt
git switch mercenary-2879-rt
stage3/bin/zig build -p stage4 -Dno-lib -Denable-llvm
```
Then, test stage4 against [zig-libc-test](https://github.com/rpkak/zig-libc-test):
```sh
zig="$(realpath stage4/bin/zig)"
cd /tmp/zig-libc-test
"$zig" build test -Dtarget=x86_64-linux-musl
```
The output is like this (edited for readability):
```
test
+- run exe log2 failure
error: ========= expected this stdout: =========
========= but found: ====================
/cache/p/#/src/math/sanity/log2.h:1: bad fp exception: RN log2(-0x1.02239f3c6a8f1p+3)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log2.h:3: bad fp exception: RN log2(-0x1.0c34b3e01e6e7p+3)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log2.h:4: bad fp exception: RN log2(-0x1.a206f0a19dcc4p+2)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log2.h:7: bad fp exception: RN log2(-0x1.a05cc754481d1p-2)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log2.h:10: bad fp exception: RN log2(-0x1.5b86ea8118a0ep-1)=nan, want INVALID got 0
/cache/p/#/src/math/special/log2.h:1: bad fp exception: RN log2(0x0p+0)=-inf, want DIVBYZERO got 0
/cache/p/#/src/math/special/log2.h:2: bad fp exception: RN log2(-0x0p+0)=-inf, want DIVBYZERO got 0
/cache/p/#/src/math/special/log2.h:3: bad fp exception: RN log2(-0x1p-100)=nan, want INVALID got 0
/cache/p/#/src/math/special/log2.h:5: bad fp exception: RN log2(-0x1p+0)=nan, want INVALID got 0
/cache/p/#/src/math/special/log2.h:7: bad fp exception: RN log2(-inf)=nan, want INVALID got 0
failed command: ./.zig-cache/o/1f8d705f5f07db37694239e72c4538c5/log2
test
+- run exe exp failure
error: ========= expected this stdout: =========
========= but found: ====================
/cache/p/#/src/math/crlibm/exp.h:42: bad fp exception: RN exp(0x1.62e42fefa39fp+9)=inf, want INEXACT|OVERFLOW got 0
/cache/p/#/src/math/crlibm/exp.h:44: bad fp exception: RU exp(0x1.62e42fefa39fp+9)=inf, want INEXACT|OVERFLOW got 0
/cache/p/#/src/math/crlibm/exp.h:46: bad fp exception: RD exp(0x1.62e42fefa39fp+9)=0x1.fffffffffffffp+1023, want INEXACT|OVERFLOW got 0
/cache/p/#/src/math/crlibm/exp.h:48: bad fp exception: RZ exp(0x1.62e42fefa39fp+9)=0x1.fffffffffffffp+1023, want INEXACT|OVERFLOW got 0
/cache/p/#/src/math/crlibm/exp.h:49: bad fp exception: RN exp(-0x1.74910d52d3051p+9)=0x1p-1074, want INEXACT|UNDERFLOW got INEXACT
[SNIP]
/cache/p/#/src/math/sanity/log10.h:7: bad fp exception: RN log10(-0x1.a05cc754481d1p-2)=nan, want INVALID got 0
/cache/p/#/src/math/sanity/log10.h:10: bad fp exception: RN log10(-0x1.5b86ea8118a0ep-1)=nan, want INVALID got 0
/cache/p/#/src/math/special/log10.h:1: bad fp exception: RN log10(0x0p+0)=-inf, want DIVBYZERO got 0
/cache/p/#/src/math/special/log10.h:2: bad fp exception: RN log10(-0x0p+0)=-inf, want DIVBYZERO got 0
/cache/p/#/src/math/special/log10.h:3: bad fp exception: RN log10(-0x1p-100)=nan, want INVALID got 0
/cache/p/#/src/math/special/log10.h:5: bad fp exception: RN log10(-0x1p+0)=nan, want INVALID got 0
/cache/p/#/src/math/special/log10.h:7: bad fp exception: RN log10(-inf)=nan, want INVALID got 0
failed command: ./.zig-cache/o/1926366952ad1c89b1a1f593c3d14688/log10
Build Summary: 501/511 steps succeeded (9 failed)
test transitive failure
+- run exe acoshf failure
+- run exe exp failure
+- run exe lgamma_r failure
+- run exe log10 failure
+- run exe log10f failure
+- run exe log2 failure
+- run exe log2f failure
+- run exe log failure
+- run exe logf failure
```
This issue blocks ziglang/zig!30648, which tries to remove _libc_ functions in favor of the existing _compiler_rt_ implementations, contributing to [#2879](https://github.com/ziglang/zig/issues/2879). See also [this comment in the PR](https://codeberg.org/ziglang/zig/pulls/30648#issuecomment-9455507).
### Expected Behavior
I expect the _compiler_rt_ implementations not to fail any additional tests, as compared to the _musl_ implementations.