From 5b98ea6da85a86c6bb0e227303fe6c884a5c1207 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Thu, 29 Aug 2024 01:56:24 +0800 Subject: [PATCH] py-greenlet: fix build for powerpc --- python/py-greenlet/Portfile | 9 ++++ ...tch_ppc_macosx.h-fix-wrong-assembler.patch | 32 +++++++++++ ...2-switch_ppc_unix.h-fix-the-same-bug.patch | 31 +++++++++++ ...select.h-fix-PowerPC-macro-for-Apple.patch | 22 ++++++++ .../files/patch-powerpc-2.0.2.diff | 53 +++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 python/py-greenlet/files/0001-switch_ppc_macosx.h-fix-wrong-assembler.patch create mode 100644 python/py-greenlet/files/0002-switch_ppc_unix.h-fix-the-same-bug.patch create mode 100644 python/py-greenlet/files/0003-slp_platformselect.h-fix-PowerPC-macro-for-Apple.patch create mode 100644 python/py-greenlet/files/patch-powerpc-2.0.2.diff diff --git a/python/py-greenlet/Portfile b/python/py-greenlet/Portfile index 5ef2d9c546bf3..2a8da57805468 100644 --- a/python/py-greenlet/Portfile +++ b/python/py-greenlet/Portfile @@ -54,9 +54,18 @@ if {${name} ne ${subport}} { checksums rmd160 260d2414cd1be4c7af131f482a4c82b6762d7f87 \ sha256 e7c8dc13af7db097bed64a051d2dd49e9f0af495c26995c00a9ee842690d34c0 \ size 164980 + + patchfiles-append patch-powerpc-2.0.2.diff + python.pep517 no depends_build-append \ port:py${python.version}-setuptools + } else { + # https://github.com/python-greenlet/greenlet/pull/419 + # Drop once merged to upstream. + patchfiles-append 0001-switch_ppc_macosx.h-fix-wrong-assembler.patch \ + 0002-switch_ppc_unix.h-fix-the-same-bug.patch \ + 0003-slp_platformselect.h-fix-PowerPC-macro-for-Apple.patch } # cc1plus: error: unrecognized command line option "-std=gnu++11" diff --git a/python/py-greenlet/files/0001-switch_ppc_macosx.h-fix-wrong-assembler.patch b/python/py-greenlet/files/0001-switch_ppc_macosx.h-fix-wrong-assembler.patch new file mode 100644 index 0000000000000..f7fe4f6333a56 --- /dev/null +++ b/python/py-greenlet/files/0001-switch_ppc_macosx.h-fix-wrong-assembler.patch @@ -0,0 +1,32 @@ +From fd27352ba171d49b709db30d5e5a0e460a31ab8c Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Wed, 28 Aug 2024 23:18:42 +0800 +Subject: [PATCH 1/3] switch_ppc_macosx.h: fix wrong assembler + +Fixes: https://github.com/python-greenlet/greenlet/issues/418 +--- + src/greenlet/platform/switch_ppc_macosx.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git src/greenlet/platform/switch_ppc_macosx.h src/greenlet/platform/switch_ppc_macosx.h +index d6e5a03..bd414c6 100644 +--- src/greenlet/platform/switch_ppc_macosx.h ++++ src/greenlet/platform/switch_ppc_macosx.h +@@ -49,7 +49,7 @@ slp_switch(void) + int err; + int *stackref, stsizediff; + __asm__ volatile ("" : : : REGS_TO_SAVE); +- __asm__ ("; asm block 2\n\tmr %0, r1" : "=g" (stackref) : ); ++ __asm__ ("; asm block 2\n\tmr %0, r1" : "=r" (stackref) : ); + { + SLP_SAVE_STATE(stackref, stsizediff); + __asm__ volatile ( +@@ -58,7 +58,7 @@ slp_switch(void) + "\tadd r1, r1, r11\n" + "\tadd r30, r30, r11\n" + : /* no outputs */ +- : "g" (stsizediff) ++ : "r" (stsizediff) + : "r11" + ); + SLP_RESTORE_STATE(); diff --git a/python/py-greenlet/files/0002-switch_ppc_unix.h-fix-the-same-bug.patch b/python/py-greenlet/files/0002-switch_ppc_unix.h-fix-the-same-bug.patch new file mode 100644 index 0000000000000..da6f9334e2ce4 --- /dev/null +++ b/python/py-greenlet/files/0002-switch_ppc_unix.h-fix-the-same-bug.patch @@ -0,0 +1,31 @@ +From 4d38954377e91d30c213fb198b5cf2fcae403ba3 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Wed, 28 Aug 2024 23:26:30 +0800 +Subject: [PATCH 2/3] switch_ppc_unix.h: fix the same bug + +--- + src/greenlet/platform/switch_ppc_unix.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git src/greenlet/platform/switch_ppc_unix.h src/greenlet/platform/switch_ppc_unix.h +index ca590a5..bb18808 100644 +--- src/greenlet/platform/switch_ppc_unix.h ++++ src/greenlet/platform/switch_ppc_unix.h +@@ -50,7 +50,7 @@ slp_switch(void) + int err; + int *stackref, stsizediff; + __asm__ volatile ("" : : : REGS_TO_SAVE); +- __asm__ ("mr %0, 1" : "=g" (stackref) : ); ++ __asm__ ("mr %0, 1" : "=r" (stackref) : ); + { + SLP_SAVE_STATE(stackref, stsizediff); + __asm__ volatile ( +@@ -58,7 +58,7 @@ slp_switch(void) + "add 1, 1, 11\n" + "add 30, 30, 11\n" + : /* no outputs */ +- : "g" (stsizediff) ++ : "r" (stsizediff) + : "11" + ); + SLP_RESTORE_STATE(); diff --git a/python/py-greenlet/files/0003-slp_platformselect.h-fix-PowerPC-macro-for-Apple.patch b/python/py-greenlet/files/0003-slp_platformselect.h-fix-PowerPC-macro-for-Apple.patch new file mode 100644 index 0000000000000..f1e312672865d --- /dev/null +++ b/python/py-greenlet/files/0003-slp_platformselect.h-fix-PowerPC-macro-for-Apple.patch @@ -0,0 +1,22 @@ +From ff0d5973d89dd86b17a48f1fb847a57df28db914 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Wed, 28 Aug 2024 23:29:10 +0800 +Subject: [PATCH 3/3] slp_platformselect.h: fix PowerPC macro for Apple + +--- + src/greenlet/slp_platformselect.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git src/greenlet/slp_platformselect.h src/greenlet/slp_platformselect.h +index c959f0f..22330ee 100644 +--- src/greenlet/slp_platformselect.h ++++ src/greenlet/slp_platformselect.h +@@ -21,7 +21,7 @@ extern "C" { + # include "platform/switch_ppc64_linux.h" /* gcc on PowerPC 64-bit */ + #elif defined(__GNUC__) && defined(__PPC__) && (defined(__linux__) || defined(__FreeBSD__)) + # include "platform/switch_ppc_linux.h" /* gcc on PowerPC */ +-#elif defined(__GNUC__) && defined(__ppc__) && defined(__APPLE__) ++#elif defined(__GNUC__) && defined(__POWERPC__) && defined(__APPLE__) + # include "platform/switch_ppc_macosx.h" /* Apple MacOS X on PowerPC */ + #elif defined(__GNUC__) && defined(__powerpc64__) && defined(_AIX) + # include "platform/switch_ppc64_aix.h" /* gcc on AIX/PowerPC 64-bit */ diff --git a/python/py-greenlet/files/patch-powerpc-2.0.2.diff b/python/py-greenlet/files/patch-powerpc-2.0.2.diff new file mode 100644 index 0000000000000..833c63216c211 --- /dev/null +++ b/python/py-greenlet/files/patch-powerpc-2.0.2.diff @@ -0,0 +1,53 @@ +--- src/greenlet/slp_platformselect.h 2023-01-28 22:19:23.000000000 +0800 ++++ src/greenlet/slp_platformselect.h 2024-08-28 23:43:43.000000000 +0800 +@@ -20,7 +20,7 @@ + #include "platform/switch_ppc64_linux.h" /* gcc on PowerPC 64-bit */ + #elif defined(__GNUC__) && defined(__PPC__) && (defined(__linux__) || defined(__FreeBSD__)) + #include "platform/switch_ppc_linux.h" /* gcc on PowerPC */ +-#elif defined(__GNUC__) && defined(__ppc__) && defined(__APPLE__) ++#elif defined(__GNUC__) && defined(__POWERPC__) && defined(__APPLE__) + #include "platform/switch_ppc_macosx.h" /* Apple MacOS X on PowerPC */ + #elif defined(__GNUC__) && defined(__powerpc64__) && defined(_AIX) + #include "platform/switch_ppc64_aix.h" /* gcc on AIX/PowerPC 64-bit */ + +--- src/greenlet/platform/switch_ppc_macosx.h 2023-01-28 22:19:23.000000000 +0800 ++++ src/greenlet/platform/switch_ppc_macosx.h 2024-08-28 23:42:43.000000000 +0800 +@@ -49,7 +49,7 @@ + register int err; + register int *stackref, stsizediff; + __asm__ volatile ("" : : : REGS_TO_SAVE); +- __asm__ ("; asm block 2\n\tmr %0, r1" : "=g" (stackref) : ); ++ __asm__ ("; asm block 2\n\tmr %0, r1" : "=r" (stackref) : ); + { + SLP_SAVE_STATE(stackref, stsizediff); + __asm__ volatile ( +@@ -58,7 +58,7 @@ + "\tadd r1, r1, r11\n" + "\tadd r30, r30, r11\n" + : /* no outputs */ +- : "g" (stsizediff) ++ : "r" (stsizediff) + : "r11" + ); + SLP_RESTORE_STATE(); + +--- src/greenlet/platform/switch_ppc_unix.h 2023-01-28 22:19:23.000000000 +0800 ++++ src/greenlet/platform/switch_ppc_unix.h 2024-08-28 23:42:43.000000000 +0800 +@@ -50,7 +50,7 @@ + register int err; + register int *stackref, stsizediff; + __asm__ volatile ("" : : : REGS_TO_SAVE); +- __asm__ ("mr %0, 1" : "=g" (stackref) : ); ++ __asm__ ("mr %0, 1" : "=r" (stackref) : ); + { + SLP_SAVE_STATE(stackref, stsizediff); + __asm__ volatile ( +@@ -58,7 +58,7 @@ + "add 1, 1, 11\n" + "add 30, 30, 11\n" + : /* no outputs */ +- : "g" (stsizediff) ++ : "r" (stsizediff) + : "11" + ); + SLP_RESTORE_STATE();