Uh oh!
There was an error while loading. Please reload this page.
add zig build support for -static - #8248
Conversation
data-man
commented
Mar 14, 2021
...exe.is_static=true;
exe.is_dynamic=true;
...What will happen here? |
elerch
commented
Mar 14, 2021
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 |
tauoverpi
commented
Mar 14, 2021
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 |
elerch
commented
Mar 14, 2021
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... |
elerch
commented
Mar 15, 2021
I created #8258 to disallow |
There was a problem hiding this comment.
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.
elerch
commented
Jun 11, 2021
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 |
Vexu
commented
Jun 11, 2021
It turns that #7959 already mostly implemented having linkage as an enum making this pr unnecessary. |
elerch
commented
Jun 11, 2021
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
-staticto thezig build-execommand. Usage example: