File tree Expand file tree Collapse file tree 4 files changed +22
-2
lines changed
Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2222 prevent garbling unicode characters.
2323 [ #108 ] ( https://github.com/greglook/cljstyle/issues/108 )
2424 [ #110 ] ( https://github.com/greglook/cljstyle/issues/110 )
25+ - Fix static builds by switching to musl.
2526
2627
2728## [ 0.16.626] - 2024-01-06
Original file line number Diff line number Diff line change @@ -30,8 +30,11 @@ RUN clojure -T:build fetch-deps
3030COPY . .
3131RUN ./bin/build graal-uberjar
3232
33- # Build native-image
33+ # Setup musl compiler if building a static binary
3434ARG GRAAL_STATIC="false"
35+ RUN if [ "$GRAAL_STATIC" = true ]; then ./bin/build setup-musl; fi
36+
37+ # Build native-image
3538RUN ./bin/build native-image :graal-static $GRAAL_STATIC
3639
3740# Install tool
Original file line number Diff line number Diff line change @@ -12,6 +12,19 @@ elif [[ $1 = hiera ]]; then
1212 shift
1313 exec clojure -X:hiera " $@ "
1414
15+ elif [[ $1 = setup-musl ]]; then
16+ # This should only really run in the context of the Docker image builder for static binaries
17+ apt install -y musl-tools
18+ ZLIB_VERSION=" 1.2.13"
19+ curl -sLO --fail --show-error " https://zlib.net/fossils/zlib-${ZLIB_VERSION} .tar.gz"
20+ tar xf " zlib-${ZLIB_VERSION} .tar.gz"
21+ cd " zlib-${ZLIB_VERSION} "
22+ CC=musl-gcc ./configure --static --prefix=/usr/local
23+ make CC=musl-gcc
24+ make install
25+ cd ..
26+ install -Dm644 /usr/local/lib/libz.a /usr/lib/x86_64-linux-musl/libz.a
27+
1528elif [[ $1 = native-image ]]; then
1629 shift
1730 GRAAL_ROOT=" ${GRAAL_ROOT:- $HOME / .local/ share/ graalvm} "
Original file line number Diff line number Diff line change 370370 " --verbose" ])
371371 ; ; Static build flag
372372 (when (:graal-static opts)
373- " --static" )]
373+ [" --libc=musl"
374+ ; ; see https://github.com/oracle/graal/issues/3398
375+ " -H:CCompilerOption=-Wl,-z,stack-size=2097152"
376+ " --static" ])]
374377 result (b/process {:command-args (remove nil? (flatten args))})]
375378 (when-not (zero? (:exit result))
376379 (binding [*out* *err*]
You can’t perform that action at this time.
0 commit comments