Go to file
Iain Buclaw 76a7e7e706 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.
2021-04-05 13:40:36 +02:00
c++tools Daily bump. 2021-04-02 00:16:26 +00:00
config
contrib
fixincludes
gcc d: Use weak linkage for template symbols instead of gnu.linkonce (PR99914) 2021-04-05 13:40:36 +02:00
gnattools
gotools
include Daily bump. 2021-04-01 00:16:39 +00:00
INSTALL
intl
libada
libatomic
libbacktrace
libcc1
libcody
libcpp Daily bump. 2021-03-30 00:16:29 +00:00
libdecnumber
libffi
libgcc Daily bump. 2021-04-04 00:16:26 +00:00
libgfortran
libgo
libgomp Daily bump. 2021-03-30 00:16:29 +00:00
libhsail-rt
libiberty Daily bump. 2021-04-01 00:16:39 +00:00
libitm
libobjc
liboffloadmic
libphobos Daily bump. 2021-04-04 00:16:26 +00:00
libquadmath
libsanitizer
libssp
libstdc++-v3 Daily bump. 2021-04-01 00:16:39 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.