public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion
@ 2020-03-28  9:40 Sergei Trofimovich
  2020-03-28  9:40 ` [gentoo-dev] [PATCH 2/2] multilib.eclass: multilib_env(): set LIBDIR=lib for *-musl* Sergei Trofimovich
  2020-03-28 15:17 ` [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion Mike Gilbert
  0 siblings, 2 replies; 6+ messages in thread
From: Sergei Trofimovich @ 2020-03-28  9:40 UTC (permalink / raw
  To: gentoo-dev; +Cc: Sergei Trofimovich

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 eclass/tests/multilib.sh | 61 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100755 eclass/tests/multilib.sh

diff --git a/eclass/tests/multilib.sh b/eclass/tests/multilib.sh
new file mode 100755
index 00000000000..308c456b98d
--- /dev/null
+++ b/eclass/tests/multilib.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+# Copyright 1999-2020 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+source tests-common.sh
+
+inherit multilib
+
+# Run 'multilib_env' and check what variables it expands to
+test-multilib_env() {
+	local target=$1 exp_abi=$2 exp_vars=" $3"
+	tbegin "expand-target $1"
+
+	# Reset default
+	unset MULTILIB_ABIS
+	unset DEFAULT_ABI
+	CFLAGS_default=
+	LDFLAGS_default=
+	LIBDIR_default=lib
+	CHOST_default=${target}
+	CTARGET_default=${CHOST_default}
+	LIBDIR_default=lib
+
+	multilib_env ${target}
+
+	local actual_abi="${DEFAULT_ABI}:${MULTILIB_ABIS}"
+
+	local actual_vars=""
+	local abi var v
+	for abi in ${MULTILIB_ABIS}; do
+		actual_vars+=" ${abi}? ("
+		for var in CHOST LIBDIR CFLAGS LDFLAGS; do
+			v=${var}_${abi}
+			actual_vars+=" ${var}=${!v}"
+		done
+		actual_vars+=" )"
+	done
+
+	[[ "${exp_abi}" == "${actual_abi}" && "${exp_vars}" == "${actual_vars}" ]]
+
+	if ! tend $? ; then
+		printf '### EXPECTED ABI: %s\n' "${exp_abi}"
+		printf '### ACTUAL   ABI: %s\n' "${actual_abi}"
+		printf '### EXPECTED VARS: %s\n' "${exp_vars}"
+		printf '### ACTUAL   VARS: %s\n' "${actual_vars}"
+	fi
+}
+
+# Pick a few interesting gargets from:
+# $ grep -h -o -R 'CHOST=.*' ../../profiles/ | sort -u
+
+test-multilib_env \
+	"x86_64-pc-linux-gnu" \
+	"amd64:amd64 x86" \
+	"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-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= )"
+
+texit
-- 
2.26.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-dev] [PATCH 2/2] multilib.eclass: multilib_env(): set LIBDIR=lib for *-musl*
  2020-03-28  9:40 [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion Sergei Trofimovich
@ 2020-03-28  9:40 ` Sergei Trofimovich
  2020-03-28 15:19   ` Mike Gilbert
  2020-03-28 15:17 ` [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion Mike Gilbert
  1 sibling, 1 reply; 6+ messages in thread
From: Sergei Trofimovich @ 2020-03-28  9:40 UTC (permalink / raw
  To: gentoo-dev; +Cc: Sergei Trofimovich

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 <slyfox@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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion
  2020-03-28  9:40 [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion Sergei Trofimovich
  2020-03-28  9:40 ` [gentoo-dev] [PATCH 2/2] multilib.eclass: multilib_env(): set LIBDIR=lib for *-musl* Sergei Trofimovich
@ 2020-03-28 15:17 ` Mike Gilbert
  2020-03-28 19:56   ` Sergei Trofimovich
  1 sibling, 1 reply; 6+ messages in thread
From: Mike Gilbert @ 2020-03-28 15:17 UTC (permalink / raw
  To: Gentoo Dev; +Cc: Sergei Trofimovich

On Sat, Mar 28, 2020 at 5:40 AM Sergei Trofimovich <slyfox@gentoo.org> wrote:
>
> Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
> ---
>  eclass/tests/multilib.sh | 61 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
>  create mode 100755 eclass/tests/multilib.sh
>
> diff --git a/eclass/tests/multilib.sh b/eclass/tests/multilib.sh
> new file mode 100755
> index 00000000000..308c456b98d
> --- /dev/null
> +++ b/eclass/tests/multilib.sh
> @@ -0,0 +1,61 @@
> +#!/bin/bash
> +# Copyright 1999-2020 Gentoo Foundation

This should say "Copyright 2020 Gentoo Authors".

> +# Distributed under the terms of the GNU General Public License v2
> +
> +source tests-common.sh
> +
> +inherit multilib
> +
> +# Run 'multilib_env' and check what variables it expands to
> +test-multilib_env() {
> +       local target=$1 exp_abi=$2 exp_vars=" $3"
> +       tbegin "expand-target $1"
> +
> +       # Reset default
> +       unset MULTILIB_ABIS
> +       unset DEFAULT_ABI
> +       CFLAGS_default=
> +       LDFLAGS_default=
> +       LIBDIR_default=lib
> +       CHOST_default=${target}
> +       CTARGET_default=${CHOST_default}
> +       LIBDIR_default=lib
> +
> +       multilib_env ${target}
> +
> +       local actual_abi="${DEFAULT_ABI}:${MULTILIB_ABIS}"
> +
> +       local actual_vars=""
> +       local abi var v
> +       for abi in ${MULTILIB_ABIS}; do
> +               actual_vars+=" ${abi}? ("
> +               for var in CHOST LIBDIR CFLAGS LDFLAGS; do
> +                       v=${var}_${abi}
> +                       actual_vars+=" ${var}=${!v}"
> +               done
> +               actual_vars+=" )"
> +       done
> +
> +       [[ "${exp_abi}" == "${actual_abi}" && "${exp_vars}" == "${actual_vars}" ]]
> +
> +       if ! tend $? ; then
> +               printf '### EXPECTED ABI: %s\n' "${exp_abi}"
> +               printf '### ACTUAL   ABI: %s\n' "${actual_abi}"
> +               printf '### EXPECTED VARS: %s\n' "${exp_vars}"
> +               printf '### ACTUAL   VARS: %s\n' "${actual_vars}"
> +       fi
> +}
> +
> +# Pick a few interesting gargets from:

Probably a typo: s/gargets/targets/

> +# $ grep -h -o -R 'CHOST=.*' ../../profiles/ | sort -u
> +
> +test-multilib_env \
> +       "x86_64-pc-linux-gnu" \
> +       "amd64:amd64 x86" \
> +       "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-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= )"
> +
> +texit
> --
> 2.26.0
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] [PATCH 2/2] multilib.eclass: multilib_env(): set LIBDIR=lib for *-musl*
  2020-03-28  9:40 ` [gentoo-dev] [PATCH 2/2] multilib.eclass: multilib_env(): set LIBDIR=lib for *-musl* Sergei Trofimovich
@ 2020-03-28 15:19   ` Mike Gilbert
  2020-03-28 19:56     ` Sergei Trofimovich
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Gilbert @ 2020-03-28 15:19 UTC (permalink / raw
  To: Gentoo Dev; +Cc: Sergei Trofimovich

On Sat, Mar 28, 2020 at 5:40 AM Sergei Trofimovich <slyfox@gentoo.org> wrote:
>
> 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 <slyfox@gentoo.org>

Please also update the copyright notice in multilib.eclass while you're at it.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion
  2020-03-28 15:17 ` [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion Mike Gilbert
@ 2020-03-28 19:56   ` Sergei Trofimovich
  0 siblings, 0 replies; 6+ messages in thread
From: Sergei Trofimovich @ 2020-03-28 19:56 UTC (permalink / raw
  To: Mike Gilbert; +Cc: Gentoo Dev

On Sat, 28 Mar 2020 11:17:42 -0400
Mike Gilbert <floppym@gentoo.org> wrote:

> > --- /dev/null
> > +++ b/eclass/tests/multilib.sh
> > @@ -0,0 +1,61 @@
> > +#!/bin/bash
> > +# Copyright 1999-2020 Gentoo Foundation  
> 
> This should say "Copyright 2020 Gentoo Authors".
...
> > +# Pick a few interesting gargets from:  
> 
> Probably a typo: s/gargets/targets/

God point! Tweaked both as:
    https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1a687fd280c3d33cbf7ef99cd6f96fda95039c75

-- 

  Sergei


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] [PATCH 2/2] multilib.eclass: multilib_env(): set LIBDIR=lib for *-musl*
  2020-03-28 15:19   ` Mike Gilbert
@ 2020-03-28 19:56     ` Sergei Trofimovich
  0 siblings, 0 replies; 6+ messages in thread
From: Sergei Trofimovich @ 2020-03-28 19:56 UTC (permalink / raw
  To: Mike Gilbert; +Cc: Gentoo Dev

On Sat, 28 Mar 2020 11:19:29 -0400
Mike Gilbert <floppym@gentoo.org> wrote:

> On Sat, Mar 28, 2020 at 5:40 AM Sergei Trofimovich <slyfox@gentoo.org> wrote:
> >
> > 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 <slyfox@gentoo.org>  
> 
> Please also update the copyright notice in multilib.eclass while you're at it.

Updated as:
    https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1a687fd280c3d33cbf7ef99cd6f96fda95039c75

-- 

  Sergei


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-28 19:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-28  9:40 [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion Sergei Trofimovich
2020-03-28  9:40 ` [gentoo-dev] [PATCH 2/2] multilib.eclass: multilib_env(): set LIBDIR=lib for *-musl* Sergei Trofimovich
2020-03-28 15:19   ` Mike Gilbert
2020-03-28 19:56     ` Sergei Trofimovich
2020-03-28 15:17 ` [gentoo-dev] [PATCH 1/2] eclass/tests: add basic tests for multilib_env() expansion Mike Gilbert
2020-03-28 19:56   ` Sergei Trofimovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox