public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/65262] New: Link time optimization breaks use __attribute__((section("..."))) in templates
@ 2015-03-01 11:54 goswin-v-b at web dot de
  2015-03-02  9:01 ` [Bug lto/65262] " rguenth at gcc dot gnu.org
  2015-03-02  9:54 ` goswin-v-b at web dot de
  0 siblings, 2 replies; 3+ messages in thread
From: goswin-v-b at web dot de @ 2015-03-01 11:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65262
           Summary: Link time optimization breaks use
                    __attribute__((section("..."))) in templates
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: goswin-v-b at web dot de
                CC: goswin-v-b at web dot de

Created attachment 34911
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34911&action=edit
Simple testcase

I'm trying to put a template member functions of a class into a different
section. Without -flto this works but with -flto the function reverts to the
.text section.

g++ -O2 -W -Wall -fvisibility=hidden -fno-inline -Tlink.ld -c -o main.o main.cc
g++ -O2 -W -Wall -fvisibility=hidden -fno-inline -Tlink.ld -o main main.o
g++ -O2 -W -Wall -fvisibility=hidden -fno-inline -Tlink.ld -flto -c -o
main.lto.o main.cc
g++ -O2 -W -Wall -fvisibility=hidden -fno-inline -Tlink.ld -flto -o main.lto
main.lto.o
Without link time optimization:
0000000000000200 l    d  .text.foo      0000000000000000              .text.foo
0000000000000210 g     F .text.foo      0000000000000006              .hidden
foo()
0000000000000200  w    F .text.foo      0000000000000006              .hidden
int foobar<int>()

With link time optimization:
0000000000000820 l    d  .text.foo      0000000000000000              .text.foo
0000000000000100 l     F .text  0000000000000006              int foobar<int>()
0000000000000820 l     F .text.foo      0000000000000006              foo()


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug lto/65262] Link time optimization breaks use __attribute__((section("..."))) in templates
  2015-03-01 11:54 [Bug lto/65262] New: Link time optimization breaks use __attribute__((section("..."))) in templates goswin-v-b at web dot de
@ 2015-03-02  9:01 ` rguenth at gcc dot gnu.org
  2015-03-02  9:54 ` goswin-v-b at web dot de
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-03-02  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |hubicka at gcc dot gnu.org
         Resolution|---                         |WONTFIX

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
You are using a linker script for this?  That doesn't work.  LTO happily
privatizes template instantiations.

See other bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug lto/65262] Link time optimization breaks use __attribute__((section("..."))) in templates
  2015-03-01 11:54 [Bug lto/65262] New: Link time optimization breaks use __attribute__((section("..."))) in templates goswin-v-b at web dot de
  2015-03-02  9:01 ` [Bug lto/65262] " rguenth at gcc dot gnu.org
@ 2015-03-02  9:54 ` goswin-v-b at web dot de
  1 sibling, 0 replies; 3+ messages in thread
From: goswin-v-b at web dot de @ 2015-03-02  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Goswin von Brederlow <goswin-v-b at web dot de> ---
The linker script is only there because the default script combines all .text.*
into one hiding the effect. One could use different section names that the
default script does not combine and work without a custom linker script.

LTO is free to privatizes template instantiations. But if it doesn't inline the
template then it should preserve the section attribute on it like it does for
normal functions. All optimized clones of a normal functions are still in the
same section the original function was in.

I could understand if a template would end up in the section of the function
causing the instantiation (although what if functions from different sections
use the same instance?). But templates simply end up in the .text section no
matter what they where originally or where they get instantiated. I don't know
the internals but it looks to me like something should copy the section
attribute from the template to the privatized function in LTO mode.

You can't set a section on the template, you can't use a file scope in the
linker, you can't even use __attribute__((always_inline)) and the behaviour
differs from without -flto. How is that a WONTFIX?


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-02  9:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01 11:54 [Bug lto/65262] New: Link time optimization breaks use __attribute__((section("..."))) in templates goswin-v-b at web dot de
2015-03-02  9:01 ` [Bug lto/65262] " rguenth at gcc dot gnu.org
2015-03-02  9:54 ` goswin-v-b at web dot de

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).