From patchwork Thu Feb 1 21:54:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1894205 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=xry111.site header.i=@xry111.site header.a=rsa-sha256 header.s=default header.b=L39emtqR; 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 4TQt5k5qcyz23g7 for ; Fri, 2 Feb 2024 08:56:25 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7064F385841C for ; Thu, 1 Feb 2024 21:56:23 +0000 (GMT) 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 5C35A385829A for ; Thu, 1 Feb 2024 21:55:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C35A385829A Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C35A385829A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.208.246.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706824549; cv=none; b=i2W0eQidbGr8/l7ndx8p5s+cOWvslnjtLd2hZH+iXXoHJBlSWWbsc+7tz+9OOeb3zYvov5RTcGG/suaAQGQ4zFuUvy7D0Cd4LpE0LsKikOa4SNhMpDzTd3Qlz9qlqC15366cd1wtpTS6dEOoDKyPcj/NTaOlWTY2TSr+x7Xp3Ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706824549; c=relaxed/simple; bh=hjtZwj6udBbiRqGYomdoKUGJhbIpPtPkiyK159WlB0A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kb6a8rqINhoG7lCbhqTakbEgukPFkWsKOIXxU8UU5eS4YzpkS1YUQZQlgHPKUvQqCbnHHribqoV/dFoiBC7aePlTCDGKtphQIImMJI1qQp6n/MD8jUqZ2/NYugAuP4KMcvPgk37dWzlzTJLbCUOMCoBfqg7vLTMgwjs2ZEnSVkw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1706824545; bh=hjtZwj6udBbiRqGYomdoKUGJhbIpPtPkiyK159WlB0A=; h=From:To:Cc:Subject:Date:From; b=L39emtqRrlHn2HwzrjcD03t+ruYbC5fBhYFSOcS+N6/u0V3qTteQBRaMKykk+mPNT X+aaT5oLxBTkEmCC5wxbonc2gnzyKh2OBQuVgrw28FAcQdVd0QqMAePEdJq273hzkN ebobNer+amokJUw+teiCdzmNsrYOWBUsZUpBZsGo= Received: from stargazer.. (unknown [IPv6:240e:358:11d4:5700:dc73:854d:832e:4]) (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 12F5B65F19; Thu, 1 Feb 2024 16:55:41 -0500 (EST) From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: chenglulu , i@xen0n.name, xuchenghua@loongson.cn, Xi Ruoyao Subject: [PATCH] LoongArch: Fix an ODR violation Date: Fri, 2 Feb 2024 05:54:13 +0800 Message-ID: <20240201215532.90520-1-xry111@xry111.site> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.1 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, 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 When bootstrapping GCC 14 --with-build-config=bootstrap-lto, an ODR violation is detected: ../../gcc/config/loongarch/loongarch-opts.cc:57: warning: 'abi_minimal_isa' violates the C++ One Definition Rule [-Wodr] 57 | abi_minimal_isa[N_ABI_BASE_TYPES][N_ABI_EXT_TYPES]; ../../gcc/config/loongarch/loongarch-def.cc:186: note: 'abi_minimal_isa' was previously declared here 186 | abi_minimal_isa = array, ../../gcc/config/loongarch/loongarch-def.cc:186: note: code may be misoptimized unless '-fno-strict-aliasing' is used Fix it by adding a proper declaration of abi_minimal_isa into loongarch-def.h and remove the ODR-violating local declaration in loongarch-opts.cc. gcc/ChangeLog: * config/loongarch/loongarch-def.h (abi_minimal_isa): Declare. * config/loongarch/loongarch-opts.cc (abi_minimal_isa): Remove the ODR-violating locale declaration. --- Bootstrapped on loongarch64-linux-gnu. Not fully regtested but it should be an obvious fix. Ok for trunk? gcc/config/loongarch/loongarch-def.h | 3 +++ gcc/config/loongarch/loongarch-opts.cc | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/loongarch/loongarch-def.h b/gcc/config/loongarch/loongarch-def.h index a1237ecf1fd..2dbf006d013 100644 --- a/gcc/config/loongarch/loongarch-def.h +++ b/gcc/config/loongarch/loongarch-def.h @@ -203,5 +203,8 @@ extern loongarch_def_array loongarch_cpu_align; extern loongarch_def_array loongarch_cpu_rtx_cost_data; +extern loongarch_def_array< + loongarch_def_array, + N_ABI_BASE_TYPES> abi_minimal_isa; #endif /* LOONGARCH_DEF_H */ diff --git a/gcc/config/loongarch/loongarch-opts.cc b/gcc/config/loongarch/loongarch-opts.cc index b87299513c9..7eeac43ed2f 100644 --- a/gcc/config/loongarch/loongarch-opts.cc +++ b/gcc/config/loongarch/loongarch-opts.cc @@ -53,8 +53,6 @@ static const int tm_multilib_list[] = { TM_MULTILIB_LIST }; static int enabled_abi_types[N_ABI_BASE_TYPES][N_ABI_EXT_TYPES] = { 0 }; #define isa_required(ABI) (abi_minimal_isa[(ABI).base][(ABI).ext]) -extern "C" const struct loongarch_isa -abi_minimal_isa[N_ABI_BASE_TYPES][N_ABI_EXT_TYPES]; static inline int is_multilib_enabled (struct loongarch_abi abi)