From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id C92003858D34 for ; Sun, 14 Apr 2024 11:02:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C92003858D34 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 C92003858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713092549; cv=none; b=jGZdHCmm/tYR7hkbVReNn4en79xtYD6BLoormkG0QTRlBg4p5pIg3yKTuIGgxLPe0/bmzzsw29ipDAO6y9R7BYqNt/vtmwGcBBrF3WlrfM0Asg1K/KOS83DIkW02th2BJhmWH4IX2K3gCkFkVqfSSNp1u3ryLbZQAoUQXc3UnNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713092549; c=relaxed/simple; bh=KwouHXNXGuUR7kbqH9G/3N33H2i+5Prk7HiQvaDZOjY=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=x08vy4ByBXTOC0cRMY5aTxWorYHHNqaDxab0tg1ZI9G4CCLiukb6C+ocJAuf+wOnKDf/9Pk9QCObklADCDkmoaBsoEYIOWsVJBrWFnDfvDS5wbtsJmciAjoo4nlDGZqWWFS0SaUDwHXL4pu79O1uWlG7HyV5XF/K5oBoKoIkuMc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6ecf05fd12fso2204961b3a.2 for ; Sun, 14 Apr 2024 04:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713092547; x=1713697347; darn=gcc.gnu.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=nqWWeTA3noihmyT7EW7Xr7jZ6EXJhWc4/OuPxmoqu8U=; b=neUGtar8Pj5DklrjKyMSBaKAiHl+lDUh/17Q+gyZufqXGSpoFq50obfmFrz6kSEuSw y9UyTgcRc7sjols6NFnmPYY+DcuqINUKFfotMxMYv67XTPd32Y29xIyB2G7TDgp6me8H nEEBFX55pQiJv+x2gDugibjPpF21jxFcLR14V3a2pydg0JDHab21wEFC0TPByuhFeei9 Wq/RpQG6Bzz2BFvleCo95gPOMwvLV3J+PFn23ma5aBiO2/zBrIKAPmM7HIpjUkaHY8Vm SehkgPpROHyTl8gZVbLG8E16ka+I+BT1ZsAYtXjyHCbQIg+V+h4ySy/NwIxQAwW1hYH3 8VtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713092547; x=1713697347; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nqWWeTA3noihmyT7EW7Xr7jZ6EXJhWc4/OuPxmoqu8U=; b=BR796iizmH/XhLBooiOVqm5N3OTRVPPtkMNU60AKZLmWokJ6MThYoz8l9h6lfKeN5D UX0u1HcQyF8bbaTYz6zJhUHO1rXJm6JM71keCSmwweJUZ8YwjUsBfr+QJuf9CmHAk/Tq QOuSG26DDRyGonlnrImUG7ZFTn5wlibV38t8OImY8FQciiPASnS+U/+jUArxZ+BSuheV 6N7T+K+zDwms1bBa2OiGvlhpJDTm1jn7LWq8towcDTh6bD4TAYrQ/DUDe9fadVAtvr4d Gx+772lXfswZD4hstitz/lYw4+IaRMQIZm90g5Eg2dTFztxHl4IJ4M9X+epFYo/RNctl w5Tw== X-Gm-Message-State: AOJu0YxufvMblSS8tDOFW+6xbxpfWBlIiuB/OlcjagNKI+8amF/Tw3pK LC04qe9lK2NhVzu821dY06GgSJWXkemZvL6MQecm85wYdSkrhsSh X-Google-Smtp-Source: AGHT+IFbSXjXhKp2A8z8vdogemI8PNiO9V6YkfRH87Se4EN9reiDttVmfFvPTW8O5XKar2r83mJ91g== X-Received: by 2002:a05:6a00:acb:b0:6ed:21d5:fc2c with SMTP id c11-20020a056a000acb00b006ed21d5fc2cmr8849211pfl.26.1713092546557; Sun, 14 Apr 2024 04:02:26 -0700 (PDT) Received: from Thaum. (121-44-11-123.tpgi.com.au. [121.44.11.123]) by smtp.gmail.com with ESMTPSA id y2-20020a056a00190200b006ed03220122sm5591193pfi.16.2024.04.14.04.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 04:02:26 -0700 (PDT) Message-ID: <661bb7c2.050a0220.79d9f.0423@mx.google.com> X-Google-Original-Message-ID: Date: Sun, 14 Apr 2024 21:02:21 +1000 From: Nathaniel Shead To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Nathan Sidwell Subject: Re: [PATCH] c++/modules: Setup aliases imported from modules [PR106820] References: <6602ccab.170a0220.a8b45.7fc8@mx.google.com> <024f75df-3727-4efd-ac9a-c3057dddc32d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <024f75df-3727-4efd-ac9a-c3057dddc32d@redhat.com> X-Spam-Status: No, score=-11.1 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 List-Id: On Fri, Apr 12, 2024 at 03:54:21PM -0400, Jason Merrill wrote: > On 3/26/24 09:24, Nathaniel Shead wrote: > > > > 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. > > Can we just call those functions? > Probably at least 'rest_of_decl_compilation' can (should?) be called from modules, but I haven't worked out exactly in which circumstances yet and whether there's any other work it does that doesn't make sense in a modules context. I don't think 'make_rtl_for_nonlocal_decl' can easily be called directly though. At the very least it'll probably need to get called in `read_definition` which doesn't clash with aliases (which are never definitions, as far as I can tell), so this will still be necessary. > > But this patch fixes at least one missing step. > > OK. > Thanks, pushed as r14-9959-g62a0ef0d02cbb7. > > 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(); > > +} >