This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: [mingw/cygwin] Add "selectany" (=linkonce) attribute forinitialized global data
- From: Danny Smith <dannysmith at clear dot net dot nz>
- To: Christopher Faylor <me at cgf dot cx>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 11 Mar 2005 09:44:42 +1300
- Subject: Re: Patch: [mingw/cygwin] Add "selectany" (=linkonce) attribute forinitialized global data
- References: <20050306050402.47518.qmail@web50908.mail.yahoo.com><20050309185233.GC17118@gully.bosbc.com>
- Reply-to: Danny Smith <dannysmith at users dot sourceforge dot net>
Christopher Faylor wrote:
> On Sun, Mar 06, 2005 at 06:04:02PM +1300, Danny Smith wrote:
>> The apended patch adds the "selectany" attribute, which causes an
>> initialized global variable to have link-once semantics, for windows
>> targets. The attribute is declared on other compilers using the
>> synonym __declspec(selectany)) and is commonly used in MS win32api
>> headers to define ids (GUID objects) used to register Common Object
>> Model (COM) "interfaces". It is also use extensively in such COM code
>> as MS's proprietary "Active Template Library" (ATL) to allow in-header
>> definition of static data members of C++ classes.
>>
>> I have only added this as a subtarget attribute for windows targets,
>> since it specifies a very restricted type of COMDAT linkage that, AFAIK,
>> is common only in the MS world. Does it have any wider utility?
>>
>> Bootstrapped and tested on i686-pc-mingw32 with C, C++.
>> gcc version 4.1.0 20050304 (experimental)
>>
>> OK for mainline?
>
> Since this is all windows-only, it seems like you have the authority to
> check this in.
>
The patch adds to extend.texi and to g++ testsuite, as well as adding prototype
to i386-protos.h. I was under the impression that those changes would need
approval.
Danny
> cgf
>
>> Changelog
>>
>> 2005-03-06 Danny Smith <dannysmith@users.sourceforge.net>
>>
>> * config/i386/cygming.h (SUBTARGET_ATTRIBUTE_TABLE): Define,
>> with entry for selectany attribute.
>> * config/i386/i386-protos.h (ix86_handle_selectany_attribute):
>> Declare.
>> * config/i386/winnt.c (ix86_handle_selectany_attribute): Define.
>> (i386_pe_asm_named_section): Handle sections generated by
>> selectany attribute.
>> * doc/extend.texi (selectany): Document attribute.
>>
>> testsuite/Changelog
>>
>> * g++.dg/ext/selectany1.C: New file. Test for linkonce sections.
>> * g++.dg/ext/selectany2.C: New file. Test for errors with invalid
>> selectany usage.