From e095510cb6a75eb9bd20af98a5d6ac460f728ab6 Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 9 Jun 2019 20:23:41 +0200 Subject: [PATCH 1/3] musl: backport upstream patches for vrregset_t on ppc64 [ci skip] --- .../patches/ppc64-vrregset-t-fix-layout.patch | 45 +++++++++++++++++++ .../patches/ppc64-vrregset-t-vrregs-fix.patch | 29 ++++++++++++ srcpkgs/musl/template | 2 +- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/musl/patches/ppc64-vrregset-t-fix-layout.patch create mode 100644 srcpkgs/musl/patches/ppc64-vrregset-t-vrregs-fix.patch diff --git a/srcpkgs/musl/patches/ppc64-vrregset-t-fix-layout.patch b/srcpkgs/musl/patches/ppc64-vrregset-t-fix-layout.patch new file mode 100644 index 00000000000000..5ca68a35aafc5b --- /dev/null +++ b/srcpkgs/musl/patches/ppc64-vrregset-t-fix-layout.patch @@ -0,0 +1,45 @@ +commit 3c59a868956636bc8adafb1b168d090897692532 +Author: Rich Felker +Date: Wed May 22 15:17:12 2019 -0400 + + fix vrregset_t layout and member naming on powerpc64 + + the mistaken layout seems to have been adapted from 32-bit powerpc, + where vscr and vrsave are packed into the same 128-bit slot in a way + that looks like it relies on non-overlapping-ness of the value bits in + big endian. + + the powerpc64 port accounted for the fact that the 64-bit ABI puts + each in its own 128-bit slot, but ordered them incorrectly (matching + the bit order used on the 32-bit ABI), and failed to account for vscr + being padded according to endianness so that it can be accessed via + vector moves. + + in addition to ABI layout, our definition used different logical + member layout/naming from glibc, where vscr is a structure to + facilitate access as a 32-bit word or a 128-bit vector. the + inconsistency here was unintentional, so fix it. + +diff --git a/arch/powerpc64/bits/signal.h b/arch/powerpc64/bits/signal.h +index 34693a68..94c7a327 100644 +--- arch/powerpc64/bits/signal.h ++++ arch/powerpc64/bits/signal.h +@@ -17,10 +17,14 @@ typedef struct { + + typedef struct { + unsigned __int128 vrregs[32]; +- unsigned _pad[3]; +- unsigned vrsave; +- unsigned vscr; +- unsigned _pad2[3]; ++ struct { ++#if __BIG_ENDIAN__ ++ unsigned _pad[3], vscr_word; ++#else ++ unsigned vscr_word, _pad[3]; ++#endif ++ } vscr; ++ unsigned vrsave, _pad[3]; + } vrregset_t; + + typedef struct sigcontext { diff --git a/srcpkgs/musl/patches/ppc64-vrregset-t-vrregs-fix.patch b/srcpkgs/musl/patches/ppc64-vrregset-t-vrregs-fix.patch new file mode 100644 index 00000000000000..0d2664e6c97394 --- /dev/null +++ b/srcpkgs/musl/patches/ppc64-vrregset-t-vrregs-fix.patch @@ -0,0 +1,29 @@ +commit ac304227bb3ea1787d581f17d76a5f5f3abff51f +Author: Rich Felker +Date: Wed May 22 18:28:32 2019 -0400 + + make powerpc64 vrregset_t logical layout match expected API + + between v2 and v3 of the powerpc64 port patch, the change was made + from a 32x4 array of 32-bit unsigned ints for vrregs[] to a 32-element + array of __int128. this mismatches the API applications working with + mcontext_t expect from glibc, and seems to have been motivated by a + misinterpretation of a comment on how aarch64 did things as a + suggestion to do the same on powerpc64. + +diff --git a/arch/powerpc64/bits/signal.h b/arch/powerpc64/bits/signal.h +index 94c7a327..2cc0604c 100644 +--- arch/powerpc64/bits/signal.h ++++ arch/powerpc64/bits/signal.h +@@ -16,7 +16,10 @@ typedef struct { + } fpregset_t; + + typedef struct { +- unsigned __int128 vrregs[32]; ++#ifdef __GNUC__ ++ __attribute__((__aligned__(16))) ++#endif ++ unsigned vrregs[32][4]; + struct { + #if __BIG_ENDIAN__ + unsigned _pad[3], vscr_word; diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template index 4ebe3f86431951..8f7ea0c9dc7d9b 100644 --- a/srcpkgs/musl/template +++ b/srcpkgs/musl/template @@ -1,7 +1,7 @@ # Template file for 'musl'. pkgname=musl version=1.1.22 -revision=2 +revision=3 archs="*-musl" build_style=gnu-configure configure_args="--prefix=/usr --disable-gcc-wrapper" From 43dc5be766584b4d9ad81a316805831bc9fefe43 Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 9 Jun 2019 20:54:27 +0200 Subject: [PATCH 2/3] cross-powerpc64le-linux-musl: add musl backport patches [ci skip] --- .../files/ppc64-vrregset-t-fix-layout.patch | 1 + .../files/ppc64-vrregset-t-vrregs-fix.patch | 1 + srcpkgs/cross-powerpc64le-linux-musl/template | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 120000 srcpkgs/cross-powerpc64le-linux-musl/files/ppc64-vrregset-t-fix-layout.patch create mode 120000 srcpkgs/cross-powerpc64le-linux-musl/files/ppc64-vrregset-t-vrregs-fix.patch diff --git a/srcpkgs/cross-powerpc64le-linux-musl/files/ppc64-vrregset-t-fix-layout.patch b/srcpkgs/cross-powerpc64le-linux-musl/files/ppc64-vrregset-t-fix-layout.patch new file mode 120000 index 00000000000000..07c710a2072400 --- /dev/null +++ b/srcpkgs/cross-powerpc64le-linux-musl/files/ppc64-vrregset-t-fix-layout.patch @@ -0,0 +1 @@ +../../musl/patches/ppc64-vrregset-t-fix-layout.patch \ No newline at end of file diff --git a/srcpkgs/cross-powerpc64le-linux-musl/files/ppc64-vrregset-t-vrregs-fix.patch b/srcpkgs/cross-powerpc64le-linux-musl/files/ppc64-vrregset-t-vrregs-fix.patch new file mode 120000 index 00000000000000..ccc5c0ef175ae2 --- /dev/null +++ b/srcpkgs/cross-powerpc64le-linux-musl/files/ppc64-vrregset-t-vrregs-fix.patch @@ -0,0 +1 @@ +../../musl/patches/ppc64-vrregset-t-vrregs-fix.patch \ No newline at end of file diff --git a/srcpkgs/cross-powerpc64le-linux-musl/template b/srcpkgs/cross-powerpc64le-linux-musl/template index 03e91752e9fd82..8bb44d51b1f51b 100644 --- a/srcpkgs/cross-powerpc64le-linux-musl/template +++ b/srcpkgs/cross-powerpc64le-linux-musl/template @@ -9,7 +9,7 @@ _sysroot="/usr/${_triplet}" pkgname=cross-${_triplet} version=0.30 -revision=4 +revision=5 short_desc="Cross toolchain for powerpc64le with musl" maintainer="q66 " homepage="https://www.voidlinux.org/" @@ -149,6 +149,10 @@ _musl_build() { [ -f ${wrksrc}/.musl_build_done ] && return 0 cd ${wrksrc}/musl-${_musl_version} + + _apply_patch -p0 ${FILESDIR}/ppc64-vrregset-t-fix-layout.patch + _apply_patch -p0 ${FILESDIR}/ppc64-vrregset-t-vrregs-fix.patch + msg_normal "Building cross musl libc\n" CC="${_triplet}-gcc" LD="${_triplet}-ld" AR="${_triplet}-ar" \ From b9a1869cf9213f44fca027ba8fa457873254f65b Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 9 Jun 2019 20:54:42 +0200 Subject: [PATCH 3/3] cross-powerpc64-linux-musl: add musl backport patches [ci skip] --- .../files/ppc64-vrregset-t-fix-layout.patch | 1 + .../files/ppc64-vrregset-t-vrregs-fix.patch | 1 + srcpkgs/cross-powerpc64-linux-musl/template | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 120000 srcpkgs/cross-powerpc64-linux-musl/files/ppc64-vrregset-t-fix-layout.patch create mode 120000 srcpkgs/cross-powerpc64-linux-musl/files/ppc64-vrregset-t-vrregs-fix.patch diff --git a/srcpkgs/cross-powerpc64-linux-musl/files/ppc64-vrregset-t-fix-layout.patch b/srcpkgs/cross-powerpc64-linux-musl/files/ppc64-vrregset-t-fix-layout.patch new file mode 120000 index 00000000000000..07c710a2072400 --- /dev/null +++ b/srcpkgs/cross-powerpc64-linux-musl/files/ppc64-vrregset-t-fix-layout.patch @@ -0,0 +1 @@ +../../musl/patches/ppc64-vrregset-t-fix-layout.patch \ No newline at end of file diff --git a/srcpkgs/cross-powerpc64-linux-musl/files/ppc64-vrregset-t-vrregs-fix.patch b/srcpkgs/cross-powerpc64-linux-musl/files/ppc64-vrregset-t-vrregs-fix.patch new file mode 120000 index 00000000000000..ccc5c0ef175ae2 --- /dev/null +++ b/srcpkgs/cross-powerpc64-linux-musl/files/ppc64-vrregset-t-vrregs-fix.patch @@ -0,0 +1 @@ +../../musl/patches/ppc64-vrregset-t-vrregs-fix.patch \ No newline at end of file diff --git a/srcpkgs/cross-powerpc64-linux-musl/template b/srcpkgs/cross-powerpc64-linux-musl/template index c672e92f02ed85..71b9c0d1499088 100644 --- a/srcpkgs/cross-powerpc64-linux-musl/template +++ b/srcpkgs/cross-powerpc64-linux-musl/template @@ -9,7 +9,7 @@ _sysroot="/usr/${_triplet}" pkgname=cross-${_triplet} version=0.30 -revision=4 +revision=5 short_desc="Cross toolchain for powerpc64 with musl" maintainer="q66 " homepage="https://www.voidlinux.org/" @@ -149,6 +149,10 @@ _musl_build() { [ -f ${wrksrc}/.musl_build_done ] && return 0 cd ${wrksrc}/musl-${_musl_version} + + _apply_patch -p0 ${FILESDIR}/ppc64-vrregset-t-fix-layout.patch + _apply_patch -p0 ${FILESDIR}/ppc64-vrregset-t-vrregs-fix.patch + msg_normal "Building cross musl libc\n" CC="${_triplet}-gcc" LD="${_triplet}-ld" AR="${_triplet}-ar" \