Skip to content
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

std.zig: handle -frandom-seed in NIX_CFLAGS_COMPILE #8667

Merged
merged 2 commits into from
May 19, 2021

Conversation

sagehane
Copy link
Contributor

@sagehane sagehane commented May 1, 2021

Closes #8269 by ignoring the value of the -frandom-seed flag.

It would be nice to have it addressed before the upcoming NixOS release (21.05).

@LemonBoy
Copy link
Contributor

LemonBoy commented May 1, 2021

I think a better and more future-proof solution would be to make the unrecognized flag error a non-fatal one.

@sagehane
Copy link
Contributor Author

sagehane commented May 2, 2021

I guess simply removing the break from the unrecognized flag case would work. This makes sure the compiler keeps going after coming across an unrecognized flag, as opposed to just aborting.

diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig
index 42099c6ef..85b5da38e 100644
--- a/lib/std/zig/system.zig
+++ b/lib/std/zig/system.zig
@@ -54,7 +54,6 @@ pub const NativePaths = struct {
                     try self.addIncludeDir(include_path);
                 } else {
                     try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word});
-                    break;
                 }
             }
         } else |err| switch (err) {

However, that would cause it to always leave a message like this:

$ ../zig/build/bin/zig build
warning: Unrecognized C flag from NIX_CFLAGS_COMPILE: -frandom-seed=yymb0qgbfh

I'm fine with this as long as getting that warn message every time isn't deemed too annoying. Or, both methods can be applied so -frandom-seed is properly dealt with, and any new C flag NixOS introduces won't be fatal.

@andrewrk andrewrk merged commit 22f51f2 into ziglang:master May 19, 2021
@andrewrk
Copy link
Member

Thanks @sagehane!

@sagehane sagehane deleted the nixos branch May 19, 2021 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zig fails to get the include paths on NixOS Unstable
3 participants