Build: Fix bug causing ReleaseSmall to fail on Windows#15756
Conversation
Due to the change in default behavior of ReleaseSmall, debug info are stripped by default. However because `Compile.create` still defaults to null, `producesPdbFile` will report true for `lib/std/Build/Step/InstallArtifact.zig` causing it to fail on copying a file that does not exist. This commit change the default of strip depending on `optimize`.
|
|
I don't think the current/intended behavior of ReleaseFast is to strip the binaries, but i could also be wrong or misinterpreting what you said 😄. Linux: ~/Projects/zigProjects/bench
Zig-Shell ❯ zig build -Doptimize=ReleaseFast
~/Projects/zigProjects/bench 6s
Zig-Shell ❯ file zig-out/bin/bench
zig-out/bin/bench: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not strippedWindows builds also produces pdb. |
|
Ok I take back what I said then. Apologies :) |
|
Seems like CI is failing on Lines 2185 to 2197 in 7cf2cbb I assume it's triggered because strip is now set to true on ReleaseSmall, thus failing on the builtin strip check. I haven't investigated further yet so i could be totally wrong, but does it make sense that this test should have been skipped for ReleaseSmall because there is no debug info? |
|
I guess, if I understood correctly, that one could use |
|
I think I have a better understanding of this now. The problem is more specifically because it's stripping the test (addTest in Build.zig). So it depends on the desired behavior of tests. Whether tests should also strip or not. So there are three options here:
edit: for now, i am going with the 1st option. |
Because tests are also stripped by ReleaseSmall, the test specified in this commit will fail on ReleaseSmall due to no debug info.
| const self = owner.allocator.create(Compile) catch @panic("OOM"); | ||
| self.* = Compile{ | ||
| .strip = null, | ||
| .strip = if (options.optimize == .ReleaseSmall) true else null, |
There was a problem hiding this comment.
The previous value was correct. The default is decided by the compiler rather than the build system. null means to use the compiler's default.
There was a problem hiding this comment.
I think I understand this now, and it does make sense why the CI was initially failing. Thanks for letting me know and sorry for the bad initial commit.
I reverted the commits and modified it to just check inside the producesPdbFile function instead of changing the strip value. Hopefully that's better(?).
This change allows InstallArtifact to not produce a pdb file while keeping the default strip to the compiler.
Fixes bug causing ReleaseSmall to fail on Windows. Due to the change in default behavior of ReleaseSmall, debug info are stripped by default. However because `Compile.create` still defaults to null, `producesPdbFile` will report true for `lib/std/Build/Step/InstallArtifact.zig` causing it to fail on copying a file that does not exist. This commit change the default of strip depending on `optimize`.
closes: #13405
Due to the change in default behavior of ReleaseSmall (#13067), debug info (pdb here) are stripped by default. However because
Compile.createdefaults to null,producesPdbFilewill report true forlib/std/Build/Step/InstallArtifact.zigzig/lib/std/Build/Step/InstallArtifact.zig
Line 33 in 378264d
Because of this, this only affects
zig buildand notzig build-exe. After this change, a simple program compiled withReleaseSmallwill successfully compile and won't try to copy/produce the pdb file.Of course, this still allows the user to choose not to strip the build and will produce a pdb file.