useShellEnv: don't auto-export lib/ for libc-style bottles#85
Conversation
For most projects, adding `${prefix}/lib/` to `LD_LIBRARY_PATH` /
`LIBRARY_PATH` is exactly what you want: subsequent commands in the
pkgx env find the bottle's shared libraries.
For projects that *ship libc itself* (gnu.org/glibc; musl bottles
when they land) the auto-export is harmful: every executable in the
env tries to load the bottle's libc.so.6, but the host's own
ld-linux is the one doing the loading. When the bottle's libc is
newer than what the host's ld-linux supports, every command in the
env breaks:
mkdir: /lib/ld-linux-aarch64.so.1: version `GLIBC_2.35' not found
(required by /opt/gnu.org/glibc/v2.43.0/lib/libc.so.6)
Add a small hardcoded `NO_LIB_EXPORT` set listing projects whose
`lib/` and `include/` must NOT be auto-added. For these projects,
LIBRARY_PATH / LD_LIBRARY_PATH (set later from LIBRARY_PATH) and
CPATH all skip the bottle. Consumers that explicitly want to link
against this glibc bottle do so via a sysroot route (`-B`, `-isystem`,
`-Wl,--dynamic-linker=…`), not via env auto-population.
This is the v1 implementation; the set is intentionally minimal and
hardcoded. v2 should express the opt-out in the bottle's own metadata
so the pantry can add new libc-style bottles without a coordinated
libpkgx release.
Refs:
- pkgxdev/pantry#12968 (gnu.org/glibc PR) — the use case. The PR
currently works around this by installing libs under lib/glibc-X.Y/
to keep the top lib/ free of libc.so.6. With this libpkgx change,
glibc can ship libs at the conventional lib/ path.
- pkgxdev/pantry#5080 (mxcl's Feb 2024 glibc attempt — same root cause).
Includes a regression test that asserts gnu.org/glibc's lib/ is NOT
exported while curl.se's lib/ still is (current behaviour preserved).
Coverage Report for CI Build 26167830176Warning No base build found for commit Coverage: 82.877%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
Updates useShellEnv to avoid auto-exporting lib/ and include/ paths for “libc-style” bottles (starting with gnu.org/glibc), preventing LD_LIBRARY_PATH pollution that can break execution on hosts with older ld-linux than the bottle’s glibc requires.
Changes:
- Add a hardcoded
NO_LIB_EXPORTallowlist of projects whoselib//include/should not be auto-added toLIBRARY_PATH/CPATH(and therefore not toLD_LIBRARY_PATH). - Gate the existing “archaic”
lib/+include/auto-add behind!NO_LIB_EXPORT.has(project). - Add regression coverage ensuring
gnu.org/glibcis skipped while a normal library-bearing project (egcurl.se) is still exported.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/hooks/useShellEnv.ts | Adds NO_LIB_EXPORT and skips lib//include/ auto-export for libc-shipping projects. |
| src/hooks/useShellEnv.test.ts | Adds regression test asserting glibc’s lib/ is not added while curl’s lib/ remains added. |
| fixtures/projects/gnu.org/glibc/package.yml | Adds fixture pantry entry so tests can resolve the gnu.org/glibc project. |
| fixtures/projects/curl.se/package.yml | Adds fixture pantry entry so tests can resolve the curl.se project. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
elegant. |
Summary
For most projects, adding
\${prefix}/lib/toLD_LIBRARY_PATH/LIBRARY_PATHis exactly what you want: subsequent commands in the pkgx env find the bottle's shared libraries.For projects that ship libc itself (
gnu.org/glibc; musl bottles when they land) the auto-export is harmful: every executable in the env tries to load the bottle'slibc.so.6, but the host's own ld-linux is the one doing the loading. When the bottle's libc is newer than what the host's ld-linux supports, every command in the env breaks:This blocks
gnu.org/glibcfrom being a usable pantry recipe — currently the only workaround is to install glibc's shared libraries into a sub-directory likelib/glibc-X.Y/so the toplib/doesn't containlibc.so.6. That's a hack in the recipe; the right place to fix it is here in libpkgx.Change
Add a small hardcoded
NO_LIB_EXPORTset listing projects whoselib/andinclude/must NOT be auto-added:For projects in this set,
LIBRARY_PATH/LD_LIBRARY_PATH(set later fromLIBRARY_PATH) andCPATHall skip the bottle. Thearchaicblock at the centre ofuseShellEnv.ts:map()gains a single conjunction:Consumers that explicitly want to link against the glibc bottle do so via a sysroot route (
-B,-isystem,-Wl,--dynamic-linker=…), not via env auto-population. The bottle'sbin/(getconf, ldconfig, …) still ends up in PATH normally.Tests
Added a regression test in
src/hooks/useShellEnv.test.tsasserting thatgnu.org/glibc'slib/is NOT exported whilecurl.se'slib/still is (existing behaviour preserved).Full suite: 76 passed (was 75), 0 failed.
v1 vs v2
This is the v1 implementation: the set is intentionally minimal and hardcoded. v2 should express the opt-out in the bottle's own metadata (a small
.pkgx-meta.jsonfile or similar) so the pantry can add new libc-style bottles without a coordinated libpkgx release. Happy to follow up with a v2 PR if there's interest in the direction.Refs
lib/glibc-X.Y/. With this libpkgx change merged, glibc can ship libs at the conventionallib/path and the workaround drops.PT_INTERP+brewingissue infix-elf.ts.🤖 Generated with Claude Code