public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] toolchain-funcs.eclass: include riscv bitness in tc-arch
@ 2021-05-02 22:22 fedora.dm0
  2021-05-03  8:41 ` Sergei Trofimovich
  0 siblings, 1 reply; 3+ messages in thread
From: fedora.dm0 @ 2021-05-02 22:22 UTC (permalink / raw
  To: gentoo-dev; +Cc: toolchain

This makes tc-arch identify RISC-V systems as either "riscv64" or
"riscv32".  It will still return "riscv" for the kernel arch or if
bitness is not given in the host triplet.

This fixes the expected values of cpu_family in meson projects:
https://mesonbuild.com/Reference-tables.html#cpu-families

Signed-off-by: David Michael <fedora.dm0@gmail.com>
---

Hi,

When building systemd from Git, it now relies on the "stable" cpu_family
value for riscv64[0].  Meson gets this value from tc-arch.  From a quick
grep, it looked like the only place that compared tc-arch output with
"riscv" was toolchain.eclass, but there may be some other subtle issue I
haven't encountered.  Does this look okay to apply?

Thanks.

David

[0] https://github.com/systemd/systemd/commit/a00ff2e1b596f0d08d32b8ca9cefe8aca1212604

 eclass/toolchain-funcs.eclass | 10 +++++++++-
 eclass/toolchain.eclass       |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 267cf5cfce3..5dd6dcbd658 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -687,7 +687,15 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
 				echo ppc
 			fi
 			;;
-		riscv*)		echo riscv;;
+		riscv*)
+			if [[ ${type} != "kern" && ${host} == riscv32* ]] ; then
+				echo riscv32
+			elif [[ ${type} != "kern" && ${host} == riscv64* ]] ; then
+				echo riscv64
+			else
+				echo riscv
+			fi
+			;;
 		s390*)		echo s390;;
 		score*)		echo score;;
 		sh64*)		ninj sh64 sh;;
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index f41ce22c591..b1d2e671917 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1084,7 +1084,7 @@ toolchain_src_configure() {
 		# https://gcc.gnu.org/PR93157
 		[[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
 		;;
-	riscv)
+	riscv*)
 		# Add --with-abi flags to set default ABI
 		confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
 		;;
-- 
2.26.3



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

* Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: include riscv bitness in tc-arch
  2021-05-02 22:22 [gentoo-dev] [PATCH] toolchain-funcs.eclass: include riscv bitness in tc-arch fedora.dm0
@ 2021-05-03  8:41 ` Sergei Trofimovich
  2021-05-03 12:56   ` David Michael
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Trofimovich @ 2021-05-03  8:41 UTC (permalink / raw
  To: fedora.dm0; +Cc: gentoo-dev, toolchain

On Sun, 02 May 2021 18:22:43 -0400
fedora.dm0@gmail.com wrote:

> This makes tc-arch identify RISC-V systems as either "riscv64" or
> "riscv32".  It will still return "riscv" for the kernel arch or if
> bitness is not given in the host triplet.

tc-arch returns portage's ARCH= value based on passed tuple.
There are no ARCH=riscv32 or ARCH=riscv64 in Gentoo. Only ARCH=riscv.

You probably need to map gentoo's ABI USE to upstream's ABI flag.
But it's not clear from your description what effect you intend to achieve.

> This fixes the expected values of cpu_family in meson projects:
> https://mesonbuild.com/Reference-tables.html#cpu-families

I'm not sure what meson's `cpu_family` is. Is it something that should
affect -march=/-mabi=? Please state your intent explicitly. The fix does
not look correct.

> Signed-off-by: David Michael <fedora.dm0@gmail.com>
> ---
> 
> Hi,
> 
> When building systemd from Git, it now relies on the "stable" cpu_family
> value for riscv64[0].  Meson gets this value from tc-arch.  From a quick
> grep, it looked like the only place that compared tc-arch output with
> "riscv" was toolchain.eclass, but there may be some other subtle issue I
> haven't encountered.  Does this look okay to apply?
> 
> Thanks.
> 
> David
> 
> [0] https://github.com/systemd/systemd/commit/a00ff2e1b596f0d08d32b8ca9cefe8aca1212604
> 
>  eclass/toolchain-funcs.eclass | 10 +++++++++-
>  eclass/toolchain.eclass       |  2 +-
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
> index 267cf5cfce3..5dd6dcbd658 100644
> --- a/eclass/toolchain-funcs.eclass
> +++ b/eclass/toolchain-funcs.eclass
> @@ -687,7 +687,15 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
>  				echo ppc
>  			fi
>  			;;
> -		riscv*)		echo riscv;;
> +		riscv*)
> +			if [[ ${type} != "kern" && ${host} == riscv32* ]] ; then
> +				echo riscv32
> +			elif [[ ${type} != "kern" && ${host} == riscv64* ]] ; then
> +				echo riscv64
> +			else
> +				echo riscv
> +			fi
> +			;;
>  		s390*)		echo s390;;
>  		score*)		echo score;;
>  		sh64*)		ninj sh64 sh;;
> diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
> index f41ce22c591..b1d2e671917 100644
> --- a/eclass/toolchain.eclass
> +++ b/eclass/toolchain.eclass
> @@ -1084,7 +1084,7 @@ toolchain_src_configure() {
>  		# https://gcc.gnu.org/PR93157
>  		[[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
>  		;;
> -	riscv)
> +	riscv*)
>  		# Add --with-abi flags to set default ABI
>  		confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
>  		;;
> -- 
> 2.26.3
> 
> 


-- 

  Sergei


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

* Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: include riscv bitness in tc-arch
  2021-05-03  8:41 ` Sergei Trofimovich
@ 2021-05-03 12:56   ` David Michael
  0 siblings, 0 replies; 3+ messages in thread
From: David Michael @ 2021-05-03 12:56 UTC (permalink / raw
  To: Sergei Trofimovich; +Cc: gentoo-dev, toolchain

On Mon, May 3, 2021 at 4:41 AM Sergei Trofimovich <slyfox@gentoo.org> wrote:
> On Sun, 02 May 2021 18:22:43 -0400 fedora.dm0@gmail.com wrote:
> > This makes tc-arch identify RISC-V systems as either "riscv64" or
> > "riscv32".  It will still return "riscv" for the kernel arch or if
> > bitness is not given in the host triplet.
>
> tc-arch returns portage's ARCH= value based on passed tuple.
> There are no ARCH=riscv32 or ARCH=riscv64 in Gentoo. Only ARCH=riscv.

Okay, then I will remap it directly in meson instead.

Thanks.

David


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

end of thread, other threads:[~2021-05-03 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-02 22:22 [gentoo-dev] [PATCH] toolchain-funcs.eclass: include riscv bitness in tc-arch fedora.dm0
2021-05-03  8:41 ` Sergei Trofimovich
2021-05-03 12:56   ` David Michael

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