sha512-x86_64.pl: fix linking problem under Windows.
[openssl.git] / crypto / sha / asm / sha512-x86_64.pl
index 01698c40cfaa682edaef3b0a02eee1be5cd4d223..9941da93e2e33b5f348155907d1f5c08ccee54fd 100755 (executable)
@@ -123,6 +123,13 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
        $avx = ($1>=10) + ($1>=11);
 }
 
+if (!$avx && `$ENV{CC} -v 2>&1` =~ /(^clang version|based on LLVM) ([3-9]\.[0-9]+)/) {
+       $avx = ($2>=3.0) + ($2>3.0);
+}
+
+$shaext=1;     ### set to zero if compiling for 1.0.1
+$avx=1         if (!$shaext && $avx);
+
 open OUT,"| \"$^X\" $xlate $flavour $output";
 *STDOUT=*OUT;
 
@@ -259,7 +266,7 @@ $code.=<<___ if ($SZ==4 || $avx);
        mov     4(%r11),%r10d
        mov     8(%r11),%r11d
 ___
-$code.=<<___ if ($SZ==4);
+$code.=<<___ if ($SZ==4 && $shaext);
        test    \$`1<<29`,%r11d         # check for SHA
        jnz     _shaext_shortcut
 ___
@@ -518,7 +525,7 @@ ___
 ######################################################################
 # SIMD code paths
 #
-if ($SZ==4) {{{
+if ($SZ==4 && $shaext) {{{
 ######################################################################
 # Intel SHA Extensions implementation of SHA256 update function.
 #
@@ -2255,7 +2262,9 @@ $code.=<<___;
        pop     %rsi
        ret
 .size  se_handler,.-se_handler
+___
 
+$code.=<<___ if ($SZ==4 && $shaext);
 .type  shaext_handler,\@abi-omnipotent
 .align 16
 shaext_handler:
@@ -2288,17 +2297,21 @@ shaext_handler:
 
        jmp     .Lin_prologue
 .size  shaext_handler,.-shaext_handler
+___
 
+$code.=<<___;
 .section       .pdata
 .align 4
        .rva    .LSEH_begin_$func
        .rva    .LSEH_end_$func
        .rva    .LSEH_info_$func
 ___
-$code.=<<___ if ($SZ==4);
+$code.=<<___ if ($SZ==4 && $shext);
        .rva    .LSEH_begin_${func}_shaext
        .rva    .LSEH_end_${func}_shaext
        .rva    .LSEH_info_${func}_shaext
+___
+$code.=<<___ if ($SZ==4);
        .rva    .LSEH_begin_${func}_ssse3
        .rva    .LSEH_end_${func}_ssse3
        .rva    .LSEH_info_${func}_ssse3