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: 195480 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp45874dyc; Thu, 1 Feb 2024 13:56:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2wlLp+onse3fteBphOCD4PN3uZmloRwrYDjDFPXfloCfrrVaBF8as+u5nMVNgjQ6RkS6f X-Received: by 2002:ac8:7e88:0:b0:42b:ec86:2477 with SMTP id w8-20020ac87e88000000b0042bec862477mr663934qtj.3.1706824606400; Thu, 01 Feb 2024 13:56:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706824606; cv=pass; d=google.com; s=arc-20160816; b=kpCSBhgHyPg0E9wx1P3O0JXvqM0LYmgdnACpdygz5SumuY07wBChSHcTJ7X4FPezsA 6Bd1nsUcI/LlDCO4US7UOGa1kg2CYZu3XklmRN7PrCGDkQIBFv7fa4+YfLUtOtP8qVV0 +ezIXWYRod7QUAF9R8hm7QObbNccxz7MFRHPv96NUyUZEL1RZ0lLyEGnSFPRRNlCJ3A8 oXjYIGw1ef9q0MqfQSbXPX0i6VM3FZL5qLS8BjBnz8d6+UGvbmLpJV1LNUS1xcE3S2N6 tLvJR+f3uJOWfHIyV5zCI0vG0gmNokWU4Shs2vOYJDczZYE3/25gFYvpB/6TUEAa7/uT j6WA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=HaitJcvK7HFoW9j+/VOuaRJfGRMrwToE9RmrLaWeptQ=; fh=Ke3iM2G5MhYYdaCQxLwxe51KFDDQ+lsImZbZEtBev/Q=; b=nknTGxf6yLv4p2WTBk8L29wN4FBRw5gwoQ57Md4kLjGofhrYIcLuPoZj601WCzwxWx f4GB8g/0m04yRqo1Q7TJaUcpgY8XK3gYYHkTOhUl4ClJD6Kd4FUbCWt5DWdqLDhFHhow 6k9gaoBdT4ac9zecuLjg+h3Bil27JBfy9pJXxw/pP/37vWR/mpXLq8xBmdnxNyZTbxxU 4HPifouA6YLSjUm2t+pQkVgAUGBwmz60XY/B7OhKlZo1tGmF9i8R0jlBubaycQDqxRBD Lo1k19427Jz35EtMTCRO+A/E0e8QKDqK5EQ40xNBBYE9oLixsHq719CIydbomB2yeF3V D+OQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=L39emtqR; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site X-Forwarded-Encrypted: i=1; AJvYcCVHnB+v4kTxd1aJMKH5WDK7sw5aqxJznemtXqi4faFQn43+G49Y81rhTnkpGOkWDfNevYoDKSehfT4Gqzl5kw91Kl7Kzg== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m10-20020a05622a054a00b0042bfbfef6e8si449825qtx.553.2024.02.01.13.56.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 13:56:46 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=L39emtqR; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2135B3858018 for ; Thu, 1 Feb 2024 21:56:46 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789735318789387768 X-GMAIL-MSGID: 1789735318789387768 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)