From 80ed1fc758063081e29ecb0aa1fbed64700ee68e Mon Sep 17 00:00:00 2001 From: Ryan Mast Date: Fri, 27 Dec 2024 10:52:56 -0800 Subject: [PATCH] Add patch to check if platform requires linking to `atomic` --- H/HELICS/build_tarballs.jl | 3 +++ H/HELICS/bundled/patches/link-atomic.patch | 30 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 H/HELICS/bundled/patches/link-atomic.patch diff --git a/H/HELICS/build_tarballs.jl b/H/HELICS/build_tarballs.jl index 57e51c0a3ad..fa48d950dfa 100644 --- a/H/HELICS/build_tarballs.jl +++ b/H/HELICS/build_tarballs.jl @@ -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", @@ -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}" \ diff --git a/H/HELICS/bundled/patches/link-atomic.patch b/H/HELICS/bundled/patches/link-atomic.patch new file mode 100644 index 00000000000..ed1b212bdb7 --- /dev/null +++ b/H/HELICS/bundled/patches/link-atomic.patch @@ -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 ++#include ++std::atomic n8 (0); ++std::atomic 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 + # -------------------------------------------------------------