Don't try to setup CPUID if NO_ASM.
Change-Id: Idec1cda87b0a58e9350d0e10c3251a2c47ac1929
Reviewed-on: https://boringssl-review.googlesource.com/1790
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/crypto.c b/crypto/crypto.c
index 78241da..ee7c405 100644
--- a/crypto/crypto.c
+++ b/crypto/crypto.c
@@ -16,14 +16,22 @@
#include "internal.h"
+#if !defined(OPENSSL_NO_ASM) && \
+ (defined(OPENSSL_X86) || defined(OPENSSL_X86_64))
+/* x86 and x86_64 need to record the result of a cpuid call for the asm to work
+ * correctly, unless compiled without asm code. */
+#define NEED_CPUID
-/* Currently, the only configurations which require a static initializer are x86
- * and x86_64. Don't bother emitting one in other cases. */
-#if !defined(OPENSSL_X86) && !defined(OPENSSL_X86_64) && \
- !defined(BORINGSSL_NO_STATIC_INITIALIZER)
+#else
+
+/* Otherwise, don't emit a static initialiser. */
+
+#if !defined(BORINGSSL_NO_STATIC_INITIALIZER)
#define BORINGSSL_NO_STATIC_INITIALIZER
#endif
+#endif /* !OPENSSL_NO_ASM && (OPENSSL_X86 || OPENSSL_X86_64) */
+
#if defined(OPENSSL_WINDOWS)
#define OPENSSL_CDECL __cdecl
#else
@@ -45,7 +53,7 @@
* BORINGSSL_NO_STATIC_INITIALIZER isn't defined, this is set as a static
* initializer. Otherwise, it is called by CRYPTO_library_init. */
static void OPENSSL_CDECL do_library_init(void) {
-#if defined(OPENSSL_X86) || defined(OPENSSL_X86_64)
+#if defined(NEED_CPUID)
OPENSSL_cpuid_setup();
#endif
}