From eb8fc7771dabde938c8e96e797ff67ac9358411c Mon Sep 17 00:00:00 2001 From: Jukka Raimovaara Date: Sat, 29 Apr 2017 21:47:20 +0300 Subject: [PATCH] bugfix: the feature test for SSE 4.2 support did not really check if the local CPU indeed has it. Signed-off-by: Yichun Zhang (agentzh) --- util/configure | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/util/configure b/util/configure index 941fde4..e78fc74 100755 --- a/util/configure +++ b/util/configure @@ -632,18 +632,35 @@ _END_ SUFFIX => '.c', TMPDIR => 1, UNLINK => 1); - print $out "int main(void) { return 0; }"; + print $out " +int main(void) { +#ifndef __SSE4_2__ +# error SSE 4.2 not found +#endif + return 0; +} +"; close $out; my $ofile = tmpnam(); my $comp = ($cc || 'cc'); + my $found; if (system("$comp -o $ofile -msse4.2 -c $cfile") == 0 && -s $ofile) { - print "INFO: found -msse4.2 in $comp.\n"; - $luajit_xcflags .= " -msse4.2"; unlink $ofile; - } else { + if (system("$comp -o $ofile -march=native -c $cfile") == 0 && -s $ofile) { + print "INFO: found -msse4.2 in $comp.\n"; + $found = 1; + $luajit_xcflags .= " -msse4.2"; + } + } + + if (-f $ofile) { + unlink $ofile; + } + + if (!$found) { print "WARNING: -msse4.2 not supported in $comp.\n"; } }