Exclude glibc libraries from dependency bundling#1397
Conversation
The RUNTIME_DEPENDENCY_SET was capturing glibc components (libc, libdl, libpthread, librt, libm, ld-linux) from the Ubuntu 20.04 build environment. When these bundled glibc 2.31 libraries are loaded on systems with newer glibc (e.g., Ubuntu 24.04 with glibc 2.39), GLIBC_PRIVATE symbol mismatches cause runtime failures: liblantern.so - libdl.so.2: undefined symbol: _dl_catch_error, version GLIBC_PRIVATE glibc libraries must never be bundled on Linux - they should always come from the host system. This is standard practice for portable Linux binaries (cf. manylinux approach). This fix adds PRE_EXCLUDE_REGEXES and POST_EXCLUDE_REGEXES to filter out glibc components and system library paths from the dependency collection. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Test ResultsBuild TestBuilt and packaged lantern locally with $ cmake .. -DBUNDLE_DEPENDENCIES=ON
$ cmake --build . --config Release --parallel 4 --target package
CPack: - package: lantern-0.16.3.9000+cpu+x86_64-Linux.zip generated.Verified: No glibc libraries in package $ unzip -l lantern-*.zip | grep -E 'libc-|libdl-|libpthread-|librt-|libm-|ld-.*\.so'
(no output - glibc excluded ✓)Expected libraries still bundled: Runtime TestReplaced installed torch libs with the fixed build and tested both launchers: Before fix (littler fails): $ r -e 'library(torch)'
✖ liblantern.so - libdl.so.2: undefined symbol: _dl_catch_error, version GLIBC_PRIVATEAfter fix (both work): $ r -e 'library(torch); print(torch_tensor(1:5))'
torch_tensor
1
2
3
4
5
[ CPULongType{5} ]
$ Rscript -e 'library(torch); print(torch_tensor(1:5))'
torch_tensor
1
2
3
4
5
[ CPULongType{5} ]Context: Why littler was affectedThe issue manifests inconsistently because
With system paths first, the loader finds system glibc before torch's bundled copy. Without them, This fix ensures the bundled package never includes glibc, so the loader always uses the host system's glibc regardless of Build Environment
|
Summary
Excludes glibc libraries from the
RUNTIME_DEPENDENCY_SETto prevent bundling system libraries that cause ABI conflicts on newer Linux distributions.Problem
The current build bundles glibc 2.31 components from the Ubuntu 20.04 build environment:
libc-2.31.so,libdl-2.31.so,libpthread-2.31.so,librt-2.31.so,libm-2.31.so,ld-2.31.soWhen loaded on systems with newer glibc (e.g., Ubuntu 24.04 with glibc 2.39),
GLIBC_PRIVATEsymbol mismatches cause runtime failures:This manifests inconsistently depending on
LD_LIBRARY_PATHordering - if system library paths come first, system glibc wins and it works; otherwise the bundled glibc 2.31 gets loaded vialiblantern.so'sRUNPATH=$ORIGINand fails.Solution
Add
PRE_EXCLUDE_REGEXESandPOST_EXCLUDE_REGEXESto theinstall(RUNTIME_DEPENDENCY_SET ...)command to filter out:libc,libdl,libpthread,librt,libm,ld-linux)/lib/,/lib64/,/usr/lib/)glibc libraries should never be bundled on Linux - they must come from the host system. This is standard practice for portable Linux binaries (cf. manylinux approach).
Test plan
BUNDLE_DEPENDENCIES=ONLD_LIBRARY_PATHconfigurationsRelated issues
Generated with Claude Code