@@ -143,27 +143,32 @@ parts:
143143 - libstdc++6
144144 - make
145145
146- # glibc runtime files are part of the core24 base, so snapcraft does NOT stage them.
147- # But `gcc --sysroot=$SNAP` makes the linker look for e.g. /lib/x86_64-linux-gnu/libm.so.6
148- # INSIDE $SNAP. WHAT this part does: for every runtime .so of libc6 / libgcc-s1 / libstdc++6
149- # that is not already in the snap, add an absolute symlink pointing to the same path.
150- # Inside the snap's mount namespace "/" IS core24, so the link resolves to the base's copy.
151- # (Verified: C + C++ compile and run with host headers hidden, only the sysroot visible.)
146+ # GCC's sysroot needs the core24 libc linker targets. Only libc runtime
147+ # targets may point into the base. Bundle GCC/C++ runtimes, and omit gconv
148+ # module aliases (the running libc already loads those from the base).
152149 libc-links :
153150 plugin : nil
154- # Prime the Python venv first: it creates lib64 -> lib. Creating a real
155- # lib64 directory before that makes python-deps fail with IsADirectoryError.
151+ # The Python venv must prime lib64 -> lib before these linker aliases.
156152 after : [compilers, python-deps]
157153 override-prime : |
158154 craftctl default
159155 for pkg in libc6 libgcc-s1 libstdc++6; do
160156 dpkg -L "$pkg" 2>/dev/null | grep -E '^/(usr/)?lib(64)?/.*\.so[.0-9]*$' | while read -r f; do
161- # WHY both paths: noble ships glibc in /usr/lib, but libc6-dev's linker scripts
162- # (libc.so, libm.so) still name /lib/x86_64-linux-gnu/... and /lib64/ld-linux...
157+ case "$f" in */gconv/*) continue ;; esac
158+ if [ "$pkg" != libc6 ] && [ ! -e "$CRAFT_PRIME$f" ]; then
159+ mkdir -p "$(dirname "$CRAFT_PRIME$f")"
160+ cp -L "$f" "$CRAFT_PRIME$f"
161+ fi
162+ # Noble uses /usr/lib; glibc linker scripts also reference /lib.
163163 for t in "$f" "${f#/usr}"; do
164164 [ -e "$CRAFT_PRIME$t" ] || [ -L "$CRAFT_PRIME$t" ] && continue
165165 mkdir -p "$(dirname "$CRAFT_PRIME$t")"
166- ln -s "$f" "$CRAFT_PRIME$t"
166+ if [ "$pkg" = libc6 ]; then
167+ ln -s "$f" "$CRAFT_PRIME$t"
168+ else
169+ target=$(realpath --relative-to="$(dirname "$CRAFT_PRIME$t")" "$CRAFT_PRIME$f")
170+ ln -s "$target" "$CRAFT_PRIME$t"
171+ fi
167172 done
168173 done
169174 done
0 commit comments