From 339402b295eef5bd3f26d9395ec35099b278411a Mon Sep 17 00:00:00 2001 From: Debian Python Team Date: Sat, 18 Feb 2023 15:12:32 +0000 Subject: [PATCH] fix_highs_atomic_PR17777 =================================================================== Gbp-Pq: Name fix_highs_atomic_PR17777.patch --- scipy/meson.build | 19 +++++++++++++++++++ scipy/optimize/_highs/meson.build | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/scipy/meson.build b/scipy/meson.build index 87f7afca..64515495 100644 --- a/scipy/meson.build +++ b/scipy/meson.build @@ -292,6 +292,25 @@ else use_math_defines = [] endif +# Determine whether it is necessary to link libatomic. This could be the case +# e.g. on 32-bit platforms when atomic operations are used on 64-bit types. +# The check is copied from Mesa . +atomic_dep = dependency('', required : false) +if cc.get_id() != 'msvc' + if not cc.links(''' + #include + int main() { + struct { + uint64_t *v; + } x; + return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) & + (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL); + }''', + name : 'GCC atomic builtins required -latomic') + atomic_dep = cc.find_library('atomic') + endif +endif + # Suppress warning for deprecated Numpy API. # (Suppress warning messages emitted by #warning directives). # Replace with numpy_nodepr_api after Cython 3.0 is out diff --git a/scipy/optimize/_highs/meson.build b/scipy/optimize/_highs/meson.build index 0d9ffba0..5051a08b 100644 --- a/scipy/optimize/_highs/meson.build +++ b/scipy/optimize/_highs/meson.build @@ -237,7 +237,7 @@ _highs_wrapper = py3.extension_module('_highs_wrapper', '../../_lib/highs/src/lp_data/', '../../_lib/highs/src/util/' ], - dependencies: thread_dep, + dependencies: [thread_dep, atomic_dep], link_args: version_link_args, link_with: [highs_lib, ipx_lib, basiclu_lib], cpp_args: [highs_flags, highs_define_macros, cython_c_args], -- 2.30.2