From patchwork Mon Feb 13 10:38:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1741580 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=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=fZyHqHkM; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.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 4PFgng5gpDz23qt for ; Mon, 13 Feb 2023 21:39:34 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89233385B520 for ; Mon, 13 Feb 2023 10:39:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89233385B520 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676284772; bh=5BjmNdOmwSePuoYVvO33BZCHqizEXKc0s3JCiLvz+d4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=fZyHqHkMzya+ltxu3obdPCgFRwFUyCKQsKCzh6QfQBFsjwF91UEQyQlpLnXslkqE4 va1XGL+aDuSBPON4Td4d+HVn8Bpcx96mBAA6vns/GIykzuR1WcgnCoK6tuEv54H20x bcYbLkK1LqcZHnqWi1FY2TWfVE4RkmK4uCMpX93I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 2338E3858C66 for ; Mon, 13 Feb 2023 10:39:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2338E3858C66 Received: from stargazer.. (unknown [IPv6:240e:457:1120:3e45:ab8b:94b7:8043:a088]) (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 93561668A4; Mon, 13 Feb 2023 05:39:05 -0500 (EST) To: gcc-patches@gcc.gnu.org Cc: WANG Xuerui , Lulu Cheng , Chenghua Xu , Xi Ruoyao Subject: [PATCH] LoongArch: Fix multiarch tuple canonization Date: Mon, 13 Feb 2023 18:38:53 +0800 Message-Id: <20230213103853.502212-1-xry111@xry111.site> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP 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" Multiarch tuple will be coded in file or directory names in multiarch-aware distros, so one ABI should have only one multiarch tuple. For example, "--target=loongarch64-linux-gnu --with-abi=lp64s" and "--target=loongarch64-linux-gnusf" should both set multiarch tuple to "loongarch64-linux-gnusf". Before this commit, "--target=loongarch64-linux-gnu --with-abi=lp64s --disable-multilib" will produce wrong result (loongarch64-linux-gnu). A recent LoongArch psABI revision mandates "loongarch64-linux-gnu" to be used for -mabi=lp64d (instead of "loongarch64-linux-gnuf64") for some non-technical reason [1]. Note that we cannot make "loongarch64-linux-gnuf64" an alias for "loongarch64-linux-gnu" because to implement such an alias, we must create thousands of symlinks in the distro and doing so would be completely unpractical. This commit also aligns GCC with the revision. Tested by building cross compilers with --enable-multiarch and multiple combinations of --target=loongarch64-linux-gnu*, --with-abi=lp64{s,f,d}, and --{enable,disable}-multilib; and run "xgcc --print-multiarch" then manually verify the result with eyesight. Ok for trunk and backport to releases/gcc-12? [1]: https://github.com/loongson/LoongArch-Documentation/pull/80 gcc/ChangeLog: * config.gcc (triplet_abi): Set its value based on $with_abi, instead of $target. (la_canonical_triplet): Set it after $triplet_abi is set correctly. * config/loongarch/t-linux (MULTILIB_OSDIRNAMES): Make the multiarch tuple for lp64d "loongarch64-linux-gnu" (without "f64" suffix). --- gcc/config.gcc | 14 +++++++------- gcc/config/loongarch/t-linux | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index 067720ac795..c070e6ecd2e 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4889,20 +4889,16 @@ case "${target}" in case ${target} in loongarch64-*-*-*f64) abi_pattern="lp64d" - triplet_abi="f64" ;; loongarch64-*-*-*f32) abi_pattern="lp64f" - triplet_abi="f32" ;; loongarch64-*-*-*sf) abi_pattern="lp64s" - triplet_abi="sf" ;; loongarch64-*-*-*) abi_pattern="lp64[dfs]" abi_default="lp64d" - triplet_abi="" ;; *) echo "Unsupported target ${target}." 1>&2 @@ -4923,9 +4919,6 @@ case "${target}" in ;; esac - la_canonical_triplet="loongarch64-${triplet_os}${triplet_abi}" - - # Perform initial sanity checks on --with-* options. case ${with_arch} in "" | loongarch64 | la464) ;; # OK, append here. @@ -4996,6 +4989,13 @@ case "${target}" in ;; esac + case ${with_abi} in + "lp64d") triplet_abi="";; + "lp64f") triplet_abi="f32";; + "lp64s") triplet_abi="sf";; + esac + la_canonical_triplet="loongarch64-${triplet_os}${triplet_abi}" + # Set default value for with_abiext (internal) case ${with_abiext} in "") diff --git a/gcc/config/loongarch/t-linux b/gcc/config/loongarch/t-linux index 131c45fdced..e40da179203 100644 --- a/gcc/config/loongarch/t-linux +++ b/gcc/config/loongarch/t-linux @@ -40,7 +40,7 @@ ifeq ($(filter LA_DISABLE_MULTILIB,$(tm_defines)),) MULTILIB_OSDIRNAMES = \ mabi.lp64d=../lib64$\ - $(call if_multiarch,:loongarch64-linux-gnuf64) + $(call if_multiarch,:loongarch64-linux-gnu) MULTILIB_OSDIRNAMES += \ mabi.lp64f=../lib64/f32$\