-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
add zig build support for -static #8248
Conversation
...
exe.is_static = true;
exe.is_dynamic = true;
... What will happen here? |
Good question. I tried setting
Since the code sets I'm open to whatever behavior we think is correct here, but I thought to open the conversation, getting the flag at least accessible would be preferred. I had considered making is_dynamic optional, so setting to false would indicate static, null would be normal behavior, or true would be dynamic linking, but is_dynamic is used in a few other places and given the |
If both are true it should just throw an error and request the user removes one of them.
In this case it would be better to just have an enum |
I think this is the crux of the question. Alternatively, there could be a check in build.zig, but then there's (admittedly minimal) duplicated logic... |
I created #8258 to disallow |
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.
As noted by others, this flag works more like an enum than bools so build.zig
should be changed to have linkage: ?enum { static, dynamic } = null
instead. Let me know if you are interested in implementing this chage.
Also sorry for taking so long with reviewing this, I'm trying to put more effort into keeping the review queue more manageable.
ok - new changes @Vexu. I rebased to 0.8.0 and removed is_dynamic/is_static in favor of link_mode, which seemed more consistent. I was also able to leverage the existing std.builtin.LinkMode. The change is more involved and is now a breaking |
It turns that #7959 already mostly implemented having linkage as an enum making this pr unnecessary. |
I see the changes in #7959 - I agree they look like they'll solve this issue too. Definitely not discouraged - happy to help, even if it turns out only to further the discussion along. |
This allows forcing exe output to be statically linked, similar to the pre-existing is_dynamic flag. Setting the flag will pass
-static
to thezig build-exe
command. Usage example: