wasm linker lowers undefined and 0 incorrectly with respect to the bss section
Zig Version
0.11.0-dev.1898+36d47dd19
Steps to Reproduce and Observed Behavior
This test case is incorrect: https://github.com/ziglang/zig/blob/36d47dd1991f0ccd7a9673075624f09500cc415e/test/link/wasm/bss/build.zig
The global variable has value undefined:
https://github.com/ziglang/zig/blob/36d47dd1991f0ccd7a9673075624f09500cc415e/test/link/wasm/bss/lib.zig#L1
So it should not go into the bss section in debug mode.
Furthermore, when I change the value to 0 it should definitely go into bss, however in this case the test fails.
Expected Behavior
Zig is technically allowed to lower undefined in any way it wants to, however the linker test can test the actual behavior of the linker. It should do the following for undefined:
- Debug, ReleaseSafe: lower to 0xaa bytes
- ReleaseFast, ReleaseSmall: lower to bss
For zero values, it must lower to bss.
cc @Luukdegram and @kubkon
Thanks for reporting and clarifying this with me. I'll have a fix ready for both undefined and zero values this week :)
If you make it .build_modes = false and handle each of the build modes internally inside the build.zig file, that will make it easier for me to port the commit from master branch into #14647 :slightly_smiling_face: