fix: restore deno compile output support in alpine image#546
Merged
Conversation
The alpine image isolates glibc libs in /usr/local/lib/glibc and relies on
patchelf rpaths on /deno and /tini to find them. Binaries produced by
`deno compile` are not rpath-patched, so their glibc loader cannot find
libdl.so.2 (and the other isolated libs), failing with:
error while loading shared libraries: libdl.so.2: cannot open shared
object file: No such file or directory
This is a regression since the 2.7.8 image (#523), which moved the libs
into the isolated directory and dropped `ENV LD_LIBRARY_PATH`.
Re-adding LD_LIBRARY_PATH would reintroduce the musl-package conflict #523
fixed, since musl's loader also honors it. Instead, generate a glibc
ld.so.cache pointing at /usr/local/lib/glibc: the glibc loader consults it
(so rpath-less compiled binaries resolve their libs), while musl's loader
ignores /etc/ld.so.cache entirely, keeping the isolation intact.
Fixes denoland/deno#35683
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running the output of
deno compileinside the Alpine image fails since the 2.7.8 image:Fixes denoland/deno#35683.
Root cause
This is an image regression, not a
denobinary bug. I confirmed the compiled binaries are identical in their ELF dependencies across versions (both needlibdl.so.2, no rpath) — the difference is purely the image:Commit 01a6547 (#523, first shipped in the 2.7.8 image) isolated glibc libs into
/usr/local/lib/glibc/, droppedENV LD_LIBRARY_PATH, and rpath-patched only/denoand/tini. Adeno compileoutput binary gets neither the rpath norLD_LIBRARY_PATH, so its glibc loader can't findlibdl.so.2in the isolated (non-searched) directory.Re-adding
LD_LIBRARY_PATHwould reintroduce the exact musl-package conflict #523 fixed, because musl's loader also honorsLD_LIBRARY_PATHand would then load the incompatible glibclibgcc_s.so.1.Fix
Generate a glibc
/etc/ld.so.cachepointing at/usr/local/lib/glibc. The glibc loader consults it, so rpath-less compiled binaries resolve their libs — while musl's loader ignores/etc/ld.so.cacheentirely, so the isolation from #523 is fully preserved and no conflict returns. The cache is built with theldconfigalready present in the existingtinibuild stage (no new base image).Verification (full image build,
DENO_VERSION=2.9.0)denorunsdeno compileoutput runs (the reported failure)apk add nodejs+nodestill runs — no glibc/musl conflict reintroduced