Skip to content

Add musl/Alpine native support (linux-musl-x64 / linux-musl-arm64)#16

Open
Frooodle wants to merge 3 commits into
mainfrom
feat/musl-alpine-support
Open

Add musl/Alpine native support (linux-musl-x64 / linux-musl-arm64)#16
Frooodle wants to merge 3 commits into
mainfrom
feat/musl-alpine-support

Conversation

@Frooodle

Copy link
Copy Markdown
Member

Summary

Adds linux-musl-x64 and linux-musl-arm64 native targets so JPDFium can run on Alpine/musl (e.g. Stirling-PDF's ultra-lite Docker image). The bundled PDFium natives are glibc-linked today, so a musl JVM can't load them; this wires up musl-specific native artifacts and runtime selection.

What's in here

Validated locally (gradle wiring resolves, :jpdfium:compileJava is green):

  • NativeLoader.detectPlatform() now detects musl (probes /lib/ld-musl-*, falls back to ldd --version) and returns linux-musl-<arch>, cached.
  • New gradle modules jpdfium-natives-linux-musl-x64 / -arm64 (use the existing platform-generic natives-conventions plugin), wired into settings.gradle.kts and the BOM.
  • jpdfium.version bumped to 1.1.0-SNAPSHOT.
  • fetch-prebuilt-pdfium.sh doc/usage updated for the new platforms (no whitelist to change).

Best-effort, must be proven by CI (I cannot build Chromium-under-musl locally):

  • prebuild-pdfium.yml: new linux-musl-* matrix legs that build natively inside matching-arch Alpine containers (x64 on ubuntu-latest, arm64 on ubuntu-24.04-arm), with a bash/toolchain bootstrap (apk add ... gcompat). The release job is now always() + warn-only for musl so an unproven musl leg can't block the glibc/darwin/windows prebuild.
  • setup-pdfium.sh: a JPDFIUM_LIBC=musl branch (use_custom_libcxx=true).

Honest caveat / how to test

PDFium/Chromium has no official musl support and its bundled clang is a glibc binary, so the Alpine PDFium build is the open part - it will likely need EmbedPDF fork patches and GN/toolchain tuning. Note prebuild-pdfium.yml runs on workflow_dispatch/cron, not on PRs, so to actually exercise the musl legs trigger the Prebuild PDFium workflow manually on this branch. The publish workflows (release/snapshot/publish-github-packages) are intentionally not wired for musl yet - that's a follow-up once the musl prebuild is green (no point publishing natives that don't build).

Opening as a draft to see how the musl prebuild fares in CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant