public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug d/99914] d: Template symbols not overridable by normal symbols
Date: Mon, 05 Apr 2021 11:41:53 +0000	[thread overview]
Message-ID: <bug-99914-4-8hrhovP2gT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99914-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99914

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:76a7e7e706ac4c01cead3c6514322aaad88f9a63

commit r11-7983-g76a7e7e706ac4c01cead3c6514322aaad88f9a63
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Mar 14 22:51:56 2021 +0100

    d: Use weak linkage for template symbols instead of gnu.linkonce (PR99914)

    The default linkage of templates in the D language is now DECL_WEAK
    instead of  DECL_ONE_ONLY, if supported.  This better matches the
    expected override semantics of template symbols compiled to object code.

    For example:

     module rt.config;
     template rt_flag()
     {
       pragma(mangle, "rt_flag") __gshared bool rt_flag = true;
     }

     module main;
     extern(C) __gshared bool rt_flag = false;

    The above currently does not succeed in linking due to there being
    multiple definitions of `rt_flag' in different sections that aren't
    considered mergeable.

    The compiler flag enabling toggling of this has been given a clearer
    named `-fweak-templates', which distinguishes itself from G++ `-fweak',
    which is intended only for testing.

    gcc/d/ChangeLog:

            PR d/99914
            * d-lang.cc (d_init): Disable flag_weak_templates if no support for
            weak or one-only symbols.
            * d-tree.h (VAR_OR_FUNCTION_DECL_CHECK): New macro.
            (DECL_INSTANTIATED): New macro.
            (d_comdat_linkage): Remove declaration.
            (d_linkonce_linkage): Remove declaration.
            (set_linkage_for_decl): New declaration.
            * decl.cc (DeclVisitor::visit (StructDeclaration *)): Replace call
to
            d_linkonce_linkage with setting DECL_INSTANTIATED.
            (DeclVisitor::visit (ClassDeclaration *)): Likewise.
            (DeclVisitor::visit (EnumDeclaration *)): Likewise.
            (DeclVisitor::visit (InterfaceDeclaration *)): Remove call to
            d_linkonce_linkage.
            (get_symbol_decl): Call set_linkage_for_decl instead of
            d_linkonce_linkage.
            (d_finish_decl): Call set_linkage_for_decl.
            (d_comdat_linkage): Made function static.  Only set DECL_COMDAT for
            DECL_INSTANTIATED decls.
            (d_linkonce_linkage): Remove function.
            (d_weak_linkage): New function.
            (set_linkage_for_decl): New function.
            * gdc.texi (Runtime Options): Rename -fno-weak to
-fno-weak-templates,
            update documentation of option.
            * lang.opt (fweak): Rename option to ...
            (fweak-templates): ... this.  Update help string.
            * modules.cc (get_internal_fn): Add Prot parameter.  Set generated
            function flag.
            (build_internal_fn): Update call to get_internal_fn.
            (build_dso_cdtor_fn): Likewise.
            (register_moduleinfo): Call d_finish_decl on dso_slot_node and
            dso_initialized_node.
            * typeinfo.cc (TypeInfoVisitor::internal_reference): Call
            set_linkage_for_decl instead of d_comdat_linkage.
            (TypeInfoDeclVisitor::visit (TypeInfoDeclaration *)): Remove calls
to
            d_linkonce_linkage and d_comdat_linkage.
            (get_cpp_typeinfo_decl): Likewise.

    gcc/testsuite/ChangeLog:

            PR d/99914
            * gdc.dg/pr99914.d: New test.

  reply	other threads:[~2021-04-05 11:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-05 11:07 [Bug d/99914] New: " ibuclaw at gdcproject dot org
2021-04-05 11:41 ` cvs-commit at gcc dot gnu.org [this message]
2021-04-05 11:53 ` [Bug d/99914] " ibuclaw at gdcproject dot org
2021-04-14 12:44 ` cvs-commit at gcc dot gnu.org
2021-04-14 13:02 ` ibuclaw at gdcproject dot org
2021-04-17 12:37 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99914-4-8hrhovP2gT@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).