public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/51726] New: LTO and attribute 'selectany'
@ 2012-01-01 19:27 d.g.gorbachev at gmail dot com
2012-01-02 11:20 ` [Bug target/51726] " rguenth at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2012-01-01 19:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
Bug #: 51726
Summary: LTO and attribute 'selectany'
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: d.g.gorbachev@gmail.com
Target: *-*-mingw32
Created attachment 26213
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26213
Testcase
foobar.c: In function 'main':
foobar.c:1:32: error: 'bar':'selectany' attribute applies only to initialized
objects
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
@ 2012-01-02 11:20 ` rguenth at gcc dot gnu.org
2012-01-23 20:48 ` d.g.gorbachev at gmail dot com
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-02 11:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-01-02
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-02 11:19:41 UTC ---
It's a target bug - the target should ignore the attribute on extern
declarations.
case VAR_DECL:
if (lookup_attribute ("selectany", DECL_ATTRIBUTES (decl)))
{
if (DECL_INITIAL (decl)
/* If an object is initialized with a ctor, the static
initialization and destruction code for it is present in
each unit defining the object. The code that calls the
ctor is protected by a link-once guard variable, so that
the object still has link-once semantics, */
|| TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
else
error ("%q+D:'selectany' attribute applies only to "
"initialized objects", decl);
}
thus, restrict processing to !DECL_EXTERNAL
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
2012-01-02 11:20 ` [Bug target/51726] " rguenth at gcc dot gnu.org
@ 2012-01-23 20:48 ` d.g.gorbachev at gmail dot com
2014-08-08 2:09 ` [Bug lto/51726] " d.g.gorbachev at gmail dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2012-01-23 20:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
--- Comment #2 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2012-01-23 20:22:00 UTC ---
Created attachment 26437
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26437
Patch (not tested)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug lto/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
2012-01-02 11:20 ` [Bug target/51726] " rguenth at gcc dot gnu.org
2012-01-23 20:48 ` d.g.gorbachev at gmail dot com
@ 2014-08-08 2:09 ` d.g.gorbachev at gmail dot com
2014-08-08 8:02 ` [Bug target/51726] " rguenth at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2014-08-08 2:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
Dmitry Gorbachev <d.g.gorbachev at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu.org
--- Comment #3 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> ---
The attached patch does not work in GCC 4.10.0 - stream_read_tree() returns
NULL in lto_read_tree_1() (gcc/lto-streamer-in.c:1184):
> DECL_INITIAL (expr) = stream_read_tree (ib, data_in);
`bar' is treated as a common var.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
` (2 preceding siblings ...)
2014-08-08 2:09 ` [Bug lto/51726] " d.g.gorbachev at gmail dot com
@ 2014-08-08 8:02 ` rguenth at gcc dot gnu.org
2015-05-21 14:46 ` jacek at codeweavers dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-08-08 8:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu.org
Component|lto |target
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
On trunk the backend has to use varpool_node::get (decl)->get_constructor ().
But seriously the backend should process the attribute once at compile-time
and then discard it rather than trying to re-do the job at WPA/LTRANS time.
That is, _not_ do this in i386_pe_encode_section_info which is way too late
but instead directly in ix86_handle_selectany_attribute so LTO can see
the decl is one-only (and also the linker is informed correctly).
Still completely a backend bug. IMHO as soon as it's not necessary to
retain the attribute on the decl it's a sign of a good implementation.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
` (3 preceding siblings ...)
2014-08-08 8:02 ` [Bug target/51726] " rguenth at gcc dot gnu.org
@ 2015-05-21 14:46 ` jacek at codeweavers dot com
2015-09-30 19:34 ` ktietz at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jacek at codeweavers dot com @ 2015-05-21 14:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
Jacek Caban <jacek at codeweavers dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jacek at codeweavers dot com
--- Comment #5 from Jacek Caban <jacek at codeweavers dot com> ---
It seems like selectany is not supported at all in LTO:
$ cat selectany.c
__attribute__((selectany)) int i = 0;
$ i686-w64-mingw32-gcc selectany.c selectany.c -flto -shared
/tmp/cchTGZVt.o (symbol from plugin):(.text+0x0): multiple definition of `i'
/tmp/ccAy2OzL.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc (GCC) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Should I file separated bug?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
` (4 preceding siblings ...)
2015-05-21 14:46 ` jacek at codeweavers dot com
@ 2015-09-30 19:34 ` ktietz at gcc dot gnu.org
2015-10-01 8:02 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu.org @ 2015-09-30 19:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
--- Comment #6 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Created attachment 36427
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36427&action=edit
Suggested patch
I will do some further testing with that patch, and later on send patch
upstream with a testcase for the common-case with selectany-attribute.
It would be appreciated if you could test patch too.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
` (5 preceding siblings ...)
2015-09-30 19:34 ` ktietz at gcc dot gnu.org
@ 2015-10-01 8:02 ` rguenth at gcc dot gnu.org
2015-10-01 18:56 ` ktietz at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-01 8:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|4.10.0 |5.0
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Kai Tietz from comment #6)
> Created attachment 36427 [details]
> Suggested patch
>
> I will do some further testing with that patch, and later on send patch
> upstream with a testcase for the common-case with selectany-attribute.
>
> It would be appreciated if you could test patch too.
I believe you can skip adding the attribute after you handled it this way
(unless other code literally looks for the attribute rather than its effect)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
` (6 preceding siblings ...)
2015-10-01 8:02 ` rguenth at gcc dot gnu.org
@ 2015-10-01 18:56 ` ktietz at gcc dot gnu.org
2015-10-02 8:07 ` ktietz at gcc dot gnu.org
2015-10-02 8:09 ` ktietz at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu.org @ 2015-10-01 18:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
Kai Tietz <ktietz at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |thiago at kde dot org
--- Comment #8 from Kai Tietz <ktietz at gcc dot gnu.org> ---
*** Bug 67688 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
` (7 preceding siblings ...)
2015-10-01 18:56 ` ktietz at gcc dot gnu.org
@ 2015-10-02 8:07 ` ktietz at gcc dot gnu.org
2015-10-02 8:09 ` ktietz at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu.org @ 2015-10-02 8:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
--- Comment #9 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Author: ktietz
Date: Fri Oct 2 08:06:52 2015
New Revision: 228370
URL: https://gcc.gnu.org/viewcvs?rev=228370&root=gcc&view=rev
Log:
PR target/51726
* config/i386/winnt.c (ix86_handle_selectany_attribute): Handle
selectany within this function without need to keep attribute.
(i386_pe_encode_section_info): Remove selectany-code.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/winnt.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/51726] LTO and attribute 'selectany'
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
` (8 preceding siblings ...)
2015-10-02 8:07 ` ktietz at gcc dot gnu.org
@ 2015-10-02 8:09 ` ktietz at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu.org @ 2015-10-02 8:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
--- Comment #10 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Author: ktietz
Date: Fri Oct 2 08:08:38 2015
New Revision: 228371
URL: https://gcc.gnu.org/viewcvs?rev=228371&root=gcc&view=rev
Log:
PR target/51726
* g++.dg/ext/selectany2.C: Allow uninitialized variable case.
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/ext/selectany2.C
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-10-02 8:09 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-01 19:27 [Bug target/51726] New: LTO and attribute 'selectany' d.g.gorbachev at gmail dot com
2012-01-02 11:20 ` [Bug target/51726] " rguenth at gcc dot gnu.org
2012-01-23 20:48 ` d.g.gorbachev at gmail dot com
2014-08-08 2:09 ` [Bug lto/51726] " d.g.gorbachev at gmail dot com
2014-08-08 8:02 ` [Bug target/51726] " rguenth at gcc dot gnu.org
2015-05-21 14:46 ` jacek at codeweavers dot com
2015-09-30 19:34 ` ktietz at gcc dot gnu.org
2015-10-01 8:02 ` rguenth at gcc dot gnu.org
2015-10-01 18:56 ` ktietz at gcc dot gnu.org
2015-10-02 8:07 ` ktietz at gcc dot gnu.org
2015-10-02 8:09 ` ktietz at gcc dot gnu.org
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).