From patchwork Thu Jul 20 13:28:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1810465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=F3Zh3QeM; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R6D7z07YGz1yYm for ; Thu, 20 Jul 2023 23:30:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDC14385DC1A for ; Thu, 20 Jul 2023 13:30:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDC14385DC1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689859804; bh=rd5eo1EYa5ZP1XpTJjQuo/XzI+30C8uzY4d4QiNL7fc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=F3Zh3QeM7uCI/Un1PdFz0bWyRurMyFjHiZH0tUyrEI0jW153w/OnfZD1Uxo1MywN5 Xj/GU706uGzqJig1l+A4JCRVK4VPkM4jW3wOimMCRYUWjOs2wnUOs4h4xTemuJtwUe eBSiU7azHlQuGjt2m+39CyqIBVUmu5s11rmiy3DU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 60970385E010 for ; Thu, 20 Jul 2023 13:29:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60970385E010 Received: from stargazer.. (unknown [115.155.1.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 5CF316599C; Thu, 20 Jul 2023 09:29:20 -0400 (EDT) To: gcc-patches@gcc.gnu.org Cc: Lulu Cheng , WANG Xuerui , Xi Ruoyao Subject: [PATCH] LoongArch: Allow using --with-arch=native if host CPU is LoongArch Date: Thu, 20 Jul 2023 21:28:02 +0800 Message-ID: <20230720132910.210043-1-xry111@xry111.site> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Gcc-patches From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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}" \