From f4b3bfd6ee9bdc8ee1bb62ed405420ed165ab1b7 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 13 Sep 2024 09:34:32 +0200 Subject: [PATCH] Find `libc.so` directly in musl systems (#856) * Find libc.so directly in musl systems * add news * pre-commit * add ref Co-authored-by: drewgilliam * warn if libc.so can't be found --------- Co-authored-by: drewgilliam --- constructor/header.sh | 15 +++++++++++++-- news/856-fix-musl-glibc | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 news/856-fix-musl-glibc diff --git a/constructor/header.sh b/constructor/header.sh index 2edb0ca44..f91e49ae0 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -37,8 +37,19 @@ fi min_glibc_version="__MIN_GLIBC_VERSION__" case "$(ldd --version 2>&1)" in *musl*) - # musl ldd will report musl version; call ld.so directly - system_glibc_version=$($(find /lib/ /lib64/ -name 'ld-linux-*.so*' 2>/dev/null | head -1) --version | awk 'NR==1{ sub(/\.$/, ""); print $NF}') + # musl ldd will report musl version; call libc.so directly + # see https://github.com/conda/constructor/issues/850#issuecomment-2343756454 + libc_so="$(find /lib /usr/local/lib /usr/lib -name 'libc.so.*' -print -quit 2>/dev/null)" + if [ -z "${libc_so}" ]; then + libc_so="$(strings /etc/ld.so.cache | grep '^/.*/libc\.so.*' | head -1)" + fi + if [ -z "${libc_so}" ]; then + echo "Warning: Couldn't find libc.so; won't be able to determine GLIBC version!" >&2 + echo "Override by setting CONDA_OVERRIDE_GLIBC" >&2 + system_glibc_version="${CONDA_OVERRIDE_GLIBC:-0.0}" + else + system_glibc_version=$("${libc_so}" --version | awk 'NR==1{ sub(/\.$/, ""); print $NF}') + fi ;; *) # ldd reports glibc in the last field of the first line diff --git a/news/856-fix-musl-glibc b/news/856-fix-musl-glibc new file mode 100644 index 000000000..4532c267f --- /dev/null +++ b/news/856-fix-musl-glibc @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Fix GLIBC detection method in some MUSL systems. (#850 via #856) + +### Deprecations + +* + +### Docs + +* + +### Other + +*