feature request: a linker option to avoid merging variables from separate object files into shared cache lines
Florian Weimer
fweimer@redhat.com
Tue Nov 5 10:18:21 GMT 2024
* David Brown via Gcc:
> I would have thought it would be better as part of the compiler. For
> each compilation unit, you generate one or more data sections
> depending on the variable initialisations, compiler options and target
> (.bss, .data, .rodata, .sbss, etc.). If the compiler has
> "-align-object-data-section=64" in effect, then you could add ".align
> 64" to the start and the end of each section. As far as I can see,
> that would give the effect the OP is looking for in a simple manner
> that can also be different for different translation units in the same
> program (which would be hard to do with a linker flag). And if this
> is a flag in gcc, then it will work for any ld-compatible linker
> (gold, mold, etc.).
I agree it's more of a compiler flag from an implementation perspective.
There's another aspect that supports this: I don't think we want to do
this for data sections that we use to implement vague linkage. Bumping
the alignment for them could be really wasteful and probably not what
the programmer intends.
Thanks,
Florian
More information about the Gcc
mailing list