From 34d52883cbd7dcb8903fe5a380ca74ac1e050674 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sun, 27 Sep 2026 01:02:15 -0700 Subject: [PATCH] fix(installer): ELF interpreter decides musl in uv_bootstrap_target, as in pm/store install.sh consulted ldd before the ELF interpreter while pm/store.py's _is_musl_libc reads the native userland's ELF interpreter first, so a glibc ldd (secondary toolchain, gcompat) could make the bootstrap stage a different libc than PM later resolves. Read /bin/sh (then /bin/ls) PT_INTERP first in both; ldd and the loader glob are fallbacks only. --- scripts/install.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 9643eccc2b..7549ac40de 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -218,12 +218,23 @@ uv_bootstrap_target() { esac case "$(uname -s)" in Linux) - # Minimal musl roots may have the loader but no ldd. Trust a - # recognizable ldd result before falling back to the loader: - # a glibc host may carry musl as a secondary toolchain. - local _libc - _libc="$(ldd --version 2>&1 || true)" - _libc="${_libc,,}" + # Same precedence as pm/store.py::_is_musl_libc: the native + # userland's ELF interpreter decides; ldd and a musl loader on + # disk are fallbacks only (a glibc host may carry musl as a + # secondary toolchain, and minimal musl roots may lack ldd). + local _libc="" _probe _head + for _probe in /bin/sh /bin/ls; do + _head="$(head -c 8192 "$_probe" 2>/dev/null | LC_ALL=C tr -d '\000')" || continue + [[ "$_head" == $'\x7f'ELF* ]] || continue + case "$_head" in + *ld-musl-*) _libc="musl"; break ;; + *ld-linux*) _libc="glibc"; break ;; + esac + done + if [[ -z "$_libc" ]]; then + _libc="$(ldd --version 2>&1 || true)" + _libc="${_libc,,}" + fi if [[ "$_libc" == *musl* ]]; then echo "linux-$_arch-musl" elif [[ "$_libc" == *glibc* || "$_libc" == *"gnu libc"* || "$_libc" == *"gnu c library"* ]]; then