mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
To: Koakuma <koachan@protonmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Andreas Larsson <andreas@gaisler.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	sparclinux@vger.kernel.org,  linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH] sparc/build: Make all compiler flags also clang-compatible
Date: Tue, 25 Jun 2024 09:20:11 +0200	[thread overview]
Message-ID: <e359b140839606b1856c5625669e5b6bd7ebc7eb.camel@physik.fu-berlin.de> (raw)
In-Reply-To: <Mz-kWneLsFvKbBcTaGnC2xMA2U55fINzOJqmMRMumrtTaeHW40WfS5rYUjF_71aoXG56jSHo0vJ0oRPNoCrxpE_oIr7mmnK6fg9dFC_J9hk=@protonmail.com>

Hi Koakuma,

thanks for doing the research work!

On Tue, 2024-06-25 at 02:06 +0000, Koakuma wrote:
> John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> wrote:
> > V8plus does not use VIS instructions and also has a different ELF machine
> > type, namely EM_SPARC32PLUS instead of EM_SPARCV9 if I understand correctly.
> > 
> > So, we should make sure that the above change will not affect the ELF machine
> > type.
> 
> When assembling with GNU as, there seem to be no control as to what
> machine type we want to emit, as it simply tries to autodetect it based
> on the instruction mix in the assembly code:
> - If there's a V9 instruction inside, then use EM_SPARC32PLUS; and
> - Emit EM_SPARC otherwise.

Interesting. I actually expected some flags being passed to the linker to
enable the EM_SPARC32PLUS machine type.

> This is also the case with GCC - it simply happens that GCC will try
> to emit V9 instructions whenever possible with `-m32 -mv8plus`
> or `-m32 -mcpu=v9` so there's a high chance that the resulting object
> file will be of a EM_SPARC32PLUS type, but this does not seem to be
> a guaranteed behavior.

Would be interesting to find out what Sun's own C/C++ compiler (Sun Studio)
does in this case. I can try to run some tests on Solaris or you can check
out the Solaris machines in the GCC compile farm [1].

> With LLVM's as, we can have finer control of emitted machine type, but
> so far it never sets the type to EM_SPARC32PLUS - for this I have made
> a patch over at https://github.com/llvm/llvm-project/pull/96583.

I just had a brief look - will do the proper review later - and I think
it's the right approach for the time being. However, I am wondering whether
we should add "-mv8plus" to clang as well.

I wondering though whether "-mcpu=v9 -m32" is truly identical to "-mv8plus"
or not.

> As for VIS, GCC (and clang when it eventually supports vectorization)
> should not emit it unless explicitly asked, so I think we are
> in the clear here?
> 
> > With `-mvis`, GCC generates code that takes advantage of
> > the UltraSPARC Visual Instruction Set extensions.
> > The default is `-mno-vis`.
> 
> From https://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html#index-mvis

OK, very good to know. Yes, I think we should be safe here.

Again, thanks a lot for getting this sorted out so quickly!

Adrian

> [1] https://gcc.gnu.org/wiki/CompileFarm

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

  reply	other threads:[~2024-06-25  7:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 15:56 Koakuma via B4 Relay
2024-06-21 18:53 ` Nathan Chancellor
2024-06-22  7:29   ` John Paul Adrian Glaubitz
2024-06-22 12:18   ` Koakuma
2024-06-24 20:14     ` Nathan Chancellor
2024-06-23 16:53 ` John Paul Adrian Glaubitz
2024-06-25  2:06   ` Koakuma
2024-06-25  7:20     ` John Paul Adrian Glaubitz [this message]
2024-06-25 16:37       ` Koakuma

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=e359b140839606b1856c5625669e5b6bd7ebc7eb.camel@physik.fu-berlin.de \
    --to=glaubitz@physik.fu-berlin.de \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=justinstitt@google.com \
    --cc=koachan@protonmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sparclinux@vger.kernel.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

all inboxes | Powered by JetHome®