Skip to content

Commit

Permalink
Add patch to check if platform requires linking to atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
nightlark committed Dec 27, 2024
1 parent 9c6a7de commit 80ed1fc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions H/HELICS/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ HELICS_VERSION = v"3.6.0"
HELICS_SHA = "e111ac5d92e808f27e330afd1f8b8ca4d86adf6ccd74e3280f2d40fb3e0e2ce9"

sources = [
DirectorySource("./bundled"),
ArchiveSource("https://github.com/GMLC-TDC/HELICS/releases/download/v$HELICS_VERSION/Helics-v$HELICS_VERSION-source.tar.gz",
"$HELICS_SHA"),
ArchiveSource("https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.15.sdk.tar.xz",
Expand All @@ -42,6 +43,8 @@ apk del cmake
cd $WORKSPACE/srcdir
atomic_patch -p1 $WORKSPACE/srcdir/patches/link-atomic.patch
cmake -B build \
-DCMAKE_FIND_ROOT_PATH="${prefix}" \
-DCMAKE_INSTALL_PREFIX="${prefix}" \
Expand Down
30 changes: 30 additions & 0 deletions H/HELICS/bundled/patches/link-atomic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -387,6 +387,27 @@ if(HELICS_ENABLE_MPI_CORE)
list(APPEND VCPKG_MANIFEST_FEATURES "mpi")
endif()

+# -------------------------------------------------------------
+# check if atomic needs linking
+# -------------------------------------------------------------
+
+check_cxx_source_compiles("
+#include <atomic>
+#include <cstdint>
+std::atomic<uint8_t> n8 (0);
+std::atomic<uint64_t> n64 (0);
+int main() {
+uint8_t i = n8.load(std::memory_order_relaxed);
+uint64_t j = n64.load(std::memory_order_relaxed);
+return std::atomic_is_lock_free(&n8)
+ & std::atomic_is_lock_free(&n64);
+}"
+LIBATOMIC_NOT_NEEDED)
+
+IF (NOT LIBATOMIC_NOT_NEEDED)
+ target_link_libraries(helics_base INTERFACE atomic)
+endif()
+
# -------------------------------------------------------------
# finding MPI
# -------------------------------------------------------------

0 comments on commit 80ed1fc

Please sign in to comment.