From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 4C081386F000 for ; Fri, 14 Aug 2020 15:40:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4C081386F000 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oliva@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1C60A562F9; Fri, 14 Aug 2020 11:40:14 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id StSwDnbTWBtO; Fri, 14 Aug 2020 11:40:14 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 4C25C562F8; Fri, 14 Aug 2020 11:40:13 -0400 (EDT) Received: from livre.home (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 07EFdtgU138897 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Aug 2020 12:40:00 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org, jason@redhat.com, nathan@acm.org, joseph@codesourcery.com Cc: hainque@adacore.com, ebotcazou@adacore.com Subject: Re: [PATCH] introduce attribute exalias Organization: Free thinker, does not speak for AdaCore References: Errors-To: aoliva@lxoliva.fsfla.org Date: Fri, 14 Aug 2020 12:39:55 -0300 In-Reply-To: (Alexandre Oliva's message of "Fri, 07 Aug 2020 14:38:55 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Aug 2020 15:40:15 -0000 Ping? In case there isn't immediate approval for the patch proper (I suppose different parts will require review by different subsystem maintainers), I'd appreciate at least community and language lawyers buy-in (or turn-down) for the new feature hereby proposed for C-family languages, namely, attribute exalias("symbol_name") as a means to have symbol_name output as a same-linkage alias for functions, variables, and for C++ class types' RTTI symbols. Thanks in advance, On Aug 7, 2020, Alexandre Oliva wrote: > Since last week's patchlet, I've delayed the creation of the exalias > decls, improved the merging of attributes, minimizing > interface/visibility updates, found a better way to assign exaliases to > nested explicit instantiations, even after enabling aliases to > already-defined types, so now I'm reasonably happy with the patch. > This patch introduces an attribute to add extra aliases to a symbol > when its definition is output. The main goal is to ease interfacing > C++ with Ada, as C++ mangled names have to be named, and in some cases > (e.g. when using stdint.h typedefs in function arguments) the symbol > names may vary across platforms. > The attribute is usable in C and C++, presumably in all C-family > languages. It can be attached to global variables and functions. In > C++, it can also be attached to namespace-scoped variables and > functions, static data members, member functions, explicit > instantiations and specializations of template functions, members and > classes. When applied to constructors or destructor, additional > exaliases with _Base and _Del suffixes are defined for variants other > than complete-object ones. > Applying the attribute to class types is only valid in C++, and the > effect is to attach the alias to the RTTI object associated with the > class type. > While working on this, I noticed C++ didn't merge attributes of extern > local declarations with those of the namespace-scoped declaration. > I've added code to merge the attributes if there is a namespace-scoped > declaration, but if there isn't one, there won't be any merging, and > the effects are noticeable, as in the added attr-weak-1.C. I'm also > slightly concerned that an earlier local decl would go out of sync if > a subsequent local decl, say within the same or even in another > function, introduces additional attributes in the global decl. > Regstrapped on x86_64-linux-gnu. Ok to install? > (The newly-introduced attr-weak-1.c passes in C, but is marked as XFAIL > for C++, so it gets an XPASS in C; I could move it to some C++-only > subtree, or drop it altogether and file a PR instead) > for gcc/ChangeLog > * attribs.c: Include cgraph.h. > (decl_attributes): Allow late introduction of exalias in > types. > (create_exalias_decl, create_exalias_decls): New. > * attribs.h: Declare them. > (FOR_EACH_EXALIAS): New macro. > * cgraph.c (cgraph_node::create): Create exalias decls. > * varpool.c (varpool_node::get_create): Create exalias decls. > * cgraph.h (symtab_node::remap_exalias_target): New. > * symtab.c (symtab_node::remap_exalias_target): Define. > * cgraphunit.c (cgraph_node::analyze): Create alias_target > node if needed. > (analyze_functions): Fixup visibility of implicit alias only > after its node is analyzed. > * doc/extend.texi (exalias): Document for variables, functions > and types. > for gcc/ada/ChangeLog > * doc/gnat_rm/interfacing_to_other_languages.rst: Mention > attribute exalias to give RTTI symbols mnemonic names. > * doc/gnat_ugn/the_gnat_compilation_model.rst: Mention > attribute exalias. Fix incorrect ref to C1 ctor variant. > for gcc/c-family/ChangeLog > * c-ada-spec.c (pp_asm_name): Use first exalias if available. > * c-attribs.c (handle_exalias_attribute): New. > (c_common_attribute_table): Add exalias. > (handle_copy_attribute): Do not copy exalias. > * c-decl.c (duplicate_decls): Remap exalias target. > for gcc/cp/ChangeLog > * class.c (copy_fndecl_with_name): Move/adjust exalias to > cdtor variants. > (build_cdtor_clones): Drop exalias from primary variant. > * cp-tree.h (update_exalias_interface, update_tinfo_exalias): > Declare. > * decl.c (duplicate_decls): Remap exalias target. > (grokfndecl): Tentatively create exalias decls after adding > attributes in e.g. a template member function explicit > instantiation. > * decl2.c (cplus_decl_attributes): Update tinfo exalias. > (copy_interface, update_exalias_interface): New. > (determine_visibility): Update exalias interface. > (tentative_decl_linkage, import_export_decl): Likewise. > * name-lookup.c: Include target.h and cgraph.h. > (set_local_extern_decl_linkage): Merge attributes with a > namespace-scoped decl if one is found. Remap exalias > targets, and drop exaliases from the local decl. > * optimize.c (maybe_clone_body): Only copy attributes if they > haven't been copied yet. Update exalias interface. > * rtti.c: Include attribs.h and cgraph.h. > (get_tinfo_decl): Copy exalias attributes from type to tinfo > decl. Create exalias decls. > (update_tinfo_exalias): New. > for gcc/testsuite/ChangeLog > * c-c++-common/attr-weak-1.c: New, xfailed. > * c-c++-common/torture/attr-exalias-1.c: New. > * c-c++-common/torture/attr-exalias-2.c: New. > * c-c++-common/torture/attr-exalias-3.c: New. > * c-c++-common/torture/attr-exalias-4.c: New. > * g++.dg/torture/attr-exalias-1.C: New. > * g++.dg/torture/attr-exalias-2.C: New. > * g++.dg/torture/attr-exalias-3.C: New. > * g++.dg/torture/attr-exalias-4.C: New. https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551614.html -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer