Add --enable-executable-static flag for fully static linking#5446
Add --enable-executable-static flag for fully static linking#544623Skidoo merged 2 commits intohaskell:masterfrom
--enable-executable-static flag for fully static linking#5446Conversation
|
Note this could also be done slightly differently, making the As per
That means it might be sensible in some use cases to pass If we want to support that case, then maybe we don't want to call this feature But that those aren't necessarily exclusive; Cabal may want to offer a high-level flag called Just some ideas in my head, what do you think? |
|
|
||
| -- Some sanity checks related to dynamic/static linking. | ||
| when (fromFlag (configDynExe cfg) && fromFlag (configFullyStaticExe cfg)) $ | ||
| die' verbosity $ "--enable-executable-dynamic and --enable-executable-dynamic" ++ |
There was a problem hiding this comment.
- Typo, one of them should be
-static
da2d4a0 to
3ad4098
Compare
--enable-executable-static flag for fully static executables--enable-executable-static flag for fully static linking
|
CI should agree though. |
befa738 to
e892df7
Compare
Who can tell me? |
e892df7 to
67ef73f
Compare
|
I have added the corresponding |
| , packageConfigHaddockForHackage = x41' } | ||
| | (((x00', x01', x02', x03', x04'), | ||
| (x05', x42', x06', x07', x08', x09'), | ||
| (x05', x42', x06', x44', x07', x08', x09'), |
There was a problem hiding this comment.
What on earth was the author of the surrounding lines thinking?
The above arbitrary <*> arbitrary <*> arbitrary on 46 positional arguments is already contributor unfriendly but this one really sets a new bar.
|
Some How can I run them locally? The travis output on https://travis-ci.org/haskell/cabal/jobs/406458613 is close to useless. The raw output at https://api.travis-ci.org/v3/job/406458613/log.txt has lots of garbled characters like |
|
GHCJS doesn't have alternate linking, so it really shouldn't matter. |
|
I think this is the 4th time it complains about I've filed #5625 for it. |
|
@nh2 I would recommend ignoring this by default on macOS. While its theoretically possible to build completely static macOS binaries, Apple doesn't provide anything like the stable ABI that Linux has. You can of course build all of your libraries statically but no matter what you will need to link against |
@matthewbauer Would there be a benefit of Cabal ignoring the flag though, vs just having users not use it on OSX? Accepting the flag and then going not doing anything goes against the principle of least surprise, I'd rather have it fail (and put into the docs that it isn't known to work on OSX), or fail loudly that it doesn't work on OSX (and why). |
and another time:
@23Skidoo I am unsure right now whether #5625 (comment) means that this PR will actually merge cleanly if not done via GitHub, or not. |
I'd advocate for uniform behaviour: let the option work on all OSes, but add an explanatory warning on Mac. In other words: discourage over completely preventing. |
|
@nh2 I tried rebasing, and it didn't require manual intervention, but put the changelog note into the 2.4.0.0 section, so it had to be fixed manually. |
e396797 to
1429bdb
Compare
|
Is there anything that an interested passerby like myself could do to help get this merged? Statically linked Haskell executables are something I'm very much interested, so I'd like to help unblock anything if it's at all within my capability 😄 |
|
@23Skidoo: What's holding this up from being merged? |
Also update the docs for `--enable-executable-dynamic` as they were slightly misleading.
1429bdb to
2bff6ce
Compare
|
@nh2 wanted to add some tests for this. I think I'll merge this anyway rn, but a subsequent PR with tests would be appreciated! |
|
Merged, thanks! |
|
Regarding tests, I'm still kinda blocked on
How would you want something like this to happen? Feature detection, and skipping these tests when musl isn't available? |
|
Yeah, that'd be fine. Can we install musl on Travis? |
|
(I haven't done anything with Travis besides copy-paste-ing configuration files, but...) googling "travis musl": it sounds like there's no official support, but one can still just install a virtual machine with alpine linux (or some other environment with i just set up Alpine Linux under Virtualbox on Ubuntu LTS 16.04 (afaik, that's the OS which Travis CI runs stuff on by default). @nh2 do we need install to the cabal toolchain on it? or just check that any statically linked executables built by |
|
@sboosali Hmm, I think you will need a full musl toolchain all the way up to ghc for it to work. I would be surprised if running a VM on Travis's Ubuntu works well (their environments are already quite slow, and if they don't have nested virtualisation, it might be unbearably slow). Another alternative might be to link statically with glibc, and pick a very trivial hello-world program that is unlikely to trigger any code paths that are problematic when linking glibc statically. |
Fixes #391.
Also update the docs for
--enable-executable-dynamicas they were slightly misleading.
Please include the following checklist in your PR:
[ci skip]is used to avoid triggering the build bots.Please also shortly describe how you tested your change. Bonus points for added tests!
stack) withmuslvia nix using this new flagMy TODO list I kept when writing this code:
withFullyStaticExeinCabal/Distribution/Simple/GHCJS.hsis necessary (consider ocurrences ofwithDynExe)withFullyStaticExeandwithDynExeinLocalBuildInfoare mutually exclusive?configFullyStaticExeandconfigDynExeinConfigFlagsare mutually exclusive?muslto test it?Inputs appreciated for the above.