Hello ports list,

I want to commit this fix for an error in math/py-scipy on powerpc:
"ld: error: unable to find library -latomic"

It moves the configure check for -latomic from the C compiler to the
C++ compiler, because OpenBSD is mixing compilers,
 - base-clang for C++ (from COMPILER)
 - ports-gcc for C (forced by fortran in MODULES)

They find functions like __atomic_fetch_xor_8 in different ways,
 - ports-gcc needs -latomic
 - base-clang must not have -latomic, because it is not looking in
   /usr/local/lib where gcc installed libatomic.

std::atomic<uint64_t> in C++ calls such functions on powerpc (but not
on most other archs).  powerpc broke when configure decided to pass
-latomic to gcc, but build passed -latomic to clang.  This diff drops
the -latomic, so my powerpc can package scipy.  (I don't know whether
this package works at runtime.)

--gkoehler

Index: Makefile
===================================================================
RCS file: /cvs/ports/math/py-scipy/Makefile,v
diff -u -p -r1.72 Makefile
--- Makefile    20 May 2025 12:10:50 -0000      1.72
+++ Makefile    11 Sep 2025 02:59:17 -0000
@@ -4,7 +4,7 @@ COMMENT=        maths, science and engineering 
 MODPY_DISTV=   1.13.1
 DISTNAME=      scipy-${MODPY_DISTV}
 PKGNAME=       py-${DISTNAME}
-REVISION=      6
+REVISION=      7
 
 CATEGORIES=    math devel
 
Index: patches/patch-scipy_meson_build
===================================================================
RCS file: /cvs/ports/math/py-scipy/patches/patch-scipy_meson_build,v
diff -u -p -r1.1 patch-scipy_meson_build
--- patches/patch-scipy_meson_build     19 Oct 2024 03:32:48 -0000      1.1
+++ patches/patch-scipy_meson_build     11 Sep 2025 02:59:17 -0000
@@ -1,3 +1,6 @@
+Move the check for -latomic from C to C++.  Fixes powerpc, where gcc
+must have -latomic but clang++ must not have -latomic.
+
 Index: scipy/meson.build
 --- scipy/meson.build.orig
 +++ scipy/meson.build
@@ -12,3 +15,26 @@ Index: scipy/meson.build
  
  # First try scipy-openblas, and if found don't look for cblas or lapack, we
  # know what's inside the scipy-openblas wheels already.
+@@ -384,18 +384,18 @@ code_non_lockfree = '''
+           (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
+   }
+ '''
+-if cc.get_id() != 'msvc'
+-  if not cc.links(
++if cpp.get_id() != 'msvc'
++  if not cpp.links(
+       code_non_lockfree,
+       name : 'Check atomic builtins without -latomic'
+     )
+-    atomic_dep = cc.find_library('atomic', required: false)
++    atomic_dep = cpp.find_library('atomic', required: false)
+     if atomic_dep.found()
+       # We're not sure that with `-latomic` things will work for all 
compilers,
+       # so verify and only keep libatomic as a dependency if this works. It is
+       # possible the build will fail later otherwise - unclear under what
+       # circumstances (compilers, runtimes, etc.) exactly.
+-      if not cc.links(
++      if not cpp.links(
+           code_non_lockfree,
+           dependencies: atomic_dep,
+           name : 'Check atomic builtins with -latomic'

Reply via email to