Subject: [alpine-devel] Questions regarding a ghc port to alpine linux

From: Mitch Tishmack <[email-masked]>
Date: Wed, 17 Jun 2015 23:41:33 -0500

Hi,

Recently a reddit haskell user cross compiled ghc in gentoo linux using musl libc, which convinced me to get a port of ghc functional for alpine linux. I did a quick query on irc and was directed to this mailing list to ask my questions and get a better review on the process.

My preliminary port is here under bootstrap and alpine directories.
https://github.com/mitchty/alpine-linux-ghc-bootstrap

Note, ghc itself needs to self host to build its own source. So this is a little more difficult to do than it normally might need be. The bootstrap directory contains the docker file used to generate the ghc cross compiler for use with the alpine docker image to generate a native compiler from within alpine linux.

The alpine directory right now only contains a docker file that can get you to generating an apk that one could use to build another apk that depends on ghc itself. Note, ghc requires itself to build itself from source. So I’m not entirely sure how one submits an APKBUILD in this circumstance, the wiki is mostly focused on non self hosting binaries.

This produces a functional, for some definition of the term, ghc compiler though I will admit I’m not 100% satisfied with how it is currently built. But it seems to function for the moment and could use more testing outside of my own use and abuse as well as use a bit better review of how I went about it to fix any glaring or obvious errors in approach.

Just to address a few things quick from a quick initial review from irc:
- I’m not a huge fan of disabling position independent code to build ghc, but I cannot get ghc to build reliably without it on alpine linux. It builds fine on non hardened gentoo linux which leads me to think its some side effect of PaX or grsecurity. I can build *really* simple programs without disabling PIE code by disabling pax via paxctl -cm /path/to/ghc/binary. But that apparently is the wrong tool to use so input here is appreciated. A note, if one does not force code compiled to have -nopie, the following happens: https://gist.github.com/mitchty/29125de21ade1a04364f 
- I used docker for this port mostly due to wanting to try it out and it was nice not to have to wait 3 hours for ghc to compile its first stages with caching, I’m not wedded to the tool its more a convenience really since compile times for things can be rather long even on a fast system.
- I’ve talked a bit with the ghc developers regarding the -nopie component and either this is something new that ghc itself needs to detect in how linking on musl libc works, or I’m compiling this wrong in some fashion, or my understanding of how alpine is hardened is wrong. My knowledge of the grsecurity patches and PaX in general is low so I’m fully willing to accept that I did this preliminary port wrong or don’t understand huge portions of how alpine linux is built. I’ve mostly been a user really.

Any help or guidance on what I messed up or did wrong would be helpful. I’m just looking to get a working port of ghc onto alpine linux so input appreciated.

Apologies for the giant wall of text as well, thank you all for your time!

cheers,
mitch

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---