-
Notifications
You must be signed in to change notification settings - Fork 841
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
Support musl-based Linux distributions like Alpine Linux #2387
Comments
For Alpine support, we need GHC bindists. I'm putting out a call to the community for help in creating those: can anyone out there provide GHC 8.0.1 bindists for x86_64 and x86 (32-bit) at a minimum? Would also be nice to have GHC 7.10.3 bindists, and bindists for the armhf platform, but that's less important. This looks like a good starting point: https://github.com/mitchty/alpine-linux-ghc-bootstrap |
Possibly relevant: musl bindists of ghc 8.2.1. I have not tried them; anyone available to do so? (ping @mitchty) |
They may work post 8.0.2, but the last time I tried gentoo musl produced bindists they included TEXT relocations in shared libraries which means you can't link anything you build with them. Alpine Linux has hardening on that will prevent such things from linking. If thats the case they probably won't work at all. Worth a shot to try. You could test with the alpine/latest docker image if you want. |
Managed to get some time last night to get Jenkins up and running and doing builds. While it takes forever and an age to build ghc on armhf (like an entire day), I can get bindists generated now. Still need to brain on how I want to do this going forward but in essence my strategy is: patch the APKBUILD in aports to also build bindists, then snag those bindists out of the build directory. For 32bit ghc however I still need to get the cross compile to work sanely and get a build vm setup that I can hook Jenkins up to test things. But I need to do that to validate things in alpine linux proper anyway. But in about a week or so I should have some strategy for bindists. How do/should they get generated/updated? My thoughts are follow the standard APKBUILD, for each release update the bindist and have say a -latest link to point to the latest bindist release for each specific major version. Keeping the last... N releases. Thoughts? |
I know nothing about how Alpine packages work, so I don't really have an opinion TBH. For the purposes of Stack, the only thing that matters is having a working working bindist for each released GHC version (it's OK if that's just starting with the latest GHC version, although having versions going back to 7.10.3 would be nice). |
Any progress @mitchty!? This'd be really cool to get done. |
Whoever ends up closing this, I think it also closes #2717. Just scanning through, but looks to be the case. |
Work is a bit hectic so this is a bit on the back burner. But what I have partially is the ability to generate apks similar to hvr's ppa putting things in /opt/ghc/$version. While that builds I hacked into the apkbuild process the ability to build bindists as well. This isn't too onerous with x86_64 but armhf takes forever and a day, actually 3 days to build stuff. it needs some cleanup but shouldn't be too hard to finish up. Once I can focus back on it a bit I'll finish it off. |
Heh, well I got it working, only to find a bug in the llvm3.7 package too. It needs to get recompiled for alpine linux 3.6. As it is you see this on make install:
That is all due to missing symbols in libc++ that the older llvm3.7 was linked against that alpine linux 3.6 doesn't have. I swear I am a magnet for finding unrelated bugs in things. |
Good news everyone! I was wrong in the last comment. I think I got it working. You as a user need to: Add the community apk repository to your alpine system (if necessary). Example here is for alpine linux 3.6.
Then try this out: It seems to work for me but i just did MINIMAL testing, aka compile hello world, ./configure --prefix=/tmp/ghc example:
I have 8.2.1 working as well but only for x86_64. It'll take a while to get that going but test away. |
I'd prefer we use APK as primary way to package GHC for alpine. @mitchty Some of your patches where merged upstream already. Can you publish your 8.2.1 apkbuild somewhere, I'd try to adapt it to 8.2.2 and publish my findings here. |
Its already been done, the issue is building on armhf segfaults in the stage2 builder. Thats the only reason there isn't an update for ghc in alpine linux right now, generally frowned on to remove a platform from the supported arches list. Debugging this is... trying as I need to negate out llvm, musl patches, ghc, the rts, etc... Apkbuild is here: |
Note, that has the binary distribution stuff in it as well, you might want to rip that out if you don't want to build the binary distribution tar.xz files. Essentially this is my jenkins branch that I use to test release candidates and to build the above binary distribution files. But for 8.2.2, I have 8.2.1 and 8.0.2 as well for x86_64, example: https://mitchty.net/ghc/8.2.2/ghc-8.2.2-x86_64-alpine-linux.tar.xz If anyone wants I can resurrect my apk signing keys and plop up the apks I build out of jenkins into that web server until I can fully debug the armhf segfault issue. |
@mitchty Would alpine accept your apk if its not supporting armhf? And thx for the pointer. I can temporarily unblock myself now. |
for now I'll build / package it by myself, but thanks for the offer. I think your time is better spend in getting the changes upstream ;) I do not want to reduce the chance of this happening soon. |
In case this detail is helpful.. As of right now, running the static linux executable for stack, in an alpine 3.7 container, GHC build blows up with errors about cabal:
|
@ketzacoatl Did you add setup-info configuration pointing to @mitchty's bindist for the I've not tried the bindist above on Alpine myself, so I'd be very interested in the results. |
I have added the following to my
and then I run into the LLVM bug mitchty noted in a previous comment, even with the updates he noted. For example, this build is run in a docker image that has the packages installed as noted in mitchty's instructions, but fails with:
|
I have also now uploaded a prerelease static musl build for |
I don't understand what that means. I'm talking about the alpine ghc packages, see https://pkgs.alpinelinux.org/packages?name=ghc&branch=edge
There is no custom compiler to install that works under alpine. GHC upstream doesn't provide one, stack doesn't and the distro only provides one arbitrary version, as already explained. |
@hasufell I know that there's currently no ghc available on Alpine, I was just referring to
which sounded like "if there were multiple compilers available, it would be difficult to switch them using |
I wasn't talking about the command |
@nh2 Of course there is ghc on Alpine: https://pkgs.alpinelinux.org/packages?name=ghc&branch=v3.8 I use it every day, but since stack cannot bootstrap on Alpine you have to use "system-ghc", which is the ghc version above. That's not like stack is meant to be used, so at the moment I rather use: cabal new-* |
@mitchty (or anyone else watching this thread), I'd like to build bindists for alpine, where do I get started? |
It looks like @redneb is building musl-based GHC bindists for recent GHC releases, and people seem to be able to install them on Alpine Linux using the standard Any interested Alpine user out there who can give this a try? You'd use the setup-info configuration to point edit: I see I linked to these a couple of years ago, but it doesn't look like anybody actually tried them (perhaps due to the following comment). |
Update: I decided to try this myself. I added the following to my
And then ran |
Note for whomever implements detection of musl-based distributions: this node package appears to have decent libc detection logic that we could use as inspiration: https://github.com/lovell/detect-libc/blob/master/lib/detect-libc.js |
This seems to have worked as well. However, there is a problem that's exposed when I try to use the bindist with the upcoming stack-2.1 which does some extra sanity checking (I had been using stack-1.9.3 before): it fails to install a
Opened an issue on ghc-alt-libc for this here: redneb/ghc-alt-libc#5 |
@redneb has very kindly, and quickly, uploaded new ghc 8.6.5 bindists that fix the haddock issue. I've tested them with stack-2.1 and they seem to work great (including Now what's left is adding logic to |
I have two remarks about this:
|
@redneb Is that filed somewhere? GHC should not segfault when using gold. |
No I have not filed any bug for that, but I am not sure if this an issue with ghc. I am not sure if |
@redneb I remember hearing/reading about some musl+gold problems, but I am quite sure that their respective authors want that these work well together. So even if there's a segfault in Is it perhaps https://sourceware.org/bugzilla/show_bug.cgi?id=23856 (which I filed from NixOS/nixpkgs#49071 (comment))? |
This sounds awfully a lot like the issue I was seeing: the binaries I get from (apologies to everyone for the off topic spam) |
I'm actually tempted to rename this issue to "Support musl-based Linux distributions" rather than Alpine Linux specifically, so it's not off topic in that case :) Until GHC release team is releasing battle-tested musl-based bindists officially, I don't think we can "officially" support Alpine Linux anyway in Stack, so I'm not sure that part of the issue title should be a hold up either. But decent experimental support for musl-based distributions would be a huge step forward (in particular, being able to use it with an Alpine-based docker image that works with Anyone have any objections to me renaming the issue to "Support musl-based Linux distributions like Alpine Linux"? |
@borsboom Doesn't seem so, let's do it. |
Hi, just wanted to confirm that this is still current exactly 4 years after ticket was initially opened. I am having the same issue attempting to use "stack" for building "postgrest" on alpine 3.12 with currently available ghc on alpine. |
alpine musl GHCs are already part of the official bindists: https://downloads.haskell.org/~ghc/8.10.1/ |
I am closing this issue given the passage of time and because Stack 2.15.3 does support Alpine Linux/x86_64 (tested via WSL). |
@dysinger has had success building Stack on Alpine using GHC 8.0.1 from here: https://github.com/mitchty/alpine-linux-ghc-bootstrap. Once there is a Stackage LTS release that uses GHC 8, we can consider adding official support for Alpine Linux.
The text was updated successfully, but these errors were encountered: