]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127897: fix HACL* build on macOS/Catalina (GH-127932)
authoraeiouaeiouaeiouaeiouaeiouaeiou <aeioudev@outlook.com>
Wed, 18 Dec 2024 06:14:16 +0000 (09:14 +0300)
committerGitHub <noreply@github.com>
Wed, 18 Dec 2024 06:14:16 +0000 (22:14 -0800)
gh-127897: Update HACL* module from upstream sources to get:

- Lib_Memzero0.c: don't use memset_s() on macOS <10.9
- Use _mm_malloc() for KRML_ALIGNED_MALLOC on macOS <10.15
- Add LEGACY_MACOS macros, use _mm_free() for KRML_ALIGNED_FREE on macOS <10.15

Misc/sbom.spdx.json
Modules/_hacl/Lib_Memzero0.c
Modules/_hacl/include/krml/internal/target.h

index 739e005646ba9772e21f9a5c482e429d68f33fb2..b4d785f65639a5ed68f04998d2f4dbfc7ed56256 100644 (file)
       "checksums": [
         {
           "algorithm": "SHA1",
-          "checksumValue": "2e08072c0c57dac02b67f3f71d77068c537ac02e"
+          "checksumValue": "118dc712780ea680affa8d9794470440eb87ff10"
         },
         {
           "algorithm": "SHA256",
-          "checksumValue": "e69fd3e84f77873ecb414f5300761b686321d01f5710ccf2517765236b08fc25"
+          "checksumValue": "b017e7d5662a308c938cf4e4b919680c8f3e27f42975ca152b62fe65c5f7fb0c"
         }
       ],
       "fileName": "Modules/_hacl/Lib_Memzero0.c"
       "checksums": [
         {
           "algorithm": "SHA1",
-          "checksumValue": "9881567f43deb32bae77a84b2d349858a24b6685"
+          "checksumValue": "9c5cac1582dcd6e0d0a4142e6e8b285b4cb7d9e6"
         },
         {
           "algorithm": "SHA256",
-          "checksumValue": "3382156e32fcb376009177d3d2dc9712ff7c8c02afb97b3e16d98b41a2114f84"
+          "checksumValue": "b1e32138ac8c262e872f7da43ec80c1e54c08bcbdec4b7be17117aa25807f87e"
         }
       ],
       "fileName": "Modules/_hacl/include/krml/internal/target.h"
index 5c269d231de82fb21457cafc271ce691bec70687..f01568a138648f94cb021b024c1c62220cf3c2ff 100644 (file)
@@ -8,6 +8,10 @@
 #include <windows.h>
 #endif
 
+#if defined(__APPLE__) && defined(__MACH__)
+#include <AvailabilityMacros.h>
+#endif
+
 #if (defined(__APPLE__) && defined(__MACH__)) || defined(__linux__)
 #define __STDC_WANT_LIB_EXT1__ 1
 #include <string.h>
@@ -37,7 +41,7 @@ void Lib_Memzero0_memzero0(void *dst, uint64_t len) {
 
   #ifdef _WIN32
     SecureZeroMemory(dst, len_);
-  #elif defined(__APPLE__) && defined(__MACH__)
+  #elif defined(__APPLE__) && defined(__MACH__) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
     memset_s(dst, len_, 0, len_);
   #elif (defined(__linux__) && !defined(LINUX_NO_EXPLICIT_BZERO)) || defined(__FreeBSD__)
     explicit_bzero(dst, len_);
index fd74d3da6845677201daa8e864da0f8b639acff4..9b403c36ceca1903c1526905da8eac57cbc45e38 100644 (file)
 #  define inline __inline__
 #endif
 
+/* There is no support for aligned_alloc() in macOS before Catalina, so
+ * let's make a macro to use _mm_malloc() and _mm_free() functions
+ * from mm_malloc.h. */
+#if defined(__APPLE__) && defined(__MACH__)
+#  include <AvailabilityMacros.h>
+#  if defined(MAC_OS_X_VERSION_MIN_REQUIRED) &&                                \
+   (MAC_OS_X_VERSION_MIN_REQUIRED < 101500)
+#    include <mm_malloc.h>
+#    define LEGACY_MACOS
+#  else
+#    undef LEGACY_MACOS
+#endif
+#endif
+
 /******************************************************************************/
 /* Macros that KaRaMeL will generate.                                         */
 /******************************************************************************/
       defined(_MSC_VER) ||                                                     \
       (defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR)))
 #    define KRML_ALIGNED_MALLOC(X, Y) _aligned_malloc(Y, X)
+#  elif defined(LEGACY_MACOS)
+#    define KRML_ALIGNED_MALLOC(X, Y) _mm_malloc(Y, X)
 #  else
 #    define KRML_ALIGNED_MALLOC(X, Y) aligned_alloc(X, Y)
 #  endif
       defined(_MSC_VER) ||                                                     \
       (defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR)))
 #    define KRML_ALIGNED_FREE(X) _aligned_free(X)
+#  elif defined(LEGACY_MACOS)
+#    define KRML_ALIGNED_FREE(X) _mm_free(X)
 #  else
 #    define KRML_ALIGNED_FREE(X) free(X)
 #  endif