Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py-greenlet: fix build for powerpc #25503

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions python/py-greenlet/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From fd27352ba171d49b709db30d5e5a0e460a31ab8c Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <[email protected]>
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();
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 4d38954377e91d30c213fb198b5cf2fcae403ba3 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <[email protected]>
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();
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From ff0d5973d89dd86b17a48f1fb847a57df28db914 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <[email protected]>
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 */
53 changes: 53 additions & 0 deletions python/py-greenlet/files/patch-powerpc-2.0.2.diff
Original file line number Diff line number Diff line change
@@ -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();
Loading