-
Notifications
You must be signed in to change notification settings - Fork 51
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
Distributable Binaries For Macos #185
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fully static executables are not supported on macos, and it is required to link dynamically against core system libraries (e.g. libSystem). we therefore produce here binaries for macos that have all c deps linked statically with the exception of: - libcxx - libiconv - libsystem we can be confident that these will always be provided at runtime by macos itself. convincing cabal / ghc to produce such a binary was pretty obscure, and we rely on some (afaict) undocumented behaviour where passing a library directory to cabal via `--extra-library-dirs` that contains only static libs (i.e. *.a files) and no dynamic libs (i.e. *.dylib files) results in static linkage, while passing a lib dir that contains both results in dynamic linkage.
msooseth
approved these changes
Feb 7, 2023
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.
LGTM
2 tasks
goodness 😭 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR lets us build binaries for macos that only link dynamically against libs that we can be sure will be provided by macos itself. All other non system c dependencies (secp256k1, libff, gmp, ...) are linked statically. This is required since full static linking is not supported on macos.
Cabal doesn't seem to offer friendly config options that would make the production of this kind of binary easy, and in the end we are relying on some behaviour that is at best poorly documented (and quite possibly implicit / unintended):
We can therefore get the behaviour we want by ensuring that we pass only static versions of the libs that we wish to be statically linked. Once this is done, we can do a final piece of denixification to rewrite the library paths for the remaining dynamic libs to point to
/usr/lib/
instead of the nix store, giving us "static" binaries that can run without requiring the installation of additional libraries on any x86 macos system.I tested the updated release pipeline on a fork: https://github.com/d-xo/hevm/actions/runs/4049153909 which produced binaries that can be tested here: https://github.com/d-xo/hevm/releases/tag/release%2F0.50.3.
output of
otool -L
on the resulting macos binary:Checklist