Skip to content

fix: patchelf LLVM runtime libs to fix stale RUNPATH#67

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/llvm-shared-lib-runpath
May 22, 2026
Merged

fix: patchelf LLVM runtime libs to fix stale RUNPATH#67
Sunrisepeak merged 1 commit into
mainfrom
fix/llvm-shared-lib-runpath

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

  • After mcpp installs the LLVM toolchain, libc++.so.1 retains stale xlings-era RUNPATH, causing libatomic.so.1 to not be found at runtime
  • Run patchelf_walk() on LLVM lib/ directory after install to rewrite RUNPATH to mcpp registry paths
  • Only walks lib/ (not bin/) to preserve clang++'s own xlings-managed RUNPATH

Root Cause

libc++.so.1 (NEEDED by user binaries) depends on libatomic.so.1. ELF RUNPATH is non-transitive — the loader uses libc++.so.1's own RUNPATH (stale xlings paths) to find libatomic.so.1, not the executable's RUNPATH.

Test plan

  • Local build succeeds
  • mcpp toolchain install llvm 20.1.7 completes, libc++.so.1 RUNPATH points to mcpp registry
  • mcpp new + mcpp run with LLVM toolchain — no libatomic.so.1 error
  • GCC toolchain unaffected
  • CI: Linux, macOS, Windows all pass

libc++.so.1 depends on libatomic.so.1 (NEEDED). After mcpp copies the
LLVM xpkg from xlings, the shared libraries retain xlings-era RUNPATH
entries that point to non-existent paths. Since ELF RUNPATH is
non-transitive, the loader uses libc++.so.1's own stale RUNPATH when
searching for libatomic.so.1, causing runtime failure on systems without
a system-installed gcc runtime.

Fix: run patchelf_walk() on the LLVM lib/ directory (not bin/) after
install, rewriting RUNPATH to point to the mcpp registry paths. This
mirrors the existing GCC post-install fixup. The bin/ directory is
excluded because clang++ has its own xlings-managed RUNPATH that must
be preserved.
@Sunrisepeak Sunrisepeak merged commit 359aaa8 into main May 22, 2026
3 checks passed
@Sunrisepeak Sunrisepeak deleted the fix/llvm-shared-lib-runpath branch May 22, 2026 07:29
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