From 9cab11462a6a6a28ffe7370a022b8c0dc47be38a Mon Sep 17 00:00:00 2001 From: q66 Date: Tue, 31 Mar 2020 02:22:00 +0200 Subject: [PATCH] janet: fix on ppc* --- srcpkgs/janet/patches/328.patch | 80 +++++++++++++++++++++++++++++ srcpkgs/janet/patches/dynlink.patch | 4 +- srcpkgs/janet/template | 5 +- 3 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 srcpkgs/janet/patches/328.patch diff --git a/srcpkgs/janet/patches/328.patch b/srcpkgs/janet/patches/328.patch new file mode 100644 index 00000000000..cb869f169bb --- /dev/null +++ b/srcpkgs/janet/patches/328.patch @@ -0,0 +1,80 @@ +From 459e75bec840c1644f884795330ab7c3aca5a532 Mon Sep 17 00:00:00 2001 +From: q66 +Date: Mon, 30 Mar 2020 18:30:19 +0200 +Subject: [PATCH 1/3] Fix endian check for little endian PowerPC and maybe + others + +This fixes various subtle breakage on ppc64le at very least. +--- + src/include/janet.h | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/src/include/janet.h b/src/include/janet.h +index 6d5b7de0..9fb9f416 100644 +--- a/src/include/janet.h ++++ b/src/include/janet.h +@@ -97,7 +97,14 @@ extern "C" { + #endif + + /* Check big endian */ +-#if defined(__MIPSEB__) /* MIPS 32-bit */ \ ++#if defined(__LITTLE_ENDIAN__) || \ ++ (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) ++/* If we know the target is LE, always use that - e.g. ppc64 little endian ++ * defines the __LITTLE_ENDIAN__ macro in the ABI spec, so we can rely ++ * on that and if that's not defined, fall back to big endian assumption ++ */ ++#define JANET_LITTLE_ENDIAN 1 ++#elif defined(__MIPSEB__) /* MIPS 32-bit */ \ + || defined(__ppc__) || defined(__PPC__) /* CPU(PPC) - PowerPC 32-bit */ \ + || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) \ + || defined(_M_PPC) || defined(__PPC) \ + +From 12b183179a012554e07dce93c5b3d7173db54e8b Mon Sep 17 00:00:00 2001 +From: q66 +Date: Mon, 30 Mar 2020 19:14:00 +0200 +Subject: [PATCH 2/3] Fix typo in big endian unmarshalling code + +This was subtly breaking everything. +--- + src/core/marsh.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/core/marsh.c b/src/core/marsh.c +index d6d6353c..d9cd3f70 100644 +--- a/src/core/marsh.c ++++ b/src/core/marsh.c +@@ -1141,7 +1141,7 @@ static const uint8_t *unmarshal_one( + u.bytes[0] = data[8]; + u.bytes[1] = data[7]; + u.bytes[2] = data[6]; +- u.bytes[5] = data[5]; ++ u.bytes[3] = data[5]; + u.bytes[4] = data[4]; + u.bytes[5] = data[3]; + u.bytes[6] = data[2]; + +From 8b7c160e73fd4f17ff0393be61c04abebeb71717 Mon Sep 17 00:00:00 2001 +From: q66 +Date: Mon, 30 Mar 2020 19:19:51 +0200 +Subject: [PATCH 3/3] Fix wrong check on big endian systems + +We can't randomly type pun random-sized types on big endian +systems. +--- + src/include/janet.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/include/janet.h b/src/include/janet.h +index 9fb9f416..d874cb53 100644 +--- a/src/include/janet.h ++++ b/src/include/janet.h +@@ -663,7 +663,7 @@ struct Janet { + #define janet_type(x) ((x).type) + #define janet_checktype(x, t) ((x).type == (t)) + #define janet_truthy(x) \ +- ((x).type != JANET_NIL && ((x).type != JANET_BOOLEAN || ((x).as.integer & 0x1))) ++ ((x).type != JANET_NIL && ((x).type != JANET_BOOLEAN || ((x).as.u64 & 0x1))) + + #define janet_unwrap_struct(x) ((const JanetKV *)(x).as.pointer) + #define janet_unwrap_tuple(x) ((const Janet *)(x).as.pointer) diff --git a/srcpkgs/janet/patches/dynlink.patch b/srcpkgs/janet/patches/dynlink.patch index 5a68523cb52..472a987ada2 100644 --- a/srcpkgs/janet/patches/dynlink.patch +++ b/srcpkgs/janet/patches/dynlink.patch @@ -1,5 +1,5 @@ ---- meson.build.orig -+++ meson.build +--- a/meson.build.orig ++++ b/meson.build @@ -167,6 +167,8 @@ libjanet = library('janet', janetc, include_directories : incdir, diff --git a/srcpkgs/janet/template b/srcpkgs/janet/template index 4d5e52c8ad4..a640c751036 100644 --- a/srcpkgs/janet/template +++ b/srcpkgs/janet/template @@ -9,10 +9,7 @@ license="MIT" homepage="https://janet-lang.org/" distfiles="https://github.com/janet-lang/janet/archive/v${version}.tar.gz" checksum=e02ae5c7b4579a23e3f30636c16d248273ed119467a076d18c9362e858eb9812 - -case "$XBPS_TARGET_MACHINE" in - ppc*) broken="testsuite fails";; -esac +patch_args="-Np1" post_install() { vlicense LICENSE