From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by sourceware.org (Postfix) with ESMTPS id 21852386EC7A for ; Fri, 14 Aug 2020 16:24:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 21852386EC7A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qt1-x829.google.com with SMTP id e5so7320930qth.5 for ; Fri, 14 Aug 2020 09:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=7UR7hG/GrSIJnauRwK/KZzi9B+UqtfmC+XWQxSh1mEI=; b=HuCMDPIsLHyZnbnSQDT6CmshuD4A2UjV/dXAmOLeVe48y3t4lRWL8boAvGt21DxMBV K1rIQMzZMQSws9L81lhcxqTqSFKzT4TKcNRcaEZcnOhvEuh8LmyA05QhEjmA5v+psqpO uBUK6yIr930a0ccPq+UYSszbyU7Mj52w8N4+3QuAcBVB1LBKVQUBYHh+TUHz62Yf9wXS TNxpFbxOIl54vG2ao1LtaXjYJA3VIToCHMupogV4m6N8swT+rrIZG9mXZovoZGoCc/Ry S+xuUPNhMvTrw56OGH0b6kML5+XeQXWZuN/OpuAyGp4Wxy6yjyi5zQaMW1UwudTi6LVX wphg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7UR7hG/GrSIJnauRwK/KZzi9B+UqtfmC+XWQxSh1mEI=; b=N9lNqL6gJmBvj9enkUUC3b0cphZvzaqcZ2nedBY6XaCQYWsGHHjamECnyrbknstPjm w1w+YH8p6uCnKEdkGoMSxAjsHL/BBFClahmZoc6iUKQWPDINSKd8dfnKNyMBOw/4Fu1m NRWWBBXa6g29+3FZmXLTO4JAC8xBBGX9DIiRO7jW/jWCf6nSJ7VS+yhxHukHmv0ZYmyn rdyBUgQXJqaJJNRUi0Y6RsESDRgZ1INj0kp5ApcVbe4U2cHwHna9SPD08aqoD3GJxisO PtmAK1mslrQt6RU9gCjDA6Cm9KAAEQh23ZJcYhXwpOWSiBzTo82kE7D2oqNw13EzUb0n lWqg== X-Gm-Message-State: AOAM533WsaYbnAtRf4qRT2g/rV8TdULF2WP4WUQhIo/qumHgLoO5yFp9 BDZ6VU+nYG8YYR8FGpn6eRY= X-Google-Smtp-Source: ABdhPJyF6LcWGvlF9+u161/Qt8kKQwC6a7OUTHxykDlF0xkN/hmbavE4ni8PsyuJh/GFwK73J/ykSw== X-Received: by 2002:ac8:4256:: with SMTP id r22mr2751084qtm.367.1597422243233; Fri, 14 Aug 2020 09:24:03 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:1102:d4b:5793:bfd0:5130? ([2620:10d:c091:480::1:2e59]) by smtp.googlemail.com with ESMTPSA id d143sm8839784qkc.59.2020.08.14.09.24.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Aug 2020 09:24:02 -0700 (PDT) Sender: Nathan Sidwell Subject: Re: [PATCH] introduce attribute exalias To: Alexandre Oliva , gcc-patches@gcc.gnu.org, jason@redhat.com, joseph@codesourcery.com Cc: hainque@adacore.com, ebotcazou@adacore.com References: From: Nathan Sidwell Message-ID: Date: Fri, 14 Aug 2020 12:24:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 16:24:05 -0000 On 8/14/20 11:39 AM, Alexandre Oliva wrote: > 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. This seems a useful feature. I don;t think it needs language lawyering -- it's an extension, right? By 'same-linkage', do you mean same linkage as the *symbol* of the thing it is aliasing, or same linkage as the language entity it is aliasing? I suspect you mean the former. I'm sure we can bikeshed the name 'exalias' doesn't seem very mnemonic to me. 'symbol_alias' or something? nathan > > 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 > -- Nathan Sidwell