2021-02-22 23:30:21

by dm9pZCAq

[permalink] [raw]
Subject: [PATCH] crypto: jitterentropy: Add automatically deoptimization.

This is needed to compile with `CFLAGS_KERNEL=-O2`.

Due to `CFLAGS_jitterentropy.o = -O0` comes after `CFLAGS_KERNEL`
the code is still optimized and gives an error.
This patch deoptimizes the code despite any `CFLAGS`.

Signed-off-by: dm9pZCAq <[email protected]>
---
crypto/jitterentropy.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c
index 6e147c43fc18..7d84bc10626f 100644
--- a/crypto/jitterentropy.c
+++ b/crypto/jitterentropy.c
@@ -50,7 +50,14 @@
* version 2.2.0 provided at https://www.chronox.de/jent.html
*/

-#ifdef __OPTIMIZE__
+
+#ifdef __clang__
+ #pragma clang optimize off
+#else
+ #pragma GCC optimize ("O0")
+#endif
+
+#if !defined(__clang__) && defined(__OPTIMIZE__)
#error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy.c."
#endif

--
2.30.1