From d92162f01f715fc72226a40f875ed5db13adc670 Mon Sep 17 00:00:00 2001 From: Clementine Pendragon Date: Wed, 1 Jul 2026 22:13:23 -0600 Subject: [PATCH 1/5] feat: musl builds --- .github/workflows/build.yml | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c159f8a8a..bcfd9ac89 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,6 +101,63 @@ jobs: path: | sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip + # musl (Alpine) — CPU. Compiled inside an Alpine container so it links musl; + # libstdc++/libgcc are static so the archive is self-contained. + alpine-musl-cmake: + strategy: + fail-fast: false + matrix: + include: + - runner: ubuntu-latest + arch: x86_64 + cpu_flags: "-DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON" + - runner: ubuntu-24.04-arm + arch: aarch64 + cpu_flags: "" + runs-on: ${{ matrix.runner }} + + steps: + - name: Clone + uses: actions/checkout@v6 + with: + submodules: recursive + fetch-depth: 0 + repository: 'leejet/stable-diffusion.cpp' + + - name: Build (Alpine / musl) + run: | + docker run --rm -v "$PWD:/src" -w /src alpine:latest sh -euxc ' + apk add --no-cache build-base cmake git zip + cmake -B build -S . \ + -DGGML_NATIVE=OFF \ + ${{ matrix.cpu_flags }} \ + -DSD_BUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" \ + -DCMAKE_SHARED_LINKER_FLAGS="-static-libgcc -static-libstdc++" + cmake --build build --config Release -j"$(nproc)" + chmod -R a+rwX build + ' + + - name: Get commit hash + id: commit + if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }} + uses: prompt/actions-commit-hash@v2 + + - name: Pack artifacts + if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }} + run: | + cp ggml/LICENSE ./build/bin/ggml.txt + cp LICENSE ./build/bin/stable-diffusion.cpp.txt + zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Linux-musl-${{ matrix.arch }}.zip ./build/bin/* + + - name: Upload artifacts + if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Linux-musl-${{ matrix.arch }}.zip + path: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Linux-musl-${{ matrix.arch }}.zip + ubuntu-latest-cuda: runs-on: ubuntu-22.04 @@ -931,6 +988,7 @@ jobs: needs: - ubuntu-latest-rocm - ubuntu-latest-cmake + - alpine-musl-cmake - ubuntu-latest-cuda - ubuntu-arm64-cuda - windows-latest-cmake-hip From 446f6618a9d25cf449716b860e17fe4f0a8a93b7 Mon Sep 17 00:00:00 2001 From: Clementine Pendragon Date: Thu, 2 Jul 2026 15:07:15 -0600 Subject: [PATCH 2/5] ci(musl): emit $ORIGIN-relative rpath so relocated binaries find sibling libs --- .github/workflows/build.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c26373454..4c0357bb8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,7 +127,7 @@ jobs: - name: Build (Alpine / musl) run: | docker run --rm -v "$PWD:/src" -w /src alpine:latest sh -euxc ' - apk add --no-cache build-base cmake git zip + apk add --no-cache build-base cmake git zip patchelf file cmake -B build -S . \ -DGGML_NATIVE=OFF \ ${{ matrix.cpu_flags }} \ @@ -136,6 +136,20 @@ jobs: -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" \ -DCMAKE_SHARED_LINKER_FLAGS="-static-libgcc -static-libstdc++" cmake --build build --config Release -j"$(nproc)" + + # ggml shared libs land outside build/bin; collect them next to the + # binaries so the flattened archive is self-contained. + find build -name "libggml*.so*" ! -path "build/bin/*" -exec cp -av {} build/bin/ \; + + # The build tree bakes an absolute rpath; rewrite to $ORIGIN so the + # relocated musl binaries find their sibling .so files at runtime. + for f in build/bin/*; do + [ -f "$f" ] && ! [ -L "$f" ] || continue + if file "$f" | grep -q ELF; then + patchelf --set-rpath "\$ORIGIN" "$f" + fi + done + chmod -R a+rwX build ' From 82cebc51cd9dc1da6129841cd7baf552fb4c25ee Mon Sep 17 00:00:00 2001 From: Clementine Pendragon Date: Thu, 2 Jul 2026 22:06:32 -0600 Subject: [PATCH 3/5] version pinning --- .github/workflows/build.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c0357bb8..0313911db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,11 @@ on: description: "Create new release" required: true type: boolean + sd_ref: + description: "leejet/stable-diffusion.cpp ref to build (pin to match lemonade's sd-cpp version, e.g. 8caa3f9 for master-721-8caa3f9)" + required: false + default: "8caa3f9" + type: string pull_request: # validate the release build on PRs; the release job is skipped so nothing is published paths: # The build jobs clone stable-diffusion.cpp source from upstream @@ -18,6 +23,7 @@ on: env: BRANCH_NAME: master + SD_REF: ${{ github.event.inputs.sd_ref || '8caa3f9' }} permissions: contents: read @@ -37,6 +43,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} - name: Setup Node uses: actions/setup-node@v4 @@ -123,6 +130,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} - name: Build (Alpine / musl) run: | @@ -189,7 +197,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' - ref: master + ref: ${{ env.SD_REF }} - name: ccache uses: ggml-org/ccache-action@v1.2.16 @@ -290,7 +298,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' - ref: master + ref: ${{ env.SD_REF }} - name: Install CUDA Toolkit id: cuda-toolkit @@ -380,7 +388,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' - ref: master + ref: ${{ env.SD_REF }} - name: ccache uses: ggml-org/ccache-action@v1.2.16 @@ -473,6 +481,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} - name: Setup Node uses: actions/setup-node@v4 @@ -592,6 +601,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} - name: Cache ROCm Installation id: cache-rocm @@ -679,6 +689,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} - name: Setup Node uses: actions/setup-node@v4 @@ -800,6 +811,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} - name: Setup Node uses: actions/setup-node@v4 @@ -948,6 +960,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} - name: ccache uses: ggml-org/ccache-action@v1.2.21 @@ -1025,6 +1038,7 @@ jobs: submodules: recursive fetch-depth: 0 repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} - name: Download artifacts id: download-artifact From 354eb381e3c4446e0a2a5f9734b01cd91390f40c Mon Sep 17 00:00:00 2001 From: Clementine Pendragon Date: Thu, 2 Jul 2026 23:52:15 -0600 Subject: [PATCH 4/5] pin full sha, rpath fixes --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0313911db..662f0303f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,9 +10,9 @@ on: required: true type: boolean sd_ref: - description: "leejet/stable-diffusion.cpp ref to build (pin to match lemonade's sd-cpp version, e.g. 8caa3f9 for master-721-8caa3f9)" + description: "leejet/stable-diffusion.cpp ref to build — FULL 40-char SHA (checkout rejects short SHAs). 8caa3f908ae6d4a4bef531e73b9a969f266a3d1f -> tag master-721-8caa3f9" required: false - default: "8caa3f9" + default: "8caa3f908ae6d4a4bef531e73b9a969f266a3d1f" type: string pull_request: # validate the release build on PRs; the release job is skipped so nothing is published paths: @@ -23,7 +23,7 @@ on: env: BRANCH_NAME: master - SD_REF: ${{ github.event.inputs.sd_ref || '8caa3f9' }} + SD_REF: ${{ github.event.inputs.sd_ref || '8caa3f908ae6d4a4bef531e73b9a969f266a3d1f' }} permissions: contents: read From 9c990043e2ffafe5c5fd5dd9fbb4e9cb5a509bde Mon Sep 17 00:00:00 2001 From: Clementine Pendragon Date: Fri, 3 Jul 2026 10:25:06 -0600 Subject: [PATCH 5/5] add vulkan+musl --- .github/workflows/build.yml | 81 ++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 662f0303f..9e2080408 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,11 @@ on: env: BRANCH_NAME: master - SD_REF: ${{ github.event.inputs.sd_ref || '8caa3f908ae6d4a4bef531e73b9a969f266a3d1f' }} + # Upstream ref every job checks out. Empty on schedule/PR (no inputs) so + # actions/checkout uses leejet's default branch = latest master, preserving the + # fork's original nightly behavior. A manual dispatch defaults to the sd_ref + # input so a deliberate build matches lemonade's sd-cpp pin (master-721-8caa3f9). + SD_REF: ${{ github.event.inputs.sd_ref }} permissions: contents: read @@ -180,6 +184,80 @@ jobs: name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Linux-musl-${{ matrix.arch }}.zip path: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Linux-musl-${{ matrix.arch }}.zip + # musl (Alpine) — Vulkan. Same self-contained-archive approach as the CPU job; + # the Vulkan backend loads libvulkan at runtime (not bundled) via the loader. + alpine-musl-vulkan: + strategy: + fail-fast: false + matrix: + include: + - runner: ubuntu-latest + arch: x86_64 + cpu_flags: "-DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON" + - runner: ubuntu-24.04-arm + arch: aarch64 + cpu_flags: "" + runs-on: ${{ matrix.runner }} + + steps: + - name: Clone + uses: actions/checkout@v6 + with: + submodules: recursive + fetch-depth: 0 + repository: 'leejet/stable-diffusion.cpp' + ref: ${{ env.SD_REF }} + + - name: Build (Alpine / musl) + run: | + docker run --rm -v "$PWD:/src" -w /src alpine:latest sh -euxc ' + apk add --no-cache build-base cmake git zip patchelf file \ + vulkan-loader-dev vulkan-headers glslang shaderc spirv-tools spirv-headers + cmake -B build -S . \ + -DGGML_NATIVE=OFF \ + ${{ matrix.cpu_flags }} \ + -DSD_VULKAN=ON \ + -DSD_BUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" \ + -DCMAKE_SHARED_LINKER_FLAGS="-static-libgcc -static-libstdc++" + cmake --build build --config Release -j"$(nproc)" + + # ggml shared libs land outside build/bin; collect them next to the + # binaries so the flattened archive is self-contained. + find build -name "libggml*.so*" ! -path "build/bin/*" -exec cp -av {} build/bin/ \; + + # The build tree bakes an absolute rpath; rewrite to $ORIGIN so the + # relocated musl binaries find their sibling .so files at runtime. + for f in build/bin/*; do + [ -f "$f" ] && ! [ -L "$f" ] || continue + if file "$f" | grep -q ELF; then + patchelf --set-rpath "\$ORIGIN" "$f" + fi + done + + chmod -R a+rwX build + ' + + - name: Get commit hash + id: commit + if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }} + uses: prompt/actions-commit-hash@v2 + + - name: Pack artifacts + if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }} + run: | + cp ggml/LICENSE ./build/bin/ggml.txt + cp LICENSE ./build/bin/stable-diffusion.cpp.txt + zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Linux-musl-vulkan-${{ matrix.arch }}.zip ./build/bin/* + + - name: Upload artifacts + if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Linux-musl-vulkan-${{ matrix.arch }}.zip + path: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Linux-musl-vulkan-${{ matrix.arch }}.zip + ubuntu-latest-cuda: runs-on: ubuntu-22.04 @@ -1022,6 +1100,7 @@ jobs: - ubuntu-latest-rocm - ubuntu-latest-cmake - alpine-musl-cmake + - alpine-musl-vulkan - ubuntu-latest-cuda - ubuntu-arm64-cuda - windows-latest-cmake-hip