Skip to content

Commit fc66a0e

Browse files
authored
Merge pull request #1590 from martin-frbg/avx512_check
Disable AVX512 (Skylake X) support if the build system is too old
2 parents 36c4523 + 83fec56 commit fc66a0e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

c_check

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ $architecture = zarch if ($data =~ /ARCH_ZARCH/);
201201
$binformat = bin32;
202202
$binformat = bin64 if ($data =~ /BINARY_64/);
203203

204+
$no_avx512= 0;
205+
if (($architecture eq "x86") || ($architecture eq "x86_64")) {
206+
$code = '"vaddps %zmm1, %zmm0, %zmm0"';
207+
print $tmpf "void main(void){ __asm__ volatile($code); }\n";
208+
$args = " -o $tmpf.o -x c $tmpf";
209+
my @cmd = ("$compiler_name $args");
210+
system(@cmd) == 0;
211+
if ($? != 0) {
212+
$no_avx512 = 1;
213+
} else {
214+
$no_avx512 = 0;
215+
}
216+
unlink("tmpf.o");
217+
}
218+
204219
$data = `$compiler_name -S ctest1.c && grep globl ctest1.s | head -n 1 && rm -f ctest1.s`;
205220

206221
$data =~ /globl\s([_\.]*)(.*)/;
@@ -288,6 +303,7 @@ print MAKEFILE "CROSS=1\n" if $cross != 0;
288303
print MAKEFILE "CEXTRALIB=$linker_L $linker_l $linker_a\n";
289304
print MAKEFILE "HAVE_MSA=1\n" if $have_msa eq 1;
290305
print MAKEFILE "MSA_FLAGS=$msa_flags\n" if $have_msa eq 1;
306+
print MAKEFILE "NO_AVX512=1\n" if $no_avx512 eq 1;
291307

292308
$os =~ tr/[a-z]/[A-Z]/;
293309
$architecture =~ tr/[a-z]/[A-Z]/;

0 commit comments

Comments
 (0)