[Bug lto/65262] Link time optimization breaks use __attribute__((section(...))) in templates

2015-03-02 Thread goswin-v-b at web dot de
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?


[Bug lto/65262] Link time optimization breaks use __attribute__((section(...))) in templates

2015-03-02 Thread rguenth at gcc dot gnu.org
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.