Fix version detection on Apple clang
authorTomas Mraz <tomas@openssl.org>
Wed, 15 Mar 2023 15:14:19 +0000 (16:14 +0100)
committerTomas Mraz <tomas@openssl.org>
Fri, 17 Mar 2023 10:22:57 +0000 (11:22 +0100)
Added missing fix from the master branch.

Fixes #20518

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20519)

crypto/bn/asm/rsaz-3k-avx512.pl
crypto/bn/asm/rsaz-4k-avx512.pl

index ef82beef0b18ac86724337d5d6fe720a5893636d..df025a87f09add868d7b93b65554bb6c9591151c 100644 (file)
@@ -48,8 +48,17 @@ if (!$avx512 && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) &&
     $avx512ifma = ($1==2.11 && $2>=8) + ($1>=2.12);
 }
 
-if (!$avx512 && `$ENV{CC} -v 2>&1` =~ /((?:clang|LLVM) version|.*based on LLVM) ([0-9]+\.[0-9]+)/) {
-    $avx512ifma = ($2>=7.0);
+if (!$avx512 && `$ENV{CC} -v 2>&1`
+    =~ /(Apple)?\s*((?:clang|LLVM) version|.*based on LLVM) ([0-9]+)\.([0-9]+)\.([0-9]+)?/) {
+    my $ver = $3 + $4/100.0 + $5/10000.0; # 3.1.0->3.01, 3.10.1->3.1001
+    if ($1) {
+        # Apple conditions, they use a different version series, see
+        # https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-_10.x_(since_Free_On-Device_Development)_2
+        # clang 7.0.0 is Apple clang 10.0.1
+        $avx512ifma = ($ver>=10.0001)
+    } else {
+        $avx512ifma = ($ver>=7.0);
+    }
 }
 
 open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
index 5593165906ef7108c5a66c5f5f532d0b97f265d2..53d327e765c35919278fd3f874110f9f2e73342f 100644 (file)
@@ -48,8 +48,17 @@ if (!$avx512 && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) &&
     $avx512ifma = ($1==2.11 && $2>=8) + ($1>=2.12);
 }
 
-if (!$avx512 && `$ENV{CC} -v 2>&1` =~ /((?:clang|LLVM) version|.*based on LLVM) ([0-9]+\.[0-9]+)/) {
-    $avx512ifma = ($2>=7.0);
+if (!$avx512 && `$ENV{CC} -v 2>&1`
+    =~ /(Apple)?\s*((?:clang|LLVM) version|.*based on LLVM) ([0-9]+)\.([0-9]+)\.([0-9]+)?/) {
+    my $ver = $3 + $4/100.0 + $5/10000.0; # 3.1.0->3.01, 3.10.1->3.1001
+    if ($1) {
+        # Apple conditions, they use a different version series, see
+        # https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-_10.x_(since_Free_On-Device_Development)_2
+        # clang 7.0.0 is Apple clang 10.0.1
+        $avx512ifma = ($ver>=10.0001)
+    } else {
+        $avx512ifma = ($ver>=7.0);
+    }
 }
 
 open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""