diff mbox series

[v2,1/5] powerpc/Makefiles: Fix clang/llvm build

Message ID 20180914040649.1794-2-joel@jms.id.au (mailing list archive)
State Changes Requested
Headers show
Series powerpc: Clang build fixes | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied
snowpatch_ozlabs/checkpatch success Test checkpatch on branch next

Commit Message

Joel Stanley Sept. 14, 2018, 4:06 a.m. UTC
From: Anton Blanchard <anton@samba.org>

Commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type to POWER4")
passes -mpower4 to the assembler. We have more recent instructions in our
assembly files, but gas permits them. The clang/llvm integrated assembler
is more strict, and we get a build failure.

Fix this by calling the assembler with -mcpu=power8 if as supports it,
else fall back to power4.

Suggested-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 arch/powerpc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nick Desaulniers Sept. 14, 2018, 5:41 p.m. UTC | #1
On Thu, Sep 13, 2018 at 9:07 PM Joel Stanley <joel@jms.id.au> wrote:
>
> From: Anton Blanchard <anton@samba.org>
>
> Commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type to POWER4")
> passes -mpower4 to the assembler. We have more recent instructions in our
> assembly files, but gas permits them. The clang/llvm integrated assembler
> is more strict, and we get a build failure.

Note that we disable clang's integrated assembler in the top level
Makefile for now, but it will still validate constraints for inline
assembly.  Do you know which case is meant by "build failure?"

Is there a link to the Clang bug?  It would be good to have that
context in the commit message.

>
> Fix this by calling the assembler with -mcpu=power8 if as supports it,
> else fall back to power4.
>
> Suggested-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Anton Blanchard <anton@samba.org>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  arch/powerpc/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 11a1acba164a..a70639482053 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -238,7 +238,7 @@ 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
> +cpu-as-$(CONFIG_PPC_BOOK3S_64) += $(call as-option,-Wa$(comma)-mpower8,-Wa$(comma)-mpower4)
>  cpu-as-$(CONFIG_PPC_E500MC)    += $(call as-option,-Wa$(comma)-me500mc)
>
>  KBUILD_AFLAGS += $(cpu-as-y)
> --
> 2.17.1
>
Joel Stanley Sept. 20, 2018, 7:04 a.m. UTC | #2
On Sat, 15 Sep 2018 at 03:11, Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Thu, Sep 13, 2018 at 9:07 PM Joel Stanley <joel@jms.id.au> wrote:
> >
> > From: Anton Blanchard <anton@samba.org>
> >
> > Commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type to POWER4")
> > passes -mpower4 to the assembler. We have more recent instructions in our
> > assembly files, but gas permits them. The clang/llvm integrated assembler
> > is more strict, and we get a build failure.
>
> Note that we disable clang's integrated assembler in the top level
> Makefile for now, but it will still validate constraints for inline
> assembly.  Do you know which case is meant by "build failure?"

An example of a failure is:

  CC      init/do_mounts.o
/tmp/do_mounts-58cd1d.s: Assembler messages:
/tmp/do_mounts-58cd1d.s:251: Error: unrecognized opcode: `isel'
/tmp/do_mounts-58cd1d.s:748: Error: unrecognized opcode: `isel'
/tmp/do_mounts-58cd1d.s:759: Error: unrecognized opcode: `isel'
/tmp/do_mounts-58cd1d.s:1373: Error: unrecognized opcode: `isel'

The full build line at the bottom of this email. The m flags:

 -mlittle-endian -m64 -msoft-float -mabi=elfv2 -mcmodel=medium
-mcpu=power8 -mtune=power9 -mno-altivec -mno-vsx -Wa,-maltivec
-Wa,-mpower4 -mlittle-endian

If we remove the -Wa,-mpower4 it works. This is because isel is not
available on power4.

Digging deeper, clang drives gas like this:

"/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

GCC drives it:

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

I think the important difference is GCC adds -many:

        -many
           Generate code for any architecture (PWR/PWRX/PPC).

This is probably what we mean when building the kernel. I will get
some advice from our toolchain people first to understand what -many
does.

> Is there a link to the Clang bug?  It would be good to have that
> context in the commit message.

I haven't opened a clang bug. I'm not sure that we need one, unless we
want it to add -many to the assembler call like gcc does.

Cheers,

Joel

--
  /scratch/joel/llvm-build/bin/clang-8 -Wp,-MD,init/.do_mounts.o.d
-nostdinc -isystem /scratch/joel/llvm-build/lib/clang/8.0.0/include
-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 -include ./include/linux/kconfig.h -include
./include/linux/compiler_types.h -D__KERNEL__ -Iarch/powerpc
-DHAVE_AS_ATHIGH=1 -Qunused-arguments -Wall -Wundef
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-fshort-wchar -Werror-implicit-function-declaration
-Wno-format-security -std=gnu89 -no-integrated-as -fno-PIE
-mlittle-endian -m64 -msoft-float -pipe -Iarch/powerpc -mabi=elfv2
-mcmodel=medium -mcpu=power8 -mtune=power9 -mno-altivec -mno-vsx
-funit-at-a-time -fno-dwarf2-cfi-asm -Wa,-maltivec -Wa,-mpower4
-mlittle-endian -fno-delete-null-pointer-checks -Oz
-Wframe-larger-than=2048 -fno-stack-protector
-Wno-format-invalid-specifier -Wno-gnu -Wno-address-of-packed-member
-Wno-tautological-compare -mno-global-merge -Wno-unused-const-variable
-fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign
-fno-strict-overflow -fno-merge-all-constants -fno-stack-check
-Werror=implicit-int -Werror=strict-prototypes -Werror=date-time
-Werror=incompatible-pointer-types -Wno-initializer-overrides
-Wno-unused-value -Wno-format -Wno-sign-compare
-Wno-format-zero-length -Wno-uninitialized -fno-function-sections
-fno-data-sections    -DKBUILD_BASENAME='"do_mounts"'
-DKBUILD_MODNAME='"mounts"' -c -o init/do_mounts.o init/do_mounts.c
diff mbox series

Patch

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 11a1acba164a..a70639482053 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -238,7 +238,7 @@  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
+cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= $(call as-option,-Wa$(comma)-mpower8,-Wa$(comma)-mpower4)
 cpu-as-$(CONFIG_PPC_E500MC)	+= $(call as-option,-Wa$(comma)-me500mc)
 
 KBUILD_AFLAGS += $(cpu-as-y)