Re: [PATCH v2] x86: prevent gcc from emitting rep movsq/stosq for inlined ops

From: Linus Torvalds
Date: Fri Jun 06 2025 - 14:00:07 EST


On Fri, 6 Jun 2025 at 08:36, Mateusz Guzik <mjguzik@xxxxxxxxx> wrote:
>
> So if any patches would have to be written, how about fix up gcc to
> emit better inline asm for these to begin with. ;)

I really want to re-iterate that these kinds of "I want specific
behavior" things can be done with custom spec-files.

And I wouldn't object very much to having some kernel build support
for people doing custom spec-files themselves.

Because I suspect we could do some of our gcc-specific flags by using
spec files explicitly in the kernel, instead of the tens of flags we
add by hand to the command line.

Now, maybe things have changed - it's been years (decades?) since I
actually played with gcc spec files to do things - but it used to be a
convenient, if rather obscure, way to have site-specific gcc behavior.

I do remember that it was a pain to just add some incremental spec
file, and I think you practically speaking have to do things like "use
'gcc --dumpspec' to dump system specs, modify them, and then use 'gcc
-specs modified.specs' to use them".

Maybe that has been made simpler over the years.

Linus