Skip to content

Commit 9dd761a

Browse files
authored
Build fully static compiler binary using ghc-musl (purescript#4573)
* Build statically-linked binaries with ghc-musl * Compliance for LGPL terms * Add changelog entry * Update dependencies * Update LICENSE * Update weeder * Fix weeder * Add more changelog entries * Argument passthrough * Update license * Update license * Build images for ARM * Checkout after Node installation * Only mount volumes for static * Drop static prefix for now * Force purge cache * Remove builds against ubuntu * Use matrix.os for cache key * Fix linux only * Set CI_STATIC to true * CI_STATIC on Linux only * Fix more linux only checks
1 parent 2b7164f commit 9dd761a

11 files changed

Lines changed: 1027 additions & 322 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,38 +54,52 @@ jobs:
5454
fail-fast: false # do not cancel builds for other OSes if one fails
5555
matrix:
5656
include:
57-
- image: haskell:9.8.4 # Also upgrade version in the lint job below
58-
os: ubuntu-latest # Exact version is not important, as it's only the container host)
57+
- image: quay.io/benz0li/ghc-musl:9.8.4
58+
os: ubuntu-latest
5959

60-
- image: haskell:9.8.4
61-
os: ubuntu-24.04-arm # Exact version is not important, as it's only the container host
60+
- image: quay.io/benz0li/ghc-musl:9.8.4
61+
os: ubuntu-24.04-arm
6262

6363
- os: macos-13 # x64
6464
- os: macos-14 # arm64
6565
- os: windows-2022 # x64
6666

6767
runs-on: "${{ matrix.os }}"
68-
container: "${{ matrix.image }}"
68+
container:
69+
image: "${{ matrix.image }}"
70+
# https://github.com/actions/runner/issues/801#issuecomment-2976165281
71+
# This workaround also requires a special installation step for Node.js on arm64
72+
volumes:
73+
- "${{ contains(matrix.os, 'arm') && '/opt:/opt:rw,rshared' || ' ' }}"
74+
- "${{ contains(matrix.os, 'arm') && '/opt:/__e/node20:ro,rshared' || ' ' }}"
75+
env:
76+
CI_STATIC: "${{ startsWith(matrix.os, 'ubuntu') }}"
6977

7078
outputs:
7179
do-not-prerelease: "${{ steps.build.outputs.do-not-prerelease }}"
7280
version: "${{ steps.build.outputs.version }}"
7381

7482
steps:
75-
- # We need `gh` installed on the Linux version. Otherwise, release artifacts won't be uploaded.
76-
name: "(Linux only) Install gh"
77-
if: startsWith(matrix.image, 'haskell')
83+
# We need `gh` installed on the Linux version. Otherwise, release artifacts won't be uploaded.
84+
- name: "(Linux only) Install gh"
85+
if: "${{ startsWith(matrix.os, 'ubuntu') }}"
7886
run: |
79-
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
80-
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
81-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
82-
apt-get update
83-
apt-get install -y gh
87+
apk add github-cli
88+
89+
- name: "(Linux only / x64) Install Node"
90+
if: "${{ startsWith(matrix.os, 'ubuntu') && ! contains(matrix.os, 'arm') }}"
91+
run: |
92+
apk add nodejs npm
93+
94+
- name: "(Linux only / arm64) Install Node"
95+
if: "${{ startsWith(matrix.os, 'ubuntu') && contains(matrix.os, 'arm') }}"
96+
run: |
97+
sed -i "/^ID=/s/alpine/NotpineForGHA/" /etc/os-release
98+
apk add nodejs npm --update-cache
99+
mkdir /opt/bin
100+
ln -s /usr/bin/node /opt/bin/node
84101
85102
- uses: "actions/checkout@v4"
86-
- uses: "actions/setup-node@v4"
87-
with:
88-
node-version: "22"
89103

90104
- id: "haskell"
91105
name: "(Non-Linux only) Install Haskell"
@@ -98,7 +112,7 @@ jobs:
98112
stack-no-global: true
99113

100114
- name: "(Linux only) Fix working directory ownership"
101-
if: startsWith(matrix.image, 'haskell')
115+
if: "${{ startsWith(matrix.os, 'ubuntu') }}"
102116
run: |
103117
chown root:root .
104118
@@ -107,7 +121,7 @@ jobs:
107121
path: |
108122
/root/.stack
109123
${{ steps.haskell.outputs.stack-root }}
110-
key: "${{ matrix.image || runner.os }}--MdyPsf-${{ hashFiles('stack.yaml.lock', 'purescript.cabal') }}"
124+
key: "${{ matrix.image || matrix.os }}-v3-${{ hashFiles('stack.yaml.lock', 'purescript.cabal') }}"
111125

112126
- name: "(Windows only) Configure Stack to store its programs in STACK_ROOT"
113127
# This ensures that the local GHC and MSYS binaries that Stack installs
@@ -118,20 +132,26 @@ jobs:
118132
mkdir -p "$STACK_ROOT"
119133
echo "local-programs-path: $STACK_ROOT/programs" > $STACK_ROOT/config.yaml
120134
135+
- name: "(Linux only) Configure Stack"
136+
if: "${{ startsWith(matrix.os, 'ubuntu') }}"
137+
run: |
138+
ci/fix-home stack config set system-ghc --global true
139+
ci/fix-home stack config set install-ghc --global false
140+
121141
- id: "build"
122142
run: "ci/fix-home ci/build.sh"
123143

124144
- name: "(Linux only) Glob tests"
125-
if: startsWith(matrix.image, 'haskell')
145+
if: "${{ startsWith(matrix.os, 'ubuntu') }}"
126146
working-directory: "sdist-test"
127147
# We build in this directory in build.sh, so this is where we need to
128148
# launch `stack exec`. The actual glob checks happen in a temporary directory.
129149
run: |
130-
apt-get install -y tree
150+
apk add tree
131151
../ci/fix-home stack exec bash ../glob-test.sh
132152
133153
- name: "(Linux only) Build the entire package set"
134-
if: startsWith(matrix.image, 'haskell')
154+
if: "${{ startsWith(matrix.os, 'ubuntu') }}"
135155
# We build in this directory in build.sh, so this is where we need to
136156
# launch `stack exec`. The actual package-set building happens in a
137157
# temporary directory.
@@ -144,11 +164,11 @@ jobs:
144164
# Moreover, npm has a hook issue that will cause spago to fail to install
145165
# We upgrade npm to fix this
146166
run: |
147-
apt-get install -y jq
167+
apk add jq
148168
../ci/fix-home stack --haddock exec ../ci/build-package-set.sh
149169
150170
- name: Verify that 'libtinfo' isn't in binary
151-
if: runner.os == 'Linux'
171+
if: ${{ runner.os == 'Linux' }}
152172
working-directory: "sdist-test"
153173
run: |
154174
if [ $(ldd $(../ci/fix-home stack path --local-doc-root)/../bin/purs | grep 'libtinfo' | wc -l) -ge 1 ]; then
@@ -157,6 +177,11 @@ jobs:
157177
exit 1
158178
fi
159179
180+
- name: "(Linux only) Install perl-utils"
181+
if: "${{ startsWith(matrix.os, 'ubuntu') }}"
182+
run: |
183+
apk add perl-utils
184+
160185
- name: "(Release/prerelease only) Create bundle"
161186
if: "${{ env.CI_RELEASE == 'true' || env.CI_PRERELEASE == 'true' && steps.build.outputs.do-not-prerelease != 'true' }}"
162187
run: |
@@ -225,13 +250,13 @@ jobs:
225250
- name: Install weeder
226251
run: |
227252
ci/fix-home stack --no-terminal --jobs=2 \
228-
build --copy-compiler-tool weeder-2.8.0
253+
build --copy-compiler-tool weeder-2.9.0
229254
230255
- run: |
231256
ci/fix-home stack --no-terminal --jobs=2 \
232257
build --fast --ghc-options -fwrite-ide-info
233258
234-
- run: "ci/fix-home stack exec weeder"
259+
- run: "ci/fix-home stack exec weeder -- --hie-directory .stack-work"
235260

236261
# Now do it again, with the test suite included. We don't want a
237262
# reference from our test suite to count in the above check; the fact
@@ -241,7 +266,7 @@ jobs:
241266
ci/fix-home stack --no-terminal --jobs=2 \
242267
build --fast --test --no-run-tests --ghc-options -fwrite-ide-info
243268
244-
- run: "ci/fix-home stack exec weeder"
269+
- run: "ci/fix-home stack exec weeder -- --hie-directory .stack-work"
245270

246271
make-prerelease:
247272
runs-on: ubuntu-latest
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Update weeder version in CI to 2.9.0
2+
* Add happy ==2.0.2 as build-tool-depends

CHANGELOG.d/misc_static_linking.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* Enable statically-linked binaries using [ghc-musl](https://github.com/benz0li/ghc-musl)
2+
* Update haskeline version bounds to >=0.8.2.1 && <0.9
3+
4+
Consequently, this fixes Cabal-based builds on GHC 9.8.4

0 commit comments

Comments
 (0)