x11/gnustep/libobjc2 is disabling its objc_method_cache_version only
on powerpc.  This broke x11/gnustep/base, which assumes that
objc_method_cache_version exists.  With this patch, it exists and my
powerpc can build base and run x11/gnustep/terminal.

objc_method_cache_version is a 64-bit atomic variable.  Most archs
have 64-bit atomic ops in hardware, but powerpc needs software
functions like __atomic_fetch_add_8.  Enabling it might cause trouble
with gcc (missing -latomic), but works on OpenBSD with clang and
libcompiler_rt.

ok?
--gkoehler

Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/gnustep/libobjc2/Makefile,v
diff -u -p -r1.39 Makefile
--- Makefile    22 Apr 2024 06:47:57 -0000      1.39
+++ Makefile    10 Sep 2025 01:49:50 -0000
@@ -9,6 +9,7 @@ GH_PROJECT =    libobjc2
 GH_TAGNAME =   v${VERSION}
 DISTNAME =     libobjc2-${VERSION:S/_//}
 PKGNAME =      gnustep-${DISTNAME}
+REVISION =     0
 
 SHARED_LIBS += objc2   3.0
 SHARED_LIBS +=  objcxx 2.0
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt        10 Sep 2025 01:49:50 -0000
@@ -0,0 +1,14 @@
+Enable objc_method_cache_version on powerpc.
+
+Index: CMakeLists.txt
+--- CMakeLists.txt.orig
++++ CMakeLists.txt
+@@ -188,7 +188,7 @@ add_compile_options($<$<STREQUAL:${CMAKE_SYSTEM_PROCES
+ # which is used in safe caching.
+ # You must also update the guard in objc/runtime.h, when updating
+ # this macro.
+-if (ARCHITECTURE STREQUAL "powerpc")
++if (OFF AND ARCHITECTURE STREQUAL "powerpc")
+       add_definitions(-DNO_SAFE_CACHING)
+ endif()
+ 
Index: patches/patch-objc_slot_h
===================================================================
RCS file: patches/patch-objc_slot_h
diff -N patches/patch-objc_slot_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-objc_slot_h   10 Sep 2025 01:49:50 -0000
@@ -0,0 +1,14 @@
+Enable objc_method_cache_version on powerpc.
+
+Index: objc/slot.h
+--- objc/slot.h.orig
++++ objc/slot.h
+@@ -31,7 +31,7 @@ struct objc_slot2
+  * Caching is disabled on targets without native 64-bit atomics support such
+  * as PowerPC 32-bit.
+  */
+-#if defined(__powerpc__) && !defined(__powerpc64__)
++#if 0 && defined(__powerpc__) && !defined(__powerpc64__)
+ #else
+ OBJC_PUBLIC extern _Atomic(uint64_t) objc_method_cache_version;
+ #endif

Reply via email to