Use musl builder for Docker static Qt
ober
33960654224a485cfc2c1e9b4f5ce92ff3e40dd9
--- a/Dockerfile.qt +++ b/Dockerfile.qt @@ -13,6 +13,8 @@ ARG JERBOA_IMAGE=jerboa21/jerboa +FROM ${JERBOA_IMAGE} AS jerboa-runtime + # ── Stage 1: Build Qt6 + QScintilla + tree-sitter + libvterm on Alpine ─────── FROM alpine:3.21 AS qt-alpine @@ -265,42 +267,21 @@ RUN mkdir -p /tmp/qt-shim-out && \ echo "libqt_shim.a built successfully" && \ ls -lh /tmp/qt-shim-out/ -# ── Stage 2: jerboa21/jerboa + Qt artifacts → build jemacs-qt ──────────────── -FROM ${JERBOA_IMAGE} AS builder - -# Install Ubuntu build deps needed for jemacs-qt compilation -RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc-14 \ - g++-14 \ - g++ \ - libncurses-dev \ - libpcre2-dev \ - uuid-dev \ - libssl-dev \ - pkg-config \ - && rm -rf /var/lib/apt/lists/* - -RUN ln -sf /usr/bin/gcc-14 /usr/local/bin/gcc && \ - ln -sf /usr/bin/g++-14 /usr/local/bin/g++ - -# Copy Qt6 static libs and tools from Alpine stage -COPY --from=qt-alpine /opt/qt6-static /opt/qt6-static -COPY --from=qt-alpine /opt/qt-static-deps/lib/ /usr/local/lib/ +# ── Stage 2: Alpine/musl builder + Chez from jerboa21/jerboa ───────────────── +FROM qt-shim-alpine AS builder -# Copy tree-sitter from Alpine stage -COPY --from=qt-alpine /opt/tree-sitter-lib /opt/tree-sitter-lib -COPY --from=qt-alpine /opt/tree-sitter-include /opt/tree-sitter-include -COPY --from=qt-alpine /opt/tree-sitter-grammars /opt/tree-sitter-grammars +COPY --from=jerboa-runtime /build/chez-musl /opt/chez -# Copy Alpine-compiled libvterm.a (Ubuntu doesn't ship a static version) -COPY --from=qt-alpine /usr/lib/libvterm.a /usr/local/lib/ -COPY --from=qt-alpine /usr/include/vterm.h /usr/local/include/ - -# Copy pre-compiled Qt shim (Alpine-musl g++, so ABI-compatible with musl final link) -COPY --from=qt-shim-alpine /tmp/qt-shim-out/ /opt/qt-shim/ - -# Create /opt/chez compatibility symlink to the working Chez in jerboa21/jerboa -RUN ln -s /usr/local /opt/chez +RUN mkdir -p /opt/qt-shim && \ + cp -a /tmp/qt-shim-out/. /opt/qt-shim/ && \ + cp -L /opt/qt-static-deps/lib/*.a /usr/local/lib/ && \ + chez_dir="$(ls -d /opt/chez/lib/csv*/ta6le | head -1)" && \ + printf '%s\n' \ + '#!/bin/sh' \ + "exec \"$chez_dir/scheme\" --boot \"$chez_dir/petite.boot\" --boot \"$chez_dir/scheme.boot\" \"\$@\"" \ + > /opt/chez/bin/scheme-wrapper && \ + chmod +x /opt/chez/bin/scheme-wrapper && \ + /opt/chez/bin/scheme-wrapper --version # Copy source and run the in-container build COPY . /src @@ -308,7 +289,7 @@ WORKDIR /src ARG JEMACS_FEATURES="" ENV JEMACS_FEATURES=${JEMACS_FEATURES} -RUN make linux-qt-local MUSL_CHEZ_ROOT=/usr/local MUSL_SCHEME=/usr/local/bin/scheme +RUN make linux-qt-local MUSL_CHEZ_ROOT=/opt/chez MUSL_SCHEME=/opt/chez/bin/scheme-wrapper # Verify RUN ./jemacs-qt --version && \ --- a/build-binary-qt.ss +++ b/build-binary-qt.ss @@ -702,7 +702,7 @@ grep -v '^$' | grep -v '^register_static_foreign_symbols$'") pkgconf "-L/usr/lib -lssl -lcrypto")) "")) - (cmd (format "g++ -static -fno-lto -fno-use-linker-plugin -Wl,--export-dynamic -o jemacs-qt \ + (cmd (format "g++ -static -Wl,--export-dynamic -o jemacs-qt \ jemacs-qt-main.o jemacs-qt-chez-shim.o jemacs-qt-pcre2-shim.o jemacs-qt-jsh-ffi.o \ jemacs-qt-libcoreutils.o jemacs-qt-jsh-coreutils-stubs.o \ jemacs-qt-embed-crypto.o jemacs-qt-ssh-agent-stub.o ~a \