From 22f08d2f5a3a43fc3c4c9c172ea82d9ca337dd49 Mon Sep 17 00:00:00 2001 From: q66 Date: Fri, 12 Jul 2019 19:37:56 +0200 Subject: [PATCH] linux4.19: build ppc64 BE with ELFv2 [ci skip] --- .../linux4.19/patches/ppc64-be-elfv2.patch | 84 +++++++++++++++++++ .../linux4.19/patches/ppc64-be-gcc91.patch | 28 ------- 2 files changed, 84 insertions(+), 28 deletions(-) create mode 100644 srcpkgs/linux4.19/patches/ppc64-be-elfv2.patch delete mode 100644 srcpkgs/linux4.19/patches/ppc64-be-gcc91.patch diff --git a/srcpkgs/linux4.19/patches/ppc64-be-elfv2.patch b/srcpkgs/linux4.19/patches/ppc64-be-elfv2.patch new file mode 100644 index 00000000000..ec65b442bdb --- /dev/null +++ b/srcpkgs/linux4.19/patches/ppc64-be-elfv2.patch @@ -0,0 +1,84 @@ +This makes the Linux kernel build as ELFv2 on big endian ppc64. The upstream +doesn't seem to be interested in this but it's a small patch that is unlikely +to break/easy to remake and in worst case can always be ditched. + +Using ELFv2 has some potential performance benefits and is already always used +on little endian. It requires a relatively modern toolchain, which we already +have. + +Ping q66 if it does not apply. + +--- a/arch/powerpc/Makefile ++++ b/arch/powerpc/Makefile +@@ -93,10 +93,8 @@ MULTIPLEWORD := -mmultiple + endif + + ifdef CONFIG_PPC64 +-cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) +-cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc) +-aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) +-aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 ++cflags-y += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc)) ++aflags-y += $(call cc-option,-mabi=elfv2,$(call cc-option,-mabi=elfv1)) + endif + + ifndef CONFIG_CC_IS_CLANG +@@ -144,14 +142,8 @@ endif + endif + + CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no) +-ifdef CONFIG_CPU_LITTLE_ENDIAN + CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc)) +-AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2) +-else +-CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) +-CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc) +-AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) +-endif ++AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mabi=elfv1)) + CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc)) + CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) + +--- a/arch/powerpc/boot/Makefile ++++ b/arch/powerpc/boot/Makefile +@@ -48,8 +48,8 @@ ifdef CONFIG_CPU_BIG_ENDIAN + BOOTCFLAGS += -mbig-endian + else + BOOTCFLAGS += -mlittle-endian +-BOOTCFLAGS += $(call cc-option,-mabi=elfv2) + endif ++BOOTCFLAGS += $(call cc-option,-mabi=elfv2) + + BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc + +--- a/drivers/crypto/vmx/Makefile ++++ b/drivers/crypto/vmx/Makefile +@@ -5,7 +5,7 @@ vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes + ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) + TARGET := linux-ppc64le + else +-TARGET := linux-ppc64 ++TARGET := linux-ppc64v2 + endif + + quiet_cmd_perl = PERL $@ +--- a/drivers/crypto/vmx/ppc-xlate.pl ++++ b/drivers/crypto/vmx/ppc-xlate.pl +@@ -40,7 +40,7 @@ my $globl = sub { + }; + my $text = sub { + my $ret = ($flavour =~ /aix/) ? ".csect\t.text[PR],7" : ".text"; +- $ret = ".abiversion 2\n".$ret if ($flavour =~ /linux.*64le/); ++ $ret = ".abiversion 2\n".$ret if ($flavour =~ /linux.*64(le|v2)/); + $ret; + }; + my $machine = sub { +@@ -142,7 +142,7 @@ my $vmr = sub { + + # Some ABIs specify vrsave, special-purpose register #256, as reserved + # for system use. +-my $no_vrsave = ($flavour =~ /linux-ppc64le/); ++my $no_vrsave = ($flavour =~ /linux-ppc64(le|v2)/); + my $mtspr = sub { + my ($f,$idx,$ra) = @_; + if ($idx == 256 && $no_vrsave) { diff --git a/srcpkgs/linux4.19/patches/ppc64-be-gcc91.patch b/srcpkgs/linux4.19/patches/ppc64-be-gcc91.patch deleted file mode 100644 index f168c161e6c..00000000000 --- a/srcpkgs/linux4.19/patches/ppc64-be-gcc91.patch +++ /dev/null @@ -1,28 +0,0 @@ -Since gcc 9.1, adding `-mcall-aixdesc` to cflags makes it no longer define -`__linux__`, which breaks compilation of the kernel in places where the macro -is checked (which is multiple). This behavior is actually more correct than -it was before, as `-mcall-aixdesc` is only meant to be used when compiling -for AIX. - -However, it is not enough to just drop it and use `-mabi=elfv1`, as that -results in a ton of undefined references all over the place when linking. -So work around it until upstream sorts it out. - ---- a/arch/powerpc/Makefile -+++ b/arch/powerpc/Makefile -@@ -96,6 +96,7 @@ endif - ifdef CONFIG_PPC64 - cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) - cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc) -+cflags-$(CONFIG_CPU_BIG_ENDIAN) += -D__linux__ - aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) - aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 - endif -@@ -151,6 +152,7 @@ AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2) - else - CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) - CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc) -+CFLAGS-$(CONFIG_PPC64) += -D__linux__ - AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) - endif - CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))