-
Notifications
You must be signed in to change notification settings - Fork 81
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 support for building fully-static binaries #1390
Conversation
bdc33b3
to
ac55697
Compare
ac55697
to
e035482
Compare
@aherrmann I've pulled out the If you think this looks sensible, some ideas I have:
|
Yea looks like we might need some guards for Windows at least -- the Azure failures seem to be linker errors, which I assume are genuine and caused by |
Right, IIUC the only difference between static RTS and fully static is whether
Yes, not opposed to that. If possible it's better to create a dedicated test-case in
Absolutely, a use-case section in |
To elaborate on your comment, as I understand it -- passing As to how we trigger this:
Just my 2c though -- generally happy to do whatever as long as it works and is documented 👍 |
Yes, that's what I meant.
That's a good point! Okay, let's go with a dedicated attribute. AFAIK the only other user of the Regarding the fully static mode, looking for precedent in Bazel there is the |
I was going to suggest That said, I do think it is morally the right choice, and if we're not against changing (or at least initially deprecating) |
It's a recognized value for the
That's good to know. It looks like building fully statically linked
That sounds good. Such a deprecation can be implemented at the nixpkgs toolchain wrapper macro
Yes, though I think it's best if the user has to explicitly write
and we raise an error in case of |
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 did a review pass on the changes so far.
Again, thanks a lot for working on this!
c1a1651
to
c3d1fce
Compare
I've made all the changes you suggested -- great to see this patch getting smaller and smaller! I'll take up test cases and documentation when I next have time and then the only question I see left is deprecating
There's also the question of combinations of More feedback welcome as always; cheers. |
Thank you!
In the past we've usually gone with 3, it sounds reasonably straight-forward to implement in
I'd say,
I don't think we have checks for any such "bad" combinations, yet. TBH I don't know if |
787bcc4
to
c26dc3f
Compare
@aherrmann I implemented the compatibility checking/deprecation here: https://github.com/tweag/rules_haskell/pull/1390/files#diff-63173affa8c52d7a87df960435e8c641R275; see what you think. I've also pushed a chunk of documentation which hopefully looks OK and will see what the Windows tests say now that (hopefully) everything is gated by appropriate conditionals. |
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.
Excellent, this looks great! Thank you for the use-case documentation!
I have only two small comments.
I also ran the remaining CI pipelines on this. It's all good except for the formatting check. You can fix these warnings automatically with bazel run //:buildifier-fix
.
c26dc3f
to
c2ebd8b
Compare
Added the missing arguments documentation and hopefully have appeased Buildifier; 🤞 we get a green CI this time! |
47f0e37
to
37e9145
Compare
This commit implements support for fully-statically-linked binaries by extending functionality linked to the `is_static` attribute of an active Haskell toolchain. In particular: * Packages built with Cabal will be passed fields that ensure their static artifacts are relocatable (`-fPIC` and `-fexternal-dynamic-refs`). * Intermediate artifacts (such as binaries built by `hsc2hs` for the purposes of generating Haskell code) will also be built statically to avoid issues caused by the absences of dynamic libraries. * Linker flags for REPLs will be generated so that they correctly find static C library dependencies instead of failing/finding dynamic counterparts.
37e9145
to
b48b7eb
Compare
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.
Looks great and CI is all green!
Thank you @lunaris for implementing this feature!
Off the back of much discussion in #379.
This commit implements support for fully-statically-linked binaries by
extending functionality linked to the
is_static
attribute of an activeHaskell toolchain. In particular:
Packages built with Cabal will be passed fields that ensure their
static artifacts are relocatable (
-fPIC
and-fexternal-dynamic-refs
).Intermediate artifacts (such as binaries built by
hsc2hs
for thepurposes of generating Haskell code) will also be built statically to
avoid issues caused by the absences of dynamic libraries.
Linker flags for REPLs will be generated so that they correctly find
static C library dependencies instead of failing/finding dynamic
counterparts.