Make c_check robust against old or incomplete perl installations
by catching and working around failures to load modules, and avoiding object-oriented syntax in tempfile creation. Fixes #1989
This commit is contained in:
parent
42df9efa0c
commit
d70ae3ab43
33
c_check
33
c_check
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
use File::Basename;
|
#use File::Basename;
|
||||||
use File::Temp qw(tempfile);
|
# use File::Temp qw(tempfile);
|
||||||
|
|
||||||
# Checking cross compile
|
# Checking cross compile
|
||||||
$hostos = `uname -s | sed -e s/\-.*//`; chop($hostos);
|
$hostos = `uname -s | sed -e s/\-.*//`; chop($hostos);
|
||||||
|
@ -12,7 +12,7 @@ $hostarch = "arm64" if ($hostarch eq "aarch64");
|
||||||
$hostarch = "power" if ($hostarch =~ /^(powerpc|ppc).*/);
|
$hostarch = "power" if ($hostarch =~ /^(powerpc|ppc).*/);
|
||||||
$hostarch = "zarch" if ($hostarch eq "s390x");
|
$hostarch = "zarch" if ($hostarch eq "s390x");
|
||||||
|
|
||||||
$tmpf = new File::Temp( UNLINK => 1 );
|
#$tmpf = new File::Temp( UNLINK => 1 );
|
||||||
$binary = $ENV{"BINARY"};
|
$binary = $ENV{"BINARY"};
|
||||||
|
|
||||||
$makefile = shift(@ARGV);
|
$makefile = shift(@ARGV);
|
||||||
|
@ -31,6 +31,18 @@ if ($?) {
|
||||||
|
|
||||||
$cross_suffix = "";
|
$cross_suffix = "";
|
||||||
|
|
||||||
|
eval "use File::Basename";
|
||||||
|
if ($@){
|
||||||
|
warn "could not load PERL module File::Basename, emulating its functionality";
|
||||||
|
my $dirnam = substr($compiler_name, 0, rindex($compiler_name, "/")-1 );
|
||||||
|
if ($dirnam ne ".") {
|
||||||
|
$cross_suffix .= $dirnam . "/";
|
||||||
|
}
|
||||||
|
my $basnam = substr($compiler_name, rindex($compiler_name,"/")+1, length($compiler_name)-rindex($compiler_name,"/")-1);
|
||||||
|
if ($basnam =~ /([^\s]*-)(.*)/) {
|
||||||
|
$cross_suffix .= $1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (dirname($compiler_name) ne ".") {
|
if (dirname($compiler_name) ne ".") {
|
||||||
$cross_suffix .= dirname($compiler_name) . "/";
|
$cross_suffix .= dirname($compiler_name) . "/";
|
||||||
}
|
}
|
||||||
|
@ -38,6 +50,7 @@ if (dirname($compiler_name) ne ".") {
|
||||||
if (basename($compiler_name) =~ /([^\s]*-)(.*)/) {
|
if (basename($compiler_name) =~ /([^\s]*-)(.*)/) {
|
||||||
$cross_suffix .= $1;
|
$cross_suffix .= $1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$compiler = "";
|
$compiler = "";
|
||||||
$compiler = LSB if ($data =~ /COMPILER_LSB/);
|
$compiler = LSB if ($data =~ /COMPILER_LSB/);
|
||||||
|
@ -171,6 +184,11 @@ if ($?) {
|
||||||
|
|
||||||
$have_msa = 0;
|
$have_msa = 0;
|
||||||
if (($architecture eq "mips") || ($architecture eq "mips64")) {
|
if (($architecture eq "mips") || ($architecture eq "mips64")) {
|
||||||
|
eval "use File::Temp qw(tempfile)";
|
||||||
|
if ($@){
|
||||||
|
warn "could not load PERL module File::Temp, so could not check MSA capatibility";
|
||||||
|
} else {
|
||||||
|
$tmpf = new File::Temp( UNLINK => 1 );
|
||||||
$code = '"addvi.b $w0, $w1, 1"';
|
$code = '"addvi.b $w0, $w1, 1"';
|
||||||
$msa_flags = "-mmsa -mfp64 -msched-weight -mload-store-pairs";
|
$msa_flags = "-mmsa -mfp64 -msched-weight -mload-store-pairs";
|
||||||
print $tmpf "#include <msa.h>\n\n";
|
print $tmpf "#include <msa.h>\n\n";
|
||||||
|
@ -186,6 +204,7 @@ if (($architecture eq "mips") || ($architecture eq "mips64")) {
|
||||||
}
|
}
|
||||||
unlink("$tmpf.o");
|
unlink("$tmpf.o");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$architecture = x86 if ($data =~ /ARCH_X86/);
|
$architecture = x86 if ($data =~ /ARCH_X86/);
|
||||||
$architecture = x86_64 if ($data =~ /ARCH_X86_64/);
|
$architecture = x86_64 if ($data =~ /ARCH_X86_64/);
|
||||||
|
@ -204,6 +223,13 @@ $binformat = bin64 if ($data =~ /BINARY_64/);
|
||||||
|
|
||||||
$no_avx512= 0;
|
$no_avx512= 0;
|
||||||
if (($architecture eq "x86") || ($architecture eq "x86_64")) {
|
if (($architecture eq "x86") || ($architecture eq "x86_64")) {
|
||||||
|
eval "use File::Temp qw(tempfile)";
|
||||||
|
if ($@){
|
||||||
|
warn "could not load PERL module File::Temp, so could not check compiler compatibility with AVX512";
|
||||||
|
$no_avx512 = 0;
|
||||||
|
} else {
|
||||||
|
# $tmpf = new File::Temp( UNLINK => 1 );
|
||||||
|
($fh,$tmpf) = tempfile( UNLINK => 1 );
|
||||||
$code = '"vbroadcastss -4 * 4(%rsi), %zmm2"';
|
$code = '"vbroadcastss -4 * 4(%rsi), %zmm2"';
|
||||||
print $tmpf "#include <immintrin.h>\n\nint main(void){ __asm__ volatile($code); }\n";
|
print $tmpf "#include <immintrin.h>\n\nint main(void){ __asm__ volatile($code); }\n";
|
||||||
$args = " -march=skylake-avx512 -o $tmpf.o -x c $tmpf";
|
$args = " -march=skylake-avx512 -o $tmpf.o -x c $tmpf";
|
||||||
|
@ -216,6 +242,7 @@ if (($architecture eq "x86") || ($architecture eq "x86_64")) {
|
||||||
}
|
}
|
||||||
unlink("tmpf.o");
|
unlink("tmpf.o");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = `$compiler_name -S ctest1.c && grep globl ctest1.s | head -n 1 && rm -f ctest1.s`;
|
$data = `$compiler_name -S ctest1.c && grep globl ctest1.s | head -n 1 && rm -f ctest1.s`;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue