Crypto: fix NOASM link failures on x86 (#1896)

With NOASM=1 on x86/x64 the assembler module Aes_hw_cpu is not built,
but cpu.h still defines TC_AES_HW_CPU, so Cipher.cpp references
aes_hw_cpu_encrypt/decrypt. cpu.c also still declares and calls
TrySHA256, which Sha2Intel.c omits when CRYPTOPP_DISABLE_ASM is set
(NOASM passes CRYPTOPP_DISABLE_X86ASM, which implies it), and this
happens whenever __SHA__ is defined (-msha, -march=native) or
CRYPTOPP_SHANI_AVAILABLE is set.

- cpu.h: define TC_AES_HW_CPU on x86 only without CRYPTOPP_DISABLE_ASM
- cpu.c: declare and call TrySHA256 only under the same condition
  Sha2Intel.c uses to build it (not _UEFI, not CRYPTOPP_DISABLE_ASM)

Both follow the compiler target, so cross builds need no ARCH override.

Signed-off-by: Ville Takio <ville+git@takio.fi>
This commit is contained in:
Ville Takio authored and GitHub committed 2026-09-30 15:49:18 +09:00
1 parent 81cd94f18f
commit a15c996f4f
2 files changed
+7 -3

No files matched your search

+5 -2
View File
@@ -290,7 +290,10 @@ static int Detect_MS_HyperV_AES ()
#endif #endif
#if defined(__SHA__) || defined(__INTEL_COMPILER) || CRYPTOPP_SHANI_AVAILABLE /* TrySHA256 lives in Sha2Intel.c, which omits it for _UEFI and CRYPTOPP_DISABLE_ASM */
#if !defined(_UEFI) && !defined(CRYPTOPP_DISABLE_ASM) && \
(defined(__SHA__) || defined(__INTEL_COMPILER) || CRYPTOPP_SHANI_AVAILABLE)
#define TC_SHA256_PROBE_AVAILABLE
extern int TrySHA256(); extern int TrySHA256();
#endif #endif
@@ -366,7 +369,7 @@ void DetectX86Features()
} }
#endif #endif
#if defined(__SHA__) || defined(__INTEL_COMPILER) || CRYPTOPP_SHANI_AVAILABLE #ifdef TC_SHA256_PROBE_AVAILABLE
if (!g_hasSHA256) if (!g_hasSHA256)
{ {
g_hasSHA256 = TrySHA256(); g_hasSHA256 = TrySHA256();
+2 -1
View File
@@ -236,7 +236,8 @@ extern "C" {
#endif #endif
#define CRYPTOPP_CPUID_AVAILABLE #define CRYPTOPP_CPUID_AVAILABLE
#if !defined(CRYPTOPP_DISABLE_AESNI) && !defined(WOLFCRYPT_BACKEND) /* aes_hw_cpu_* come from the assembler module, which NOASM builds leave out */
#if !defined(CRYPTOPP_DISABLE_AESNI) && !defined(WOLFCRYPT_BACKEND) && !defined(CRYPTOPP_DISABLE_ASM)
#define TC_AES_HW_CPU #define TC_AES_HW_CPU
#endif #endif