[Bug target/95095] Feature request: support -fno-unique-section-names

2021-01-25 Thread i at maskray dot me via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #9 from Fangrui Song  ---
(In reply to Segher Boessenkool from comment #8)
> I say nothing like that.  I say that
>   .text.hot.
> is nasty (is easily mistaken for .text.hot).
> 
> I also say that and that named-per-function sections are better as
>   .text%name
> than as
>   .text.name
> (just as they were long ago), because this doesn't conflict with things like
>   .text.hot
> (and there is a very long history of such conflicts giving real-world
> problems).

.text%name and .text.hot%name will break existing output section descriptions
for .text

My scheme .text.% .text.hot.% is backward compatible.

[Bug target/95095] Feature request: support -fno-unique-section-names

2021-01-25 Thread segher at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #8 from Segher Boessenkool  ---
I say nothing like that.  I say that
  .text.hot.
is nasty (is easily mistaken for .text.hot).

I also say that and that named-per-function sections are better as
  .text%name
than as
  .text.name
(just as they were long ago), because this doesn't conflict with things like
  .text.hot
(and there is a very long history of such conflicts giving real-world
problems).

[Bug target/95095] Feature request: support -fno-unique-section-names

2021-01-25 Thread i at maskray dot me via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #7 from Fangrui Song  ---
(In reply to Segher Boessenkool from comment #6)
> I was under the impression this unique section thing needed the trailing
> dot thing.  This probably is not true.
> 
> I still think the old "%" thing is much superior to the trailing dot thing,
> but that then is orthogonal to the "unique section" thing, so let's ignore
> it now :-)
> 
> It still remains that this flag needs a name that says what it *does*, as I
> mentioned at the end of Comment 4.

-ffunction-sections -fno-unique-section-names =>

.text.%
.text.startup.%
.text.hot.%
.text.cold.%
...

?

I agree that it is superior. If GCC wants to support this scheme, that looks
fine to me. It is likely that I can migrate Clang to this scheme as well.

I think

.text%
.text.startup%
.text.hot%
.text.cold%
...

is slightly worse.

[Bug target/95095] Feature request: support -fno-unique-section-names

2021-01-25 Thread segher at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #6 from Segher Boessenkool  ---
I was under the impression this unique section thing needed the trailing
dot thing.  This probably is not true.

I still think the old "%" thing is much superior to the trailing dot thing,
but that then is orthogonal to the "unique section" thing, so let's ignore
it now :-)

It still remains that this flag needs a name that says what it *does*, as I
mentioned at the end of Comment 4.

[Bug target/95095] Feature request: support -fno-unique-section-names

2021-01-21 Thread i at maskray dot me via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #5 from Fangrui Song  ---
Linux kernel

include/asm-generic/vmlinux.lds.h currently has
#define TEXT_TEXT   \
ALIGN_FUNCTION();   \
*(.text.hot .text.hot.*)\
*(TEXT_MAIN .text.fixup)\
*(.text.unlikely .text.unlikely.*)  \
*(.text.unknown .text.unknown.*)\
NOINSTR_TEXT\
*(.text..refcount)  \
*(.ref.text)\
MEM_KEEP(init.text*)\
MEM_KEEP(exit.text*)\

If you change .text.* to .text%* , this script will need a change, along with
other projects which use or adapt GNU ld's built-in linker script

  .text   :
  {
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(SORT(.text.sorted.*))
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf.em.  */
*(.gnu.warning)
  }

By default, -fno-unique-section-names produces '.text' instead of '.text.foo'
in the normal -ffunction-sections case.

For PGO, -fno-unique-section-names produces '.text.hot.' instead of
'.text.hot.foo' in the normal -ffunction-sections case.

'.text.hot.' is an attempt to distinguish PGO caused 'hot' from a regular
functions named 'hot'.

[Bug target/95095] Feature request: support -fno-unique-section-names

2021-01-21 Thread segher at kernel dot crashing.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #4 from Segher Boessenkool  ---
On Sat, Jan 16, 2021 at 09:00:56PM +, i at maskray dot me wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095
> 
> --- Comment #3 from Fangrui Song  ---
> (In reply to Segher Boessenkool from comment #2)
> > Can't we use ".text%name" for -ffunction-sections, like we did originally,
> > in 1996?  See cf4403481dd6.  This does not conflict with other section
> > names, and does not have all the problems you get from doing anything that
> > is not a simple prefix.
> 
> A function named 'foo' compiles to '.text%foo'? It might have been better to
> avoid conflicts with '.text.startup' '.text.hot' etc but now such a change
> would just inconvenience users (think of various Linux kernel linker script
> fragments).

The conflicts that show up from time to time *also* inconvenience users,
and that is an ongoing inconvenience.

> .text%name does not address -fno-unique-section-names.

And neither does ".text.name.".

Something like this is a prerequisite of such an option.

Also, please use a different name, one that does not start with "no-"?
It isn't about unique names at all anyway, it is about having multiple
sections with the same name (that then can get separately GCed, because
of new linker features).


Segher

[Bug target/95095] Feature request: support -fno-unique-section-names

2021-01-16 Thread i at maskray dot me via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #3 from Fangrui Song  ---
(In reply to Segher Boessenkool from comment #2)
> Can't we use ".text%name" for -ffunction-sections, like we did originally,
> in 1996?  See cf4403481dd6.  This does not conflict with other section
> names, and does not have all the problems you get from doing anything that
> is not a simple prefix.

A function named 'foo' compiles to '.text%foo'? It might have been better to
avoid conflicts with '.text.startup' '.text.hot' etc but now such a change
would just inconvenience users (think of various Linux kernel linker script
fragments).

.text%name does not address -fno-unique-section-names.

[Bug target/95095] Feature request: support -fno-unique-section-names

2021-01-16 Thread segher at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #2 from Segher Boessenkool  ---
Can't we use ".text%name" for -ffunction-sections, like we did originally,
in 1996?  See cf4403481dd6.  This does not conflict with other section
names, and does not have all the problems you get from doing anything that
is not a simple prefix.

[Bug target/95095] Feature request: support -fno-unique-section-names

2020-05-24 Thread i at maskray dot me
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095

--- Comment #1 from Fangrui Song  ---
I just learned that `int main() {}` compiles to .text.startup in -O2 or -Os

It seems that .text.startup. may be better to not accidentally move a C
function named `startup` (`startup.` is not a valid C identifier)