[libsodium] Fix arm builds (android NDK r26) (#37932)

Upstream patch, adjusted. Cherry-picked from
https://github.com/microsoft/vcpkg/pull/35851.
Fixes https://github.com/microsoft/vcpkg/issues/37423,
This commit is contained in:
Kai Pastor 2024-04-03 04:21:35 +02:00 committed by GitHub
parent 733b918efc
commit 11ed79186f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 128 additions and 2 deletions

View File

@ -0,0 +1,119 @@
diff --git a/configure.ac b/configure.ac
index df83ef5..be67d34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -398,11 +398,6 @@ AS_IF([test "x$EMSCRIPTEN" = "x"], [
have_armcrypto=no
AC_MSG_CHECKING(for ARM crypto instructions set)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
- #ifdef __clang__
- # pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function)
- #elif defined(__GNUC__)
- # pragma GCC target("+simd+crypto")
- #endif
#ifndef __ARM_FEATURE_CRYPTO
# define __ARM_FEATURE_CRYPTO 1
#endif
@@ -411,6 +406,12 @@ AS_IF([test "x$EMSCRIPTEN" = "x"], [
#endif
#include <arm_neon.h>
+
+ #ifdef __clang__
+ # pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function)
+ #elif defined(__GNUC__)
+ # pragma GCC target("+simd+crypto")
+ #endif
]], [[
vaeseq_u8(vmovq_n_u8(0), vmovq_n_u8(0));
diff --git a/src/libsodium/crypto_aead/aegis128l/aegis128l_armcrypto.c b/src/libsodium/crypto_aead/aegis128l/aegis128l_armcrypto.c
index 825de8a..a01f60c 100644
--- a/src/libsodium/crypto_aead/aegis128l/aegis128l_armcrypto.c
+++ b/src/libsodium/crypto_aead/aegis128l/aegis128l_armcrypto.c
@@ -17,12 +17,6 @@
#include "aegis128l_armcrypto.h"
-#ifdef __clang__
-#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function)
-#elif defined(__GNUC__)
-#pragma GCC target("+simd+crypto")
-#endif
-
#ifndef __ARM_FEATURE_CRYPTO
#define __ARM_FEATURE_CRYPTO 1
#endif
@@ -32,6 +26,12 @@
#include <arm_neon.h>
+#ifdef __clang__
+#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function)
+#elif defined(__GNUC__)
+#pragma GCC target("+simd+crypto")
+#endif
+
#define AES_BLOCK_LENGTH 16
typedef uint8x16_t aes_block_t;
diff --git a/src/libsodium/crypto_aead/aegis256/aegis256_armcrypto.c b/src/libsodium/crypto_aead/aegis256/aegis256_armcrypto.c
index e1ebd57..058e207 100644
--- a/src/libsodium/crypto_aead/aegis256/aegis256_armcrypto.c
+++ b/src/libsodium/crypto_aead/aegis256/aegis256_armcrypto.c
@@ -17,12 +17,6 @@
#include "aegis256_armcrypto.h"
-#ifdef __clang__
-#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function)
-#elif defined(__GNUC__)
-#pragma GCC target("+simd+crypto")
-#endif
-
#ifndef __ARM_FEATURE_CRYPTO
#define __ARM_FEATURE_CRYPTO 1
#endif
@@ -32,6 +26,12 @@
#include <arm_neon.h>
+#ifdef __clang__
+#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function)
+#elif defined(__GNUC__)
+#pragma GCC target("+simd+crypto")
+#endif
+
#define AES_BLOCK_LENGTH 16
typedef uint8x16_t aes_block_t;
diff --git a/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c b/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c
index 0a5a128..aa76f5c 100644
--- a/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c
+++ b/src/libsodium/crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c
@@ -19,12 +19,6 @@
#define __vectorcall
#endif
-#ifdef __clang__
-#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function)
-#elif defined(__GNUC__)
-#pragma GCC target("+simd+crypto")
-#endif
-
#ifndef __ARM_FEATURE_CRYPTO
#define __ARM_FEATURE_CRYPTO 1
#endif
@@ -34,6 +28,12 @@
#include <arm_neon.h>
+#ifdef __clang__
+#pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), apply_to = function)
+#elif defined(__GNUC__)
+#pragma GCC target("+simd+crypto")
+#endif
+
#define ABYTES crypto_aead_aes256gcm_ABYTES
#define NPUBBYTES crypto_aead_aes256gcm_NPUBBYTES
#define KEYBYTES crypto_aead_aes256gcm_KEYBYTES

View File

@ -4,6 +4,8 @@ vcpkg_from_github(
REF ${VERSION}
SHA512 6094d7bf191ea3be85f2ddab76b71f1b9c69c786493db5b84d3c5d5a0237003377ddf6a8687a962ea651fe4a9369cf5ee1676ba0bae82690f5f7ef31a698efa9
HEAD_REF master
PATCHES
arm-neon.diff # https://github.com/jedisct1/libsodium/commit/8f453f41f8834e0fe47610f2a3e03e696ddb3450 with fuzz 2
)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)

View File

@ -1,7 +1,7 @@
{
"name": "libsodium",
"version": "1.0.19",
"port-version": 1,
"port-version": 2,
"description": "A modern and easy-to-use crypto library",
"homepage": "https://libsodium.org/",
"license": "ISC",

View File

@ -4938,7 +4938,7 @@
},
"libsodium": {
"baseline": "1.0.19",
"port-version": 1
"port-version": 2
},
"libsonic": {
"baseline": "0.2.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "24563a7817fe403090f82593e4be4c3bc8219510",
"version": "1.0.19",
"port-version": 2
},
{
"git-tree": "38de4073e90ae48d9d7bc68db71b850b5645f5ab",
"version": "1.0.19",