From patchwork Tue Mar 26 13:24:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 1916147 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=F7HKInzV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4V3rCB1c13z1yWr for ; Wed, 27 Mar 2024 00:25:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84A17385841D for ; Tue, 26 Mar 2024 13:25:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 1B8E33858D38 for ; Tue, 26 Mar 2024 13:25:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B8E33858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1B8E33858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711459503; cv=none; b=txZ1TjHoY57C7T+2z2oUTtF2yd3wI9l1A7PA8jCu8saTgcv+MFO5G0rJCcaNEmZHixQHvQKpnb5JUI/TSmEdRGHSAStIrXkYP9kDUvchhy7KGlHfS0vwbdfuQcYKx+k6qBTZQRTJlxNZL0pXJgM47eAOnDL6c1tx5FBRiO/2uu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711459503; c=relaxed/simple; bh=bfx3mDt7ZajKbqVHTyGzAXcJQ+Lg9fmHn7LCoZtweHk=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=PoyVblupqG5Ucjn9ZD+1G9eEnwhz0YV8S8l3xWPwPT01aTWv1dguRrXCD0oXOUCamoWoiynUfDyzICIiu3M0xV/o9/QB9mAueztu1JCx+iS00b4T+6FkWXvgQaFvo24/Cn6Hsof0fIjd+XDp7OkZeNZLZS27xeXx2MHAt0d8KLU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-53fa455cd94so3676116a12.2 for ; Tue, 26 Mar 2024 06:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711459500; x=1712064300; darn=gcc.gnu.org; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=iVlniqMpzpzGu8TUSK+9bbtchEpFgk41MMoF1Ww4U4o=; b=F7HKInzVBdcOsBjrF43naM62zdoZKpffXSLbrpuXPiTnki6NGYrrVZVAqVYXYK9dJV 1E9qhS8KXAIulTYHdO/2mQ1Amrp/hkJne8lyWAf3oZyG+cUqZ0sfAxF0t7eoIrg7hXp6 apPWFTbAgI/bn/wlmKR5y5cU1+SQtzK+bPjLyuAUtkoelHk4mAWIHHPfCfVy4HZ5pFM+ 8NIQaPESEOjeJo9rxGpll6QlC77shC/FZaId0mnXhwi80SrCWfR4Ms3ehearq2I0s8ze 6VmdwmI1b2Td1F5Prfpj1sIIfdnOzbeC3yVB2exKFM2HPzF2VfF7qGNzaEhTCNPLoHpQ chAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711459500; x=1712064300; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iVlniqMpzpzGu8TUSK+9bbtchEpFgk41MMoF1Ww4U4o=; b=alY6hsOc989fcstgvBbVPrBDxGxkXkcUeR11pKJa7M3UImQPoB93R3pWAwfnrYxaJs HIUcd3c3w3uuyj596uabXnU3wEbT/jxeNu0V46kknOGMHMMQk63yED9TOGyMQuO804cK uKU0l0KVu/zXKWjewyw0n8X/cfFKFF7KsBg79uTJFdedu8ZgH/yx4fNG4de8UYfTldH1 OGSQ+op/ePCDPaiGIoTQY9FuV8xrfCR4Hr+XdWl1FEsWobPoaXTgIbqXjuISN66KmRcr o4Q3dLhNwJhcvb9gnrdx3v1flFjUmF5qDmBQKZLNzjjkyL/tBhTSqxHKKDaC4uHI81cn h1Sg== X-Gm-Message-State: AOJu0Yy8YGCxaL1c4iDpuc+xTqBBCYnHPIjFJYee4D+MITmVcaC9zZz/ s7j6dAoNVDCsWtqqGBooDgkYkroKG2hsxo+y7xHkZMN0keuEjBQzxU3WeLyv X-Google-Smtp-Source: AGHT+IE+Zs2b+1xWe1v4nlQ14/gK0+DlIjbzgmUiUaswyeXa25yYwkd8d1w9ogswOyH7HHjcNKfaNw== X-Received: by 2002:a17:90a:f2c9:b0:29d:dfae:4fac with SMTP id gt9-20020a17090af2c900b0029ddfae4facmr8278593pjb.23.1711459499983; Tue, 26 Mar 2024 06:24:59 -0700 (PDT) Received: from Thaum. (193-119-89-230.tpgi.com.au. [193.119.89.230]) by smtp.gmail.com with ESMTPSA id pw4-20020a17090b278400b002a07707cf37sm2956686pjb.24.2024.03.26.06.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:24:59 -0700 (PDT) Message-ID: <6602ccab.170a0220.a8b45.7fc8@mx.google.com> X-Google-Original-Message-ID: Date: Wed, 27 Mar 2024 00:24:52 +1100 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell Subject: [PATCH] c++/modules: Setup aliases imported from modules [PR106820] MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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 Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- I wonder if more generally we need to be doing more work when importing definitions from header units especially to handle all the work that 'make_rtl_for_nonlocal_decl' and 'rest_of_decl_compilation' would have been performing. But this patch fixes at least one missing step. PR c++/106820 gcc/cp/ChangeLog: * module.cc (trees_in::decl_value): Assemble alias when needed. gcc/testsuite/ChangeLog: * g++.dg/modules/pr106820_a.H: New test. * g++.dg/modules/pr106820_b.C: New test. Signed-off-by: Nathaniel Shead --- gcc/cp/module.cc | 9 +++++++++ gcc/testsuite/g++.dg/modules/pr106820_a.H | 5 +++++ gcc/testsuite/g++.dg/modules/pr106820_b.C | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/modules/pr106820_a.H create mode 100644 gcc/testsuite/g++.dg/modules/pr106820_b.C diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 8aab9ea0bae..b4e3b38c6fe 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -217,6 +217,7 @@ Classes used: #include "dumpfile.h" #include "bitmap.h" #include "cgraph.h" +#include "varasm.h" #include "tree-iterator.h" #include "cpplib.h" #include "mkdeps.h" @@ -8302,6 +8303,14 @@ trees_in::decl_value () if (state->is_header () && decl_tls_wrapper_p (decl)) note_vague_linkage_fn (decl); + + /* Setup aliases for the declaration. */ + if (tree alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl))) + { + alias = TREE_VALUE (TREE_VALUE (alias)); + alias = get_identifier (TREE_STRING_POINTER (alias)); + assemble_alias (decl, alias); + } } else { diff --git a/gcc/testsuite/g++.dg/modules/pr106820_a.H b/gcc/testsuite/g++.dg/modules/pr106820_a.H new file mode 100644 index 00000000000..7d32d4e5fc3 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/pr106820_a.H @@ -0,0 +1,5 @@ +// PR c++/106820 +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi {} } + +static int __gthrw___pthread_key_create() __attribute__((__weakref__("foo"))); diff --git a/gcc/testsuite/g++.dg/modules/pr106820_b.C b/gcc/testsuite/g++.dg/modules/pr106820_b.C new file mode 100644 index 00000000000..247fe26e778 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/pr106820_b.C @@ -0,0 +1,8 @@ +// PR c++/106820 +// { dg-additional-options "-fmodules-ts" } + +import "pr106820_a.H"; + +int main() { + __gthrw___pthread_key_create(); +}