Skip to content

Conversation

@TroyHernandez
Copy link

Summary

Excludes glibc libraries from the RUNTIME_DEPENDENCY_SET to 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.so

When 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

This manifests inconsistently depending on LD_LIBRARY_PATH ordering - if system library paths come first, system glibc wins and it works; otherwise the bundled glibc 2.31 gets loaded via liblantern.so's RUNPATH=$ORIGIN and fails.

Solution

Add PRE_EXCLUDE_REGEXES and POST_EXCLUDE_REGEXES to the install(RUNTIME_DEPENDENCY_SET ...) command to filter out:

  • glibc library names (libc, libdl, libpthread, librt, libm, ld-linux)
  • System library paths (/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

  • Verify lantern builds successfully with BUNDLE_DEPENDENCIES=ON
  • Confirm glibc libraries are not present in the resulting package
  • Test on Ubuntu 24.04 (glibc 2.39) with various LD_LIBRARY_PATH configurations

Related issues


Generated with Claude Code

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>
@TroyHernandez
Copy link
Author

Test Results

Build Test

Built and packaged lantern locally with BUNDLE_DEPENDENCIES=ON:

$ 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:

libtorch_cpu.so, libtorch.so, liblantern.so, libc10.so, libgomp-*.so.1, etc.

Runtime Test

Replaced 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_PRIVATE

After 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 affected

The issue manifests inconsistently because Rscript and littler set different LD_LIBRARY_PATH:

Launcher LD_LIBRARY_PATH
Rscript /usr/lib/R/lib:/usr/lib/x86_64-linux-gnu:... (system paths first)
littler /usr/local/cuda-12.8/lib64:... (no system lib paths)

With system paths first, the loader finds system glibc before torch's bundled copy. Without them, liblantern.so's RUNPATH=$ORIGIN causes the bundled glibc 2.31 to be loaded, which fails against the system's glibc 2.39 due to GLIBC_PRIVATE symbol incompatibility.

This fix ensures the bundled package never includes glibc, so the loader always uses the host system's glibc regardless of LD_LIBRARY_PATH ordering.

Build Environment

  • Ubuntu 24.04 (glibc 2.39)
  • CMake 3.28.3
  • GCC 13.3.0
  • R 4.5.2

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