public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Allow using --with-arch=native if host CPU is LoongArch
@ 2023-07-20 13:28 Xi Ruoyao
  2023-07-22  9:11 ` chenglulu
  0 siblings, 1 reply; 2+ messages in thread
From: Xi Ruoyao @ 2023-07-20 13:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Lulu Cheng, WANG Xuerui, Xi Ruoyao

If the host triple and the target triple are different but the host is
LoongArch, in some cases --with-arch=native can be useful.  For example,
if we are bootstrapping a loongarch64-linux-musl toolchain on a
Glibc-based system and we don't intend to use the toolchain on other
machines, we can use

    ../gcc/configure --{build,host}=loongarch64-linux-gnu \
                     --target=loongarch64-linux-musl --with-arch=native

Relax the check in config.gcc to allow such configurations.

gcc/ChangeLog:

	* config.gcc [target=loongarch*-*-*, with_arch=native]: Allow
	building cross compiler if the host CPU is LoongArch.
---

Tested on x86_64-linux-gnu (building a cross compiler targeting
LoongArch --with-arch=native still rejected) and loongarch64-linux-gnu
(building a cross compiler targeting loongarch64-linux-musl allowed).
Ok for trunk?

 gcc/config.gcc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 1446eb2b3ca..146bca22a38 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4939,10 +4939,13 @@ case "${target}" in
 		case ${with_arch} in
 		"" | loongarch64 | la464) ;; # OK, append here.
 		native)
-			if test x${host} != x${target}; then
+			case ${host} in
+			loongarch*) ;; # OK
+			*)
 				echo "--with-arch=native is illegal for cross-compiler." 1>&2
 				exit 1
-			fi
+				;;
+			esac
 			;;
 		"")
 			echo "Please set a default value for \${with_arch}" \
-- 
2.41.0


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

* Re: [PATCH] LoongArch: Allow using --with-arch=native if host CPU is LoongArch
  2023-07-20 13:28 [PATCH] LoongArch: Allow using --with-arch=native if host CPU is LoongArch Xi Ruoyao
@ 2023-07-22  9:11 ` chenglulu
  0 siblings, 0 replies; 2+ messages in thread
From: chenglulu @ 2023-07-22  9:11 UTC (permalink / raw)
  To: Xi Ruoyao, gcc-patches


在 2023/7/20 下午9:28, Xi Ruoyao 写道:
> If the host triple and the target triple are different but the host is
> LoongArch, in some cases --with-arch=native can be useful.  For example,
> if we are bootstrapping a loongarch64-linux-musl toolchain on a
> Glibc-based system and we don't intend to use the toolchain on other
> machines, we can use
>
>      ../gcc/configure --{build,host}=loongarch64-linux-gnu \
>                       --target=loongarch64-linux-musl --with-arch=native
>
> Relax the check in config.gcc to allow such configurations.
>
> gcc/ChangeLog:
>
> 	* config.gcc [target=loongarch*-*-*, with_arch=native]: Allow
> 	building cross compiler if the host CPU is LoongArch.
> ---
>
> Tested on x86_64-linux-gnu (building a cross compiler targeting
> LoongArch --with-arch=native still rejected) and loongarch64-linux-gnu
> (building a cross compiler targeting loongarch64-linux-musl allowed).
> Ok for trunk?


Hi, Ruoyao:

  I'm sorry that some things at home are late, can this usage scenario 
be described in detail? I didn't really understand that.

>
>   gcc/config.gcc | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 1446eb2b3ca..146bca22a38 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -4939,10 +4939,13 @@ case "${target}" in
>   		case ${with_arch} in
>   		"" | loongarch64 | la464) ;; # OK, append here.
>   		native)
> -			if test x${host} != x${target}; then
> +			case ${host} in
> +			loongarch*) ;; # OK
> +			*)
>   				echo "--with-arch=native is illegal for cross-compiler." 1>&2
>   				exit 1
> -			fi
> +				;;
> +			esac
>   			;;
>   		"")
>   			echo "Please set a default value for \${with_arch}" \


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

end of thread, other threads:[~2023-07-22  9:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 13:28 [PATCH] LoongArch: Allow using --with-arch=native if host CPU is LoongArch Xi Ruoyao
2023-07-22  9:11 ` chenglulu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).