public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: gcc-patches@gcc.gnu.org
Cc: Lulu Cheng <chenglulu@loongson.cn>, WANG Xuerui <i@xen0n.name>,
	Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH] LoongArch: Allow using --with-arch=native if host CPU is LoongArch
Date: Thu, 20 Jul 2023 21:28:02 +0800	[thread overview]
Message-ID: <20230720132910.210043-1-xry111@xry111.site> (raw)

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


             reply	other threads:[~2023-07-20 13:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 13:28 Xi Ruoyao [this message]
2023-07-22  9:11 ` chenglulu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230720132910.210043-1-xry111@xry111.site \
    --to=xry111@xry111.site \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).