[libsodium] Fix build for emscripten and mingw-x86 (#39301)

Fixes issues compiling libsodium port for Emscripten and llvm-mingw x86.
This commit is contained in:
pastdue 2024-06-17 14:44:30 -04:00 committed by GitHub
parent f4aa70af40
commit d36776f8e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1,21 @@
diff --git a/src/libsodium/randombytes/internal/randombytes_internal_random.c b/src/libsodium/randombytes/internal/randombytes_internal_random.c
--- a/src/libsodium/randombytes/internal/randombytes_internal_random.c
+++ b/src/libsodium/randombytes/internal/randombytes_internal_random.c
@@ -45,7 +45,7 @@
# include <poll.h>
#endif
#ifdef HAVE_RDRAND
-# ifdef __clang__
+# if defined (__clang__) && (!defined(__MINGW32__) || !defined(__i386__))
# pragma clang attribute push(__attribute__((target("rdrnd"))), apply_to = function)
# elif defined(__GNUC__)
# pragma GCC target("rdrnd")
@@ -639,7 +639,7 @@ struct randombytes_implementation randombytes_internal_implementation = {
};
#ifdef HAVE_RDRAND
-# ifdef __clang__
+# if defined (__clang__) && (!defined(__MINGW32__) || !defined(__i386__))
# pragma clang attribute pop
# endif
#endif

View File

@ -4,6 +4,8 @@ vcpkg_from_github(
REF "${VERSION}-RELEASE"
SHA512 477b9dc10d87ae3c83db3fc207b50b9fe39593684a59f164986cce32bdaba95db0df7dee32149bf9a23c5794354fce8241d88a9a4bd4bbf2630483cbbc378c2f
HEAD_REF master
PATCHES
001-mingw-i386.patch
)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
@ -42,6 +44,9 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
endif()
endblock()
else()
if(VCPKG_TARGET_IS_EMSCRIPTEN)
list(APPEND OPTIONS "--disable-ssp" "--disable-asm")
endif()
if(NOT VCPKG_TARGET_IS_MINGW)
list(APPEND OPTIONS --disable-pie)
endif()

View File

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

View File

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

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "1b7b00b7cccd397e07fa2b1b3ce3725d3ebead29",
"version": "1.0.20",
"port-version": 2
},
{
"git-tree": "ab6a37dc1d297573d444a9ac29e2cbd496ff51c0",
"version": "1.0.20",