All Projects → utdemir → ghc-musl

utdemir / ghc-musl

Licence: other
Docker image with GHC+musl for static executables

Programming Languages

shell
77523 projects
Earthly
7 projects
Nix
1067 projects
haskell
3896 projects

Projects that are alternatives of or similar to ghc-musl

rsync-static
Static RSync binaries compiled for x86, ARM, and ARM64. Useful for running on Android. Built daily
Stars: ✭ 40 (-69.92%)
Mutual labels:  musl
Talos
Talos is a modern OS for Kubernetes.
Stars: ✭ 2,390 (+1696.99%)
Mutual labels:  musl
voidnsrun
Run glibc binaries in musl libc Void Linux environment
Stars: ✭ 31 (-76.69%)
Mutual labels:  musl
Microdot
The Microdot Project guides you to create a fully functional but compact Linux system from scratch
Stars: ✭ 41 (-69.17%)
Mutual labels:  musl
sabotage
a radical and experimental distribution based on musl libc and busybox
Stars: ✭ 502 (+277.44%)
Mutual labels:  musl
detect-libc
Node.js module to detect details of the C standard library (libc) implementation provided by a given Linux system
Stars: ✭ 33 (-75.19%)
Mutual labels:  musl
crosware
Tools, things, stuff, miscellaneous, etc., for Chrome OS / Chromium OS
Stars: ✭ 36 (-72.93%)
Mutual labels:  musl
docker-rustup
Automated builded images for rust-lang with rustup, "the ultimate way to install RUST"
Stars: ✭ 78 (-41.35%)
Mutual labels:  musl
CMLFS
Clang-Built Musl Linux From Scratch
Stars: ✭ 51 (-61.65%)
Mutual labels:  musl
musl-wiki
A community-maintained wiki documenting the musl libc.
Stars: ✭ 61 (-54.14%)
Mutual labels:  musl
merelinux
A lightweight Linux distribution using musl libc, pacman and s6
Stars: ✭ 68 (-48.87%)
Mutual labels:  musl
ghc-alt-libc
GHC compiled against musl & uClibc
Stars: ✭ 41 (-69.17%)
Mutual labels:  musl
stasis
build static rust position-independant-executables without any runtime requirements (no libc or ldso)
Stars: ✭ 40 (-69.92%)
Mutual labels:  musl
khadas-openwrt
openwrt for Khadas boards
Stars: ✭ 25 (-81.2%)
Mutual labels:  musl
profiler-api
The portable version of JetBrains profiler API for .NET Framework / .NET Core / .NET / .NET Standard / Mono
Stars: ✭ 21 (-84.21%)
Mutual labels:  musl
natick
natickOS - A minimal, lightweight, research Linux Distribution
Stars: ✭ 33 (-75.19%)
Mutual labels:  musl

ghc-musl

This repository provides Docker images with GHC compiled with musl; therefore can be used to create fully static Haskell binaries without glibc dependency on any platform which can run Docker (x86_64). Powered by ghcup.

Images come with ghc and cabal executables alongside with commonly used libraries and build tools. They can also be used with the stack build tool using its Docker integration.

Here are the latest images currently published in Docker Hub:

  • utdemir/ghc-musl:v25-ghc944
  • utdemir/ghc-musl:v25-ghc925
  • utdemir/ghc-musl:v25-ghc902
  • utdemir/ghc-musl:v25-ghc8107
  • utdemir/ghc-musl:v25-ghc884

Usage

cabal-install

Mount the project directory to the container, and use cabal-install with --enable-executable-static flag inside the container:

$ cd myproject/
$ docker run -itv $PWD:/mnt utdemir/ghc-musl:v25-ghc944
sh$ cd /mnt
sh$ cabal new-update
sh$ cabal new-build --enable-executable-static

You can also set executable-static option on your cabal.project file.

stack

Use below arguments, or set the relevant options on your stack.yaml:

stack build \
  --ghc-options ' -static -optl-static -optl-pthread -fPIC' \
  --docker --docker-image "utdemir/ghc-musl:v25-ghc944" \
  --no-nix

Make sure to pick an image with the GHC version compatible with the Stackage resolver you are using.

Follow commercialhaskell/stack#3420 for more details on static compilation using the Stack build tool.

Example session with GHC

Below shell session shows how to start a pre-compiled docker container and compile a simple Hello.hs as a static executable:

$ docker run -itv $PWD:/mnt utdemir/ghc-musl:v25-ghc944
bash-4.4# cd /mnt/
bash-4.4# cat Hello.hs
main = putStrLn "Hello"
bash-4.4# ghc --make -optl-static -optl-pthread Hello.hs
[1 of 1] Compiling Main             ( Hello.hs, Hello.o )
Linking Hello ...
bash-4.4# ls -al Hello
-rwxr-xr-x 1 root root 1185056 Aug 11 16:55 Hello
bash-4.4# file Hello
Hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped
bash-4.4# ldd ./Hello
ldd: ./Hello: Not a valid dynamic program

The result can be executed on different Linux systems:

$ docker run -itv $PWD:/mnt alpine
# /mnt/Hello
Hello
$ docker run -itv $PWD:/mnt centos
[root@94eb29dcdfe6 /]# /mnt/Hello
Hello

Development

Feel free to open an issue or send a PR to add a library or support a newer compiler version.

The build process is orchestrated using Earthly. Once it is installed (or obtained via "nix-shell -p earthly"), you can use below command to build and test all images:

earthly --allow-privileged +all

Note: --allow-privileged is only necessary because we use Docker-in-Docker project to test if the generated images work with stack's Docker support. You can use the following command to disable Stack tests so that --allow-privileged is not necessary:

earthly --build-arg TEST_STACK=0 +all

The following command updates README.md:

earthly --artifact +readme/README.md

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].