Replies: 9 comments
-
The Clang-specific |
Beta Was this translation helpful? Give feedback.
-
Oh no. I have no idea how to fix this. As a quick workaround I'd recommend using Zig rather than the old build system: zig build -Doptimize=ReleaseFast -Dtarget=x86_64-windows Which seems to work well even with clang 19. |
Beta Was this translation helpful? Give feedback.
-
Does something like this help? diff --git a/src/libsodium/randombytes/internal/randombytes_internal_random.c b/src/libsodium/randombytes/internal/randombytes_internal_random.c
index d39063c5..f4752759 100644
--- a/src/libsodium/randombytes/internal/randombytes_internal_random.c
+++ b/src/libsodium/randombytes/internal/randombytes_internal_random.c
@@ -45,12 +45,12 @@
# include <poll.h>
#endif
#ifdef HAVE_RDRAND
+# include <immintrin.h>
# 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" |
Beta Was this translation helpful? Give feedback.
-
Unfortunately not a quick workaround here, as it would require bringing Zig as a new dependency into the vendored build system (alongside Clang and Rust) that is used for reproducible builds. If I find time I might try this, although then we also need to deal with any incompatibilities between the Clang MinGW32 toolchain and whatever Zig is doing for Clang 19 is also not viable as there is no stable Rust build using LLVM 18 yet, so if this is a Clang 18-specific bug then we'd just wait for that.
Looks like no. Build output with that patch for 1.0.20 (the line numbers are different reflecting the reorder, but otherwise the same):
|
Beta Was this translation helpful? Give feedback.
-
It's a bit surprising that it only happens in that file. Can you try to |
Beta Was this translation helpful? Give feedback.
-
An |
Beta Was this translation helpful? Give feedback.
-
What if you move that block a little bit down, such as right before |
Beta Was this translation helpful? Give feedback.
-
That also appears to work! Specifically this patch: 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;
|
Beta Was this translation helpful? Give feedback.
-
This has been applied to |
Beta Was this translation helpful? Give feedback.
-
Originally discovered with the 1.0.20 release in a downstream build system.
I reproduced the build failure with current
master
(babb0dd); logs below. I believe this to be the relevant error from within them:stdout output
stderr output
Beta Was this translation helpful? Give feedback.
All reactions