Build ppc64le kernel with llvm/clang
cover Build ppc64le kernel with llvm/clang
Now that Michael has fixed the 32 bit VDSO issue in his next branch, there are only a few remaining things left to get the ppc64le kernel building with clang.
The last patch is a hack to workaround some generic Makefile issues. Hopefully the relevant bits of the LLVMLinux tree will get merged upstream to fix them.
Anton Blanchard (6):
powerpc: Fix duplicate const clang warning in user access code
powerpc: Only use -mabi=altivec if toolchain supports it
powerpc: Only use -mtraceback=no, -mno-string and -msoft-float if
toolchain supports it
powerpc: Don't use -mno-strict-align on clang
powerpc: Don't use gcc specific options on clang
llvm: A few Makefile hacks
Makefile | 5 +++++ arch/powerpc/Makefile | 14 ++++++++++---- arch/powerpc/include/asm/uaccess.h | 8 ++++---- arch/powerpc/lib/Makefile | 2 +- lib/raid6/Makefile | 2 +- 5 files changed, 21 insertions(+), 10 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/6 powerpc: Fix duplicate const clang warning in user access code
--- arch/powerpc/include/asm/uaccess.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/uaccess.h +4 -4
@@ -265,7 +265,7 @@ do { \ ({ \ long __gu_err; \ unsigned long __gu_val; \ - const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ + __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ __chk_user_ptr(ptr); \ if (!is_kernel_addr((unsigned long)__gu_addr)) \ might_fault(); \
@@ -279,7 +279,7 @@ do { \ ({ \ long __gu_err; \ long long __gu_val; \ - const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ + __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ __chk_user_ptr(ptr); \ if (!is_kernel_addr((unsigned long)__gu_addr)) \ might_fault(); \
@@ -293,7 +293,7 @@ do { \ ({ \ long __gu_err = -EFAULT; \ unsigned long __gu_val = 0; \ - const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ + __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ might_fault(); \ if (access_ok(VERIFY_READ, __gu_addr, (size))) \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
@@ -305,7 +305,7 @@ do { \ ({ \ long __gu_err; \ unsigned long __gu_val; \ - const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ + __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ __chk_user_ptr(ptr); \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \
Signature · 1 line
2.1.4
PATCH 2/6 powerpc: Only use -mabi=altivec if toolchain supports it
In reply to Anton BlanchardThe -mabi=altivec option is not recognised on LLVM, so use call cc-option to check for support.
--- arch/powerpc/lib/Makefile | 2 +- lib/raid6/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/lib/Makefile +1 -1
@@ -33,6 +33,6 @@ obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o obj-$(CONFIG_FTR_FIXUP_SELFTEST) += feature-fixups-test.o obj-$(CONFIG_ALTIVEC) += xor_vmx.o -CFLAGS_xor_vmx.o += -maltivec -mabi=altivec +CFLAGS_xor_vmx.o += -maltivec $(call cc-option,-mabi=altivec) obj-$(CONFIG_PPC64) += $(obj64-y)
lib/raid6/Makefile +1 -1
@@ -15,7 +15,7 @@ quiet_cmd_unroll = UNROLL $@ < $< > $@ || ( rm -f $@ && exit 1 ) ifeq ($(CONFIG_ALTIVEC),y) -altivec_flags := -maltivec -mabi=altivec +altivec_flags := -maltivec $(call cc-option,-mabi=altivec) endif # The GCC option -ffreestanding is required in order to compile code containing
Signature · 1 line
2.1.4
PATCH 3/6 powerpc: Only use -mtraceback=no, -mno-string and -msoft-float if toolchain supports it
In reply to Anton BlanchardThese options are not recognised on LLVM, so use call cc-option to check for support.
--- arch/powerpc/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/powerpc/Makefile +4 -3
@@ -111,7 +111,7 @@ else endif endif -CFLAGS-$(CONFIG_PPC64) := -mtraceback=no +CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no) ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,-mcall-aixdesc) AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
@@ -158,7 +158,8 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr) KBUILD_AFLAGS += -Iarch/$(ARCH) $(AFLAGS-y) -KBUILD_CFLAGS += -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y) +KBUILD_CFLAGS += $(call cc-option,-msoft-float) +KBUILD_CFLAGS += -pipe -Iarch/$(ARCH) $(CFLAGS-y) CPP = $(CC) -E $(KBUILD_CFLAGS) CHECKFLAGS += -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__
@@ -190,7 +191,7 @@ KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm) # Never use string load/store instructions as they are # often slow when they are implemented at all -KBUILD_CFLAGS += -mno-string +KBUILD_CFLAGS += $(call cc-option,-mno-string) ifeq ($(CONFIG_6xx),y) KBUILD_CFLAGS += -mcpu=powerpc
Signature · 1 line
2.1.4
PATCH 4/6 powerpc: Don't use -mno-strict-align on clang
In reply to Anton BlanchardWe added -mno-strict-align in commit f036b3681962 (powerpc: Work around little endian gcc bug) to fix gcc bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57134
Clang doesn't understand it. We need to use a conditional because we can't use the simpler call cc-option here.
--- arch/powerpc/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/Makefile +4 -1
@@ -65,7 +65,10 @@ endif ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) -override CC += -mlittle-endian -mno-strict-align +override CC += -mlittle-endian +ifneq ($(COMPILER),clang) +override CC += -mno-strict-align +endif override AS += -mlittle-endian override LD += -EL override CROSS32CC += -mlittle-endian
Signature · 1 line
2.1.4
PATCH 5/6 powerpc: Don't use gcc specific options on clang
In reply to Anton BlanchardAdd a conditional around the code to select various gcc only options:
-mabi=elfv2 vs -mcall-aixdesc, and -mcmodel=medium vs -mminimal-toc.
--- arch/powerpc/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/Makefile +2 -0
@@ -115,6 +115,7 @@ endif endif CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no) +ifneq ($(COMPILER),clang) ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,-mcall-aixdesc) AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
@@ -122,6 +123,7 @@ else CFLAGS-$(CONFIG_PPC64) += -mcall-aixdesc endif CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc) +endif CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
Signature · 1 line
2.1.4
PATCH 6/6 llvm: A few Makefile hacks
In reply to Anton Blanchardllvm accepts -fno-delete-null-pointer-checks but complains about it. Wrap it to avoid getting enormous numbers of warnings.
Also add -no-integrated-as to disable the llvm integrated assembler, lots of stuff currently relies on gas.
--- Makefile | 5 +++++ 1 file changed, 5 insertions(+)
Makefile +5 -0
@@ -609,7 +609,12 @@ all: vmlinux include arch/$(SRCARCH)/Makefile +ifneq ($(COMPILER),clang) KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) +endif + +KBUILD_CFLAGS += $(call cc-option,-no-integrated-as,) +KBUILD_AFLAGS += $(call cc-option,-no-integrated-as,) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
Signature · 1 line
2.1.4