In contrast to glibc musl profiles use 'lib' layour for 32-bit
and 64-bit targets. multilib_env() did not take it into account
and assumed glibc's lib64 layout.

That breaks crossdev as it uses multilib_env to extract target
definition. Native builds are unaffected by this change.

Bug: https://bugs.gentoo.org/675954
Bug: https://gcc.gnu.org/PR90077
Bug: https://github.com/gentoo/musl/issues/245
Signed-off-by: Sergei Trofimovich <sly...@gentoo.org>
---
 eclass/multilib.eclass   | 13 ++++++++++++-
 eclass/tests/multilib.sh |  4 ++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
index 63bde5cbb60..8b4a7dacaa3 100644
--- a/eclass/multilib.eclass
+++ b/eclass/multilib.eclass
@@ -294,11 +294,22 @@ get_modname() {
 }
 
 # This is for the toolchain to setup profile variables when pulling in
-# a crosscompiler (and thus they aren't set in the profile)
+# a crosscompiler (and thus they aren't set in the profile).
 multilib_env() {
        local CTARGET=${1:-${CTARGET}}
        local cpu=${CTARGET%%*-}
 
+       if [[ ${CTARGET} = *-musl* ]]; then
+               # musl has no multilib support and can run only in 'lib':
+               # - https://bugs.gentoo.org/675954
+               # - https://gcc.gnu.org/PR90077
+               # - https://github.com/gentoo/musl/issues/245
+               : ${MULTILIB_ABIS=default}
+               : ${DEFAULT_ABI=default}
+               export MULTILIB_ABIS DEFAULT_ABI
+               return
+       fi
+
        case ${cpu} in
                aarch64*)
                        # Not possible to do multilib with aarch64 and a single 
toolchain.
diff --git a/eclass/tests/multilib.sh b/eclass/tests/multilib.sh
index 308c456b98d..68c0dd6e142 100755
--- a/eclass/tests/multilib.sh
+++ b/eclass/tests/multilib.sh
@@ -57,5 +57,9 @@ test-multilib_env \
        "x86_64-pc-linux-gnux32" \
        "x32:x32 amd64 x86" \
        "x32? ( CHOST=x86_64-pc-linux-gnux32 LIBDIR=libx32 CFLAGS=-mx32 
LDFLAGS= ) amd64? ( CHOST=x86_64-pc-linux-gnu LIBDIR=lib64 CFLAGS=-m64 LDFLAGS= 
) x86? ( CHOST=i686-pc-linux-gnu LIBDIR=lib CFLAGS=-m32 LDFLAGS= )"
+test-multilib_env \
+       "x86_64-gentoo-linux-musl" \
+       "default:default" \
+       "default? ( CHOST=x86_64-gentoo-linux-musl LIBDIR=lib CFLAGS= LDFLAGS= 
)"
 
 texit
-- 
2.26.0


Reply via email to