public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "npiggin at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/102485] -Wa,-many no longer has any effect
Date: Thu, 24 Feb 2022 01:11:04 +0000	[thread overview]
Message-ID: <bug-102485-4-LtYd9KMecq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102485-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102485

--- Comment #8 from Nicholas Piggin <npiggin at gmail dot com> ---
(In reply to Segher Boessenkool from comment #7)
> > GCC already passes -m<cpu> to the assembler though.
> 
> That mostly is historic.

So? I was pointing out the compiler already tells the assembler what
instruction set to use without the .machine directive.

> 
> > The justification for emitting the .machine directive is given as fixing a
> > build breakage due to a build system that passes an incorrect -m<cpu> to the
> > assembler.
> 
> Not really, no. 

That is really the justification for emitting the .machine directive as
provided in the changelog of the commit which introduced the change.

> That is just one tiny part of the problem.  It is impossible
> to know what instruction sets we need ahead of time, and -many cannot work
> (and
> *does not* work: there are quite a few mnemonics that encode to different
> insns
> on different architecture versions (or for different CPUs), and we cannot
> know
> which is wanted, or which is preferred, ahead of time.

I understand the problems with -many, but it can and does work for real
software. E.g., Linux kernel as of before this change. It's not -many I'm
wedded to though, it's any ability to fix this sanely because of the .machine
directive.

The kernel should would change to using a specific CPU, e.g., -mcpu=power4
-Wa,-mpower10 and deal with the very rare few clashing mnemonics (e.g., tlbie)
specially with the .machine directive when an older one is required.

> 
> > *That* is the broken code (if any) that should have been fixed. But instead
> > that is hacked around in a way that breaks working code that passes down
> > -Wa,-many option as specified.
> 
> There is no working code that uses -many (accept by accident, if no problem
> has hit you yet).

I'll reword. "Instead that is hacked around in a way that breaks working code
that passes down the -Wa,-m<cpu> option as specified."

> 
> > The kernel builds with a base compatibility (say -mcpu=power4) and then has
> > certain code paths that are dynamically taken if running on newer CPUs which
> > use newer instructions with inline asm.
> > 
> > This is an important usage and it's pervasive, it seems unreasonable to
> > break it.  Adding .machine directives throughout inline asm for every
> > instruction not in the base compatibility class is pretty horrible.
> 
> It is the only correct thing to do.

It's not. Not passing .machine and passing -mcpu is just as correct. With the
added bonus that it allows software to use a superset of instructions in such
cases. And even the great bonus that existing "broken" code that uses -many
will continue to work.

The correct way to deal with this is not to break this, it is to add a warning
to -many for some period to binutils to give code a chance to migrate. I'm all
for removing -many, and that is the right way to do it. By deprecating -many
and providing warnings. Not by hacking around it in the compiler that breaks
things.

  parent reply	other threads:[~2022-02-24  1:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-25 21:27 [Bug target/102485] New: " pc at us dot ibm.com
2021-10-04 17:26 ` [Bug target/102485] " bergner at gcc dot gnu.org
2021-10-04 18:17 ` pc at us dot ibm.com
2021-10-05 22:11 ` segher at gcc dot gnu.org
2021-10-05 22:58 ` bergner at gcc dot gnu.org
2021-10-05 23:41 ` segher at gcc dot gnu.org
2022-02-23 17:11 ` npiggin at gmail dot com
2022-02-23 17:38 ` segher at gcc dot gnu.org
2022-02-24  1:11 ` npiggin at gmail dot com [this message]
2022-02-24  1:25 ` npiggin at gmail dot com
2022-02-24 11:07 ` amodra at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102485-4-LtYd9KMecq@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).