Skip to content

fix: musl link error with glibc libs in /usr/local/lib/ on alpine#499

Closed
erusc wants to merge 1 commit intodenoland:mainfrom
erusc:alpine-fix
Closed

fix: musl link error with glibc libs in /usr/local/lib/ on alpine#499
erusc wants to merge 1 commit intodenoland:mainfrom
erusc:alpine-fix

Conversation

@erusc
Copy link
Copy Markdown

@erusc erusc commented Nov 21, 2025

When I tried to add ffmpeg to denoland/deno:alpine. I got this link error.

docker run --rm -it denoland/deno:alpine sh -c 'apk add ffmpeg && ffmpeg'
Error relocating /usr/local/lib/libgcc_s.so.1: _dl_find_object: symbol not found
Error relocating /usr/local/lib/libgcc_s.so.1: __cpu_indicator_init: symbol not found
Error relocating /usr/local/lib/libgcc_s.so.1: __cpu_model: symbol not found

I instigated and found that is was caused by glibc libs in /usr/local/lib/, copied from gcr.io/distroless/cc.

COPY --from=cc --chown=root:root --chmod=755 /lib/*-linux-gnu/* /usr/local/lib/

This PR fixes the issue by putting glibc libs in the same path as in gcr.io/distroless/cc.

ls /lib/$(arch)-linux-gnu/ /lib64/
/lib/x86_64-linux-gnu:
ld-linux-x86-64.so.2    libc_malloc_debug.so.0  libmemusage.so          libnss_dns.so.2         libpthread.so.0         libutil.so.1
libBrokenLocale.so.1    libdl.so.2              libmvec.so.1            libnss_files.so.2       libresolv.so.2
libanl.so.1             libgcc_s.so.1           libnsl.so.1             libnss_hesiod.so.2      librt.so.1
libc.so.6               libm.so.6               libnss_compat.so.2      libpcprofile.so         libthread_db.so.1

/lib64:
ld-linux-x86-64.so.2

Since /lib/x86_64-linux-gnu (/lib/aarch64-linux-gnu on arm64) is used exclusively by glibc dynamic linker, this eliminates the interference with musl and the need for environment variable LD_LIBRARY_PATH.

Putting glibc libs in /usr/local/lib/ can result in link error when a musl binary tries to link libgcc.
This fix it by putting them in the same path as in gcr.io/distroless/cc, which also eliminates the need for LD_LIBRARY_PATH.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 21, 2025

CLA assistant check
All committers have signed the CLA.

@bartlomieju
Copy link
Copy Markdown
Member

Thanks, I'm gonna land #523 instead that should be a more thorough fix.

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.

3 participants