Re: [PATCH] Fix attribute((section)) for templates

2019-12-17 Thread Nathan Sidwell
On 12/16/19 6:20 PM, Jason Merrill wrote: On 11/29/19 6:23 PM, Strager Neds wrote: How can we solve this problem? Some ideas (none of which I like): * Disallow this code, possibly with an improved diagnostic. * Silently make the section SECTION_LINKONCE if there is a conflict. * Silently make

Re: [PATCH] Fix attribute((section)) for templates

2019-12-16 Thread Jason Merrill
On 11/29/19 6:23 PM, Strager Neds wrote: I discovered an issue with my patch. I need help resolving it. Take the following code for example: template struct s { static inline int __attribute__((section(".testsection"))) var = 1; }; struct public_symbol {};

Re: [PATCH] Fix attribute((section)) for templates

2019-11-29 Thread Strager Neds
I discovered an issue with my patch. I need help resolving it. Take the following code for example: template struct s { static inline int __attribute__((section(".testsection"))) var = 1; }; struct public_symbol {}; namespace { struct internal_symbol {}; }

Re: [PATCH] Fix attribute((section)) for templates

2019-11-22 Thread Strager Neds
Here's a revised version of the patch. This revised version is ready for review. When GCC encounters __attribute__((section("foo"))) on a function or variable declaration, it adds an entry in the symbol table for the declaration to remember its desired section. The symbol table is separate from th

Re: [PATCH] Fix attribute((section)) for templates

2019-11-06 Thread Strager Neds
Summary: Do not merge my patch. It needs more work. I realized a problem with my patch. With -flto, __attribute__((section)) is still broken (i.e. my patch has no effect for LTO builds). I narrowed the problem to localize_node (gcc/ipa-visibility.c, historically part of function_and_variable_visib

[PATCH] Fix attribute((section)) for templates

2019-11-05 Thread Strager Neds
Aside: This is my first time working in GCC's code base. I probably made some mistakes. Please point them out. =] When GCC encounters __attribute__((section("foo"))) on a function or variable declaration, it adds an entry in the symbol table for the declaration to remember its desired section. The