From 89cc3dc3a5e454fa509d6bab5260b9691b1ff877 Mon Sep 17 00:00:00 2001 From: Hernan Martinez Date: Sun, 20 Apr 2025 05:55:13 -0600 Subject: [PATCH] helics: Enable aarch64 builds (#24054) --- .../001-aarch64-processor-name.patch | 82 +++++++++++++++++++ .../001-fix-build-with-fmt-11.patch | 10 --- mingw-w64-helics/PKGBUILD | 25 +++++- 3 files changed, 103 insertions(+), 14 deletions(-) create mode 100644 mingw-w64-helics/001-aarch64-processor-name.patch delete mode 100644 mingw-w64-helics/001-fix-build-with-fmt-11.patch diff --git a/mingw-w64-helics/001-aarch64-processor-name.patch b/mingw-w64-helics/001-aarch64-processor-name.patch new file mode 100644 index 0000000000..721ff6aad5 --- /dev/null +++ b/mingw-w64-helics/001-aarch64-processor-name.patch @@ -0,0 +1,82 @@ +diff -bur benchmarks-o/helics/helics_benchmark_util.h benchmarks/helics/helics_benchmark_util.h +--- a/benchmarks/helics/helics_benchmark_util.h 2025-04-20 04:56:10.042141600 -0600 ++++ b/benchmarks/helics/helics_benchmark_util.h 2025-04-20 05:00:45.004743300 -0600 +@@ -18,6 +18,29 @@ + #endif + + #if defined(_WIN32) || defined(WIN32) ++#ifdef _M_ARM64 ++#include ++inline std::string getCPUModel() ++{ ++ #define BUFSIZE 128 ++ ++ char answer[BUFSIZE] = ""; ++ char inBuffer[BUFSIZE] = ""; ++ const char *csName = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"; ++ HKEY hKey; ++ DWORD gotType; ++ DWORD gotSize = BUFSIZ; ++ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, csName, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { ++ if (!RegQueryValueExA(hKey, "ProcessorNameString", nullptr, &gotType, (PBYTE)(inBuffer), &gotSize)) { ++ if ((gotType == REG_SZ) && strlen(inBuffer)) { ++ strcpy(answer, inBuffer); ++ } ++ } ++ RegCloseKey(hKey); ++ } ++ return std::string(answer); ++} ++#else + # include + // code modified from https://weseetips.wordpress.com/tag/c-get-cpu-name/ + inline std::string getCPUModel() +@@ -43,6 +66,7 @@ + + return std::string(CPUBrandString); + } ++#endif // _M_ARM64 + #elif defined(__unix__) + # include + # include +diff -bur src-o/helics/core/helicsVersion.cpp src/helics/core/helicsVersion.cpp +--- a/src/helics/core/helicsVersion.cpp 2025-04-20 05:06:45.880215400 -0600 ++++ b/src/helics/core/helicsVersion.cpp 2025-04-20 05:07:49.429141100 -0600 +@@ -17,6 +17,29 @@ + #include + + #if defined(_WIN32) || defined(WIN32) ++#ifdef _M_ARM64 ++#include ++inline std::string getCPUModel() ++{ ++ #define BUFSIZE 128 ++ ++ char answer[BUFSIZE] = ""; ++ char inBuffer[BUFSIZE] = ""; ++ const char *csName = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"; ++ HKEY hKey; ++ DWORD gotType; ++ DWORD gotSize = BUFSIZ; ++ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, csName, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { ++ if (!RegQueryValueExA(hKey, "ProcessorNameString", nullptr, &gotType, (PBYTE)(inBuffer), &gotSize)) { ++ if ((gotType == REG_SZ) && strlen(inBuffer)) { ++ strcpy(answer, inBuffer); ++ } ++ } ++ RegCloseKey(hKey); ++ } ++ return std::string(answer); ++} ++#else + # include + // code modified from https://weseetips.wordpress.com/tag/c-get-cpu-name/ + inline std::string getCPUModel() +@@ -42,6 +65,7 @@ + + return std::string(CPUBrandString); + } ++#endif // _M_ARM64 + #elif defined(__unix__) + # include + inline std::string getCPUModel() diff --git a/mingw-w64-helics/001-fix-build-with-fmt-11.patch b/mingw-w64-helics/001-fix-build-with-fmt-11.patch deleted file mode 100644 index 122a12f953..0000000000 --- a/mingw-w64-helics/001-fix-build-with-fmt-11.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/src/helics/application_api/helicsTypes.cpp -+++ b/src/helics/application_api/helicsTypes.cpp -@@ -18,6 +18,7 @@ - - #include - #include -+#include - #include - #include - #include diff --git a/mingw-w64-helics/PKGBUILD b/mingw-w64-helics/PKGBUILD index 1ab093d8d4..a6901ed47d 100644 --- a/mingw-w64-helics/PKGBUILD +++ b/mingw-w64-helics/PKGBUILD @@ -4,10 +4,10 @@ _realname=helics pkgbase=mingw-w64-${_realname} pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" pkgver=3.6.1 -pkgrel=1 +pkgrel=2 pkgdesc="Hierarchical Engine for Large-scale Infrastructure Co-Simulation (mingw-w64)" arch=('any') -mingw_arch=('mingw64' 'ucrt64' 'clang64') +mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') url="https://github.com/GMLC-TDC/HELICS" license=('spdx:BSD-3-Clause') depends=("${MINGW_PACKAGE_PREFIX}-zeromq" @@ -17,8 +17,25 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-ninja" "${MINGW_PACKAGE_PREFIX}-boost") options=('!strip') -source=("https://github.com/GMLC-TDC/HELICS/releases/download/v${pkgver}/HELICS-v${pkgver}-source.tar.gz") -sha256sums=('d607c1b47dd5ae32f3076c4aa4aa584d37b6056a9bd049234494698ed95cd70f') +source=("https://github.com/GMLC-TDC/HELICS/releases/download/v${pkgver}/HELICS-v${pkgver}-source.tar.gz" + "001-aarch64-processor-name.patch") +sha256sums=('d607c1b47dd5ae32f3076c4aa4aa584d37b6056a9bd049234494698ed95cd70f' + '5853683dc368453155bf690fb9082b98e88da5d854de8f2da8f32830996f0013') + +apply_patch_with_msg() { + for _patch in "$@" + do + msg2 "Applying ${_patch}" + patch -Nbp1 -i "${srcdir}/${_patch}" + done +} + +prepare() { + cd "${srcdir}" + + apply_patch_with_msg \ + 001-aarch64-processor-name.patch +} build() { declare -a extra_config