Make the dispatch tests opt-in.
The assembly dispatch tests currently assume NDEBUG is consistently
defined between C/C++ and assembly. While this is usually the case for
UNIX, CMake does not pass NDEBUG to NASM. This is giving gRPC some
difficulties in updating BoringSSL, so switch it to an opt-in
-DBORINGSSL_DISPATCH_TEST flag instead.
Update-Note: If you were copying NDEBUG over to assembly files, that's
no longer required (though it's harmless to leave it in). If you want to
run ImplDispatchTest.*, build both C/C++ and assembly with
-DBORINGSSL_DISPATCH_TEST in your debug builds. (Don't enable it in
release builds. It causes assembly to scribble in some globals.)
Change-Id: I9ab3371dc0f0a40b27b44ef93835e007a6346900
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37764
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/cpu.h b/include/openssl/cpu.h
index eb36a57..ae55967 100644
--- a/include/openssl/cpu.h
+++ b/include/openssl/cpu.h
@@ -190,20 +190,19 @@
#endif // OPENSSL_PPC64LE
-#if !defined(NDEBUG) && !defined(BORINGSSL_FIPS)
+#if defined(BORINGSSL_DISPATCH_TEST)
// Runtime CPU dispatch testing support
// BORINGSSL_function_hit is an array of flags. The following functions will
-// set these flags in non-FIPS builds if NDEBUG is not defined.
+// set these flags if BORINGSSL_DISPATCH_TEST is defined.
// 0: aes_hw_ctr32_encrypt_blocks
// 1: aes_hw_encrypt
// 2: aesni_gcm_encrypt
// 3: aes_hw_set_encrypt_key
// 4: vpaes_encrypt
// 5: vpaes_set_encrypt_key
-// 6: bsaes_ctr32_encrypt_blocks
extern uint8_t BORINGSSL_function_hit[7];
-#endif // !NDEBUG && !FIPS
+#endif // BORINGSSL_DISPATCH_TEST
#if defined(__cplusplus)