From: knut st. osmundsen Date: Tue, 9 Jun 2026 06:49:39 +0000 (+0200) Subject: Fix nasm version check for sm3 & sm4 perlasm files X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=6736bd2cb606aeaf8f0960816152cb27fa710258;p=thirdparty%2Fopenssl.git Fix nasm version check for sm3 & sm4 perlasm files Make the check correctly handle versions such as '3.00rc8'. It was incorrectly expecting major.minor.patch. Reviewed-by: Norbert Pocs Reviewed-by: Tom Cosgrove MergeDate: Mon Jul 13 15:48:03 2026 (Merged from https://github.com/openssl/openssl/pull/31420) --- diff --git a/crypto/sm3/asm/sm3-x86_64.pl b/crypto/sm3/asm/sm3-x86_64.pl index d3c9d0541a9..2f6ddf56168 100755 --- a/crypto/sm3/asm/sm3-x86_64.pl +++ b/crypto/sm3/asm/sm3-x86_64.pl @@ -35,8 +35,8 @@ if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1` } if (!$avx2_sm3_ni && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) && - `nasm -v 2>&1` =~ /NASM version ([2-9])\.([0-9]+)\.([0-9]+)/) { - my ($major, $minor, $patch) = ($1, $2, $3); + `nasm -v 2>&1` =~ /NASM version ([2-9])\.([0-9]+)(?:\.([0-9]+))?/) { + my ($major, $minor, $patch) = ($1, $2, defined($3) ? $3 : 0); $avx2_sm3_ni = ($major > 2) || ($major == 2 && $minor > 10); # minimal avx2 supported version, binary translation for SM3 instructions (sub sm3op) is used $avx2_sm3_ni_native = ($major > 2) || ($major == 2 && $minor > 16) || ($major == 2 && $minor == 16 && $patch >= 2); # support added at NASM 2.16.02 } diff --git a/crypto/sm4/asm/sm4-x86_64.pl b/crypto/sm4/asm/sm4-x86_64.pl index 9fc40fb96a4..f5b485968ef 100644 --- a/crypto/sm4/asm/sm4-x86_64.pl +++ b/crypto/sm4/asm/sm4-x86_64.pl @@ -35,8 +35,8 @@ if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1` } if (!$avx2_sm4_ni && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) && - `nasm -v 2>&1` =~ /NASM version ([2-9])\.([0-9]+)\.([0-9]+)/) { - my ($major, $minor, $patch) = ($1, $2, $3); + `nasm -v 2>&1` =~ /NASM version ([2-9])\.([0-9]+)(?:\.([0-9]+))?/) { + my ($major, $minor, $patch) = ($1, $2, defined($3) ? $3 : 0); $avx2_sm4_ni = ($major > 2) || ($major == 2 && $minor > 10); # minimal avx2 supported version, binary translation for SM4 instructions (sub sm4op) is used $avx2_sm4_ni_native = ($major > 2) || ($major == 2 && $minor > 16) || ($major == 2 && $minor == 16 && $patch >= 2); # support added at NASM 2.16.02 }