Skip to content

Commit

Permalink
depends: Fix incompatibility between libsodium 1.0.20 and Clang 18
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Sep 26, 2024
1 parent 7a93b4f commit 7535f51
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion depends/packages/libsodium.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ $(package)_download_path=https://download.libsodium.org/libsodium/releases/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=ebb65ef6ca439333c2bb41a0c1990587288da07f6c7fd07cb3a18cc18d30ce19
$(package)_dependencies=
$(package)_patches=1.0.15-pubkey-validation.diff 1.0.15-signature-validation.diff
$(package)_patches=1.0.15-pubkey-validation.diff 1.0.15-signature-validation.diff 1.0.20-immintrin-conflict.diff
$(package)_config_opts=

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/1.0.15-pubkey-validation.diff && \
patch -p1 < $($(package)_patch_dir)/1.0.15-signature-validation.diff && \
patch -p1 < $($(package)_patch_dir)/1.0.20-immintrin-conflict.diff && \
cd $($(package)_build_subdir); DO_NOT_UPDATE_CONFIG_SCRIPTS=1 ./autogen.sh
endef

Expand Down
34 changes: 34 additions & 0 deletions depends/patches/libsodium/1.0.20-immintrin-conflict.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff -ur libsodium-1.0.20-orig/src/libsodium/randombytes/internal/randombytes_internal_random.c libsodium-1.0.20/src/libsodium/randombytes/internal/randombytes_internal_random.c
--- libsodium-1.0.20-orig/src/libsodium/randombytes/internal/randombytes_internal_random.c 2024-05-25 12:15:18.000000000 +0000
+++ libsodium-1.0.20/src/libsodium/randombytes/internal/randombytes_internal_random.c 2024-09-26 18:11:50.173273070 +0000
@@ -44,14 +44,6 @@
#ifdef BLOCK_ON_DEV_RANDOM
# include <poll.h>
#endif
-#ifdef HAVE_RDRAND
-# ifdef __clang__
-# pragma clang attribute push(__attribute__((target("rdrnd"))), apply_to = function)
-# elif defined(__GNUC__)
-# pragma GCC target("rdrnd")
-# endif
-# include <immintrin.h>
-#endif

#include "core.h"
#include "crypto_core_hchacha20.h"
@@ -109,6 +101,15 @@
# endif
#endif

+#ifdef HAVE_RDRAND
+# ifdef __clang__
+# pragma clang attribute push(__attribute__((target("rdrnd"))), apply_to = function)
+# elif defined(__GNUC__)
+# pragma GCC target("rdrnd")
+# endif
+# include <immintrin.h>
+#endif
+
typedef struct InternalRandomGlobal_ {
int initialized;
int random_data_source_fd;

0 comments on commit 7535f51

Please sign in to comment.