File: link_atomic.patch

package info (click to toggle)
netgen 6.2.2404%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 12,872 kB
  • sloc: cpp: 163,119; tcl: 6,316; python: 2,612; sh: 511; makefile: 74
file content (29 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Index: netgen/libsrc/core/CMakeLists.txt
===================================================================
--- netgen.orig/libsrc/core/CMakeLists.txt	2024-09-15 11:59:35.490138446 +0200
+++ netgen/libsrc/core/CMakeLists.txt	2024-09-15 11:59:35.486138412 +0200
@@ -83,6 +83,24 @@
     target_link_libraries(ngcore PRIVATE ${NUMA_LIBRARY})
 endif(USE_NUMA)
 
+# some 32-bit arches do not automatically link to atomic symbols (util.hpp)
+# cf. https://github.com/google/highway/pull/1008
+check_cxx_source_compiles(
+"#include <atomic>
+#include <cstdint>
+std::atomic<uint8_t> n8 (0);   // basic (should not fail)
+std::atomic<uint64_t> n64 (0); // expected to fail on armel, mipsel, powerpc (undefined reference to `__atomic_fetch_add_8')
+int main() {
+  ++n8;
+  ++n64;
+  return 0;
+}"
+ HAS_INTERNAL_ATOMIC
+)
+if(NOT HAS_INTERNAL_ATOMIC)
+  target_link_libraries(ngcore INTERFACE atomic)
+endif()
+
 install(TARGETS ngcore DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen)
 
 target_link_libraries(ngcore PRIVATE "$<BUILD_INTERFACE:netgen_python>" ${CMAKE_THREAD_LIBS_INIT})