All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS
@ 2018-10-11  2:43 Joel Stanley
  2018-10-11 10:44 ` Michael Ellerman
  2018-10-15  4:01 ` [v3] " Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Joel Stanley @ 2018-10-11  2:43 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nick Desaulniers, Nicholas Piggin

Ever since commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type
to POWER4") we force -mpower4 to be passed to the assembler irrespective
of the CFLAGS used.

When building a powerpc64 kernel with clang, clang will not add -many to
the assembler flags, so any instructions that the compiler has generated
that are not available on power4 will cause an error:

 /usr/bin/as -a64 -mppc64 -mlittle-endian -mpower8 \
  -I ./arch/powerpc/include -I ./arch/powerpc/include/generated \
  -I ./include -I ./arch/powerpc/include/uapi \
  -I ./arch/powerpc/include/generated/uapi -I ./include/uapi \
  -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc \
  -maltivec -mpower4 -o init/do_mounts.o /tmp/do_mounts-3b0a3d.s
 /tmp/do_mounts-51ce54.s:748: Error: unrecognized opcode: `isel'

GCC does include -many, so the GCC driven gas call will succeed:

  as -v -I ./arch/powerpc/include -I ./arch/powerpc/include/generated -I
  ./include -I ./arch/powerpc/include/uapi
  -I ./arch/powerpc/include/generated/uapi -I ./include/uapi
  -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc
   -a64 -mpower8 -many -mlittle -maltivec -mpower4 -o init/do_mounts.o

Note that isel is power7 and above for IBM CPUs. GCC only generates it
for Power9 and above, but the above test was run against the clang
generated assembly.

Peter Bergner explains:

 > When using -many -mpower4, gas will first try and find a matching
 > power4 mnemonic and failing that, it will then allow any valid mnemonic
 > that gas knows about.  GCC's use of -many predates me though.
 >
 > IIRC, Alan looked at trying to remove it, but I forget why he didn't.
 > Could be either a gcc or gas issue at the time.  I'm not sure whether
 > issue still exists or not.  He and I have modified how gas works
 > internally a fair amount since he tried removing gcc use of -many
 >
 > I will also note that when using -many, gas will choose the first
 > mnemonic that matches in the mnemonic table and we have (mostly) sorted
 > the table so that server mnemonics show up earlier in the table than
 > other mnemonics, so they'll be seen/chosen first

By explicitly setting -many we can build with Clang and GCC while
retaining the -mpower4 option.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
Following up on:
https://lore.kernel.org/linuxppc-dev/20180914040649.1794-2-joel@jms.id.au/
https://lore.kernel.org/linuxppc-dev/20180821010203.23213-1-anton@ozlabs.org/

mpe, please trim the commit message if you think it's a bit verbose

We could test for these flags in case -many is removed in the future,
but if an assembler does not support -many then -mpower4 will probably
break it anyway.

 arch/powerpc/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 81552c7b46eb..ae097fa9abe9 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -249,7 +249,10 @@ cpu-as-$(CONFIG_4xx)		+= -Wa,-m405
 cpu-as-$(CONFIG_ALTIVEC)	+= $(call as-option,-Wa$(comma)-maltivec)
 cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 cpu-as-$(CONFIG_E500)		+= -Wa,-me500
-cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= -Wa,-mpower4
+# When using -many -mpower4 gas will first try and find a matching power4
+# mnemonic and failing that it will allow any valid mnemonic that GAS knows
+# about. GCC will pass -many to GAS when assembling, clang does not
+cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= -Wa,-mpower4 -Wa,-many
 cpu-as-$(CONFIG_PPC_E500MC)	+= $(call as-option,-Wa$(comma)-me500mc)
 
 KBUILD_AFLAGS += $(cpu-as-y)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS
  2018-10-11  2:43 [PATCH v3] powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS Joel Stanley
@ 2018-10-11 10:44 ` Michael Ellerman
  2018-10-15  4:01 ` [v3] " Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-10-11 10:44 UTC (permalink / raw)
  To: Joel Stanley, linuxppc-dev; +Cc: Nick Desaulniers, Nicholas Piggin

Joel Stanley <joel@jms.id.au> writes:
> Ever since commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type
> to POWER4") we force -mpower4 to be passed to the assembler irrespective
> of the CFLAGS used.
...
>
> By explicitly setting -many we can build with Clang and GCC while
> retaining the -mpower4 option.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
> Following up on:
> https://lore.kernel.org/linuxppc-dev/20180914040649.1794-2-joel@jms.id.au/
> https://lore.kernel.org/linuxppc-dev/20180821010203.23213-1-anton@ozlabs.org/
>
> mpe, please trim the commit message if you think it's a bit verbose

I thought it was bit short :P

> We could test for these flags in case -many is removed in the future,
> but if an assembler does not support -many then -mpower4 will probably
> break it anyway.

Yeah that's OK, breaking hypothetical future toolchains is fine.

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v3] powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS
  2018-10-11  2:43 [PATCH v3] powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS Joel Stanley
  2018-10-11 10:44 ` Michael Ellerman
@ 2018-10-15  4:01 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-10-15  4:01 UTC (permalink / raw)
  To: Joel Stanley, linuxppc-dev; +Cc: Nick Desaulniers, Nicholas Piggin

On Thu, 2018-10-11 at 02:43:03 UTC, Joel Stanley wrote:
> Ever since commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type
> to POWER4") we force -mpower4 to be passed to the assembler irrespective
> of the CFLAGS used.
> 
> When building a powerpc64 kernel with clang, clang will not add -many to
> the assembler flags, so any instructions that the compiler has generated
> that are not available on power4 will cause an error:
> 
>  /usr/bin/as -a64 -mppc64 -mlittle-endian -mpower8 \
>   -I ./arch/powerpc/include -I ./arch/powerpc/include/generated \
>   -I ./include -I ./arch/powerpc/include/uapi \
>   -I ./arch/powerpc/include/generated/uapi -I ./include/uapi \
>   -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc \
>   -maltivec -mpower4 -o init/do_mounts.o /tmp/do_mounts-3b0a3d.s
>  /tmp/do_mounts-51ce54.s:748: Error: unrecognized opcode: `isel'
> 
> GCC does include -many, so the GCC driven gas call will succeed:
> 
>   as -v -I ./arch/powerpc/include -I ./arch/powerpc/include/generated -I
>   ./include -I ./arch/powerpc/include/uapi
>   -I ./arch/powerpc/include/generated/uapi -I ./include/uapi
>   -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc
>    -a64 -mpower8 -many -mlittle -maltivec -mpower4 -o init/do_mounts.o
> 
> Note that isel is power7 and above for IBM CPUs. GCC only generates it
> for Power9 and above, but the above test was run against the clang
> generated assembly.
> 
> Peter Bergner explains:
> 
>  > When using -many -mpower4, gas will first try and find a matching
>  > power4 mnemonic and failing that, it will then allow any valid mnemonic
>  > that gas knows about.  GCC's use of -many predates me though.
>  >
>  > IIRC, Alan looked at trying to remove it, but I forget why he didn't.
>  > Could be either a gcc or gas issue at the time.  I'm not sure whether
>  > issue still exists or not.  He and I have modified how gas works
>  > internally a fair amount since he tried removing gcc use of -many
>  >
>  > I will also note that when using -many, gas will choose the first
>  > mnemonic that matches in the mnemonic table and we have (mostly) sorted
>  > the table so that server mnemonics show up earlier in the table than
>  > other mnemonics, so they'll be seen/chosen first
> 
> By explicitly setting -many we can build with Clang and GCC while
> retaining the -mpower4 option.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/960e30029863db95ec79a71009272d

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-15  4:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-11  2:43 [PATCH v3] powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS Joel Stanley
2018-10-11 10:44 ` Michael Ellerman
2018-10-15  4:01 ` [v3] " Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.