From 6ecd5f75650bc86e3b1ccbdf2999ec31c43f551b Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 30 Jul 2026 07:35:08 -0600 Subject: sha: restrict the x86 bswap asm to x86 (#41) ByteReverse(word32) in src/sha.h uses the x86 `bswap` instruction via inline asm, guarded only by `#if defined(__GNUC__)`. GCC and Clang define __GNUC__ on every architecture they target, so on aarch64 the guard passes and the assembler then rejects the instruction: Error: unknown mnemonic `bswap' -- `bswap %eax' This makes the tree fail to build on any ARM64 host -- Apple Silicon, ARM servers, a Raspberry Pi -- at a point far from anything the user did. Narrow the guard to the architectures where the instruction exists. The portable C fallback directly below is then used everywhere else; it was already there and already correct. Co-authored-by: Claude Opus 5 --- src/sha.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sha.h') diff --git a/src/sha.h b/src/sha.h index e3af7b4..ddf5cf1 100644 --- a/src/sha.h +++ b/src/sha.h @@ -72,7 +72,7 @@ inline word16 ByteReverse(word16 value) inline word32 ByteReverse(word32 value) { -#if defined(__GNUC__) +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) __asm__ ("bswap %0" : "=r" (value) : "0" (value)); return value; #elif defined(CRYPTOPP_BYTESWAP_AVAILABLE) -- cgit v1.2.3