-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Build: Fix bug causing ReleaseSmall to fail on Windows #15756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 stripped Windows 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.
lib/std/Build/Step/Compile.zig
Outdated
@@ -433,7 +433,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.create
defaults to null,producesPdbFile
will report true forlib/std/Build/Step/InstallArtifact.zig
zig/lib/std/Build/Step/InstallArtifact.zig
Line 33 in 378264d
Because of this, this only affects
zig build
and notzig build-exe
. After this change, a simple program compiled withReleaseSmall
will 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.