From patchwork Thu Sep 5 07:29:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 1981115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=Q/fqWxEC; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzrcR10Htz1yXY for ; Thu, 5 Sep 2024 17:30:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 335F5384DEF5 for ; Thu, 5 Sep 2024 07:30:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 335F5384DEF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1725521429; bh=p0g2RT+BUyCuEue8WtNy2M+976MlwePMSibXVr0jaHM=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Q/fqWxECsZvWCPWVBCBK//diq99IQR+0CtL4KX7f767r9JuZagYgpmo/YAh4kRgLa n619mn/CFxuzcIbCw3shOFtI6t8tZxoKLkFBbDOzM+oYOS7PMbESrrIP2AseSCX+jb 6565SZQS5dqcZELzOV5JW6D1uD5QQsuvkvMGZO3o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by sourceware.org (Postfix) with ESMTPS id DC4723860C34 for ; Thu, 5 Sep 2024 07:29:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC4723860C34 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC4723860C34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725521400; cv=none; b=XQaJqUqQqlmudzb8hItej9lDzfQdsKibO34wZF1Djp4koYTu3siyBddnGewQt29gPL6bGxi6vRVUCHZ36THtfkvDVw9qlABrVlvLl/yKO11bqu/T5JTztqM7qNq5d4yrZk4JLbUHVL9jzRYa9U+XZeuyrzYL/trzBnV4S1BfPRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725521400; c=relaxed/simple; bh=Kw9d1DAxHdTrJIgqXKW2klQjXThyyaqloqrpeyeM57Q=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=lMFeve0ruvW/kqLcZqBlJMcbEoLvAZFmPk2xBjkGHTX2jWgt9wK8RdpQm7Yf6pHxrZ0uVWB+0dll3GZ1M+kBClAQbHodC2cYk55ODrkrFd/S841muCHFupBQTfhpfX01rMZdBxA2iVprwB8FZAk4mY7vy8xOvyM4JcoIfsnvYVg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-206bd1c6ccdso4432675ad.3 for ; Thu, 05 Sep 2024 00:29:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725521396; x=1726126196; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=p0g2RT+BUyCuEue8WtNy2M+976MlwePMSibXVr0jaHM=; b=QAHy9WrlDVWPKOs3Y7pGL5Qsb+PJ+twM3JEAJMwztwafGMvsRHMQT7f3Wyh7+8BMk/ 6p9NOVL6zY7O6qSGcw3JAM6PFb9I6OWjYxYh3TIh48GWrtuIF9AQF57hnl7QoqjlglU7 LS/ouGtf0s8POCTBSupB1pFQAHgqivaXehcT/IGKsa9wLRRgzSdj76bm07yJwdXJ2oHP 0dNzDYU7NW1vDbwbaCiGwzW/gkhFQdB92ZbuiJ5Z55LM8kfcvC1YZynIxC8fzrSIy/o4 AYDg0SdQY/YxEKKA4Kh4JQE4lvjAAWHGfmePGQuHVbdVPbtLkfJdln18jxacBLE34Cfz NumA== X-Gm-Message-State: AOJu0YyUHJae5cdFY1aEEsXjtIYeeU719OOFIlUSsEL3A5U57DGJtT4V W6ghMT5+0W534sI9DsUMi9LyXWvkx2ijJqhn2cGpAV5Lo3FwYRJCnOHqNw== X-Google-Smtp-Source: AGHT+IEa5NyYdTZ/96jQ/p4+cbML+x41legh1WHec7bBQohrkIFsaA3rCMycIzXPzJlaT3jjzGskxw== X-Received: by 2002:a17:903:32ce:b0:202:2b3e:28d0 with SMTP id d9443c01a7336-2054bc9672cmr184492795ad.8.1725521396521; Thu, 05 Sep 2024 00:29:56 -0700 (PDT) Received: from localhost.localdomain ([194.169.55.179]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206ae94e441sm23438335ad.79.2024.09.05.00.29.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 05 Sep 2024 00:29:56 -0700 (PDT) From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, andrew@sifive.com, jim.wilson.gcc@gmail.com, YunQiang Su Subject: [PATCH] RISC-V: Lookup reversely in riscv_select_multilib_by_abi Date: Thu, 5 Sep 2024 15:29:47 +0800 Message-Id: <20240905072947.72943-1-syq@gcc.gnu.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: YunQiang Su When use --print-multilib-os-dir, gcc outputs different value with full -march option and the base one only. $ ./gcc/xgcc --print-multilib-os-dir -mabi=lp64d -march=rv64gc lib64/lp64d $ ./gcc/xgcc --print-multilib-os-dir -mabi=lp64d -march=rv64gc_zba . The reason is that in multilib.h, the fallback value of multilib is listed as the 1st one in `multilib_raw[]`. gcc * common/config/riscv/riscv-common.cc(riscv_select_multilib_by_abi): look up reversely as the fallback path is listed as the 1st one. --- gcc/common/config/riscv/riscv-common.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 62c6e1dab1f..2c1ce7fc7cb 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -2079,7 +2079,7 @@ riscv_select_multilib_by_abi ( const std::string &riscv_current_abi_str, const std::vector &multilib_infos) { - for (size_t i = 0; i < multilib_infos.size (); ++i) + for (ssize_t i = multilib_infos.size (); i >= 0; --i) if (riscv_current_abi_str == multilib_infos[i].abi_str) return xstrdup (multilib_infos[i].path.c_str ());