Skip to content

Commit d328636

Browse files
authored
Add compiler check for RISCV vector support
1 parent 06d1dd6 commit d328636

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

c_check

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,29 @@ if (($architecture eq "x86") || ($architecture eq "x86_64")) {
270270
}
271271
}
272272

273+
$no_rv64gv= 0;
274+
if (($architecture eq "riscv64")) {
275+
eval "use File::Temp qw(tempfile)";
276+
if ($@){
277+
warn "could not load PERL module File::Temp, so could not check compiler compatibility with the RISCV vector extension";
278+
$no_rv64gv = 0;
279+
} else {
280+
# $tmpf = new File::Temp( UNLINK => 1 );
281+
($fh,$tmpf) = tempfile( SUFFIX => '.c' , UNLINK => 1 );
282+
$code = '"vsetvli zero, zero, e8, m1\n"';
283+
print $fh "int main(void){ __asm__ volatile($code); }\n";
284+
$args = " -march=rv64gv -c -o $tmpf.o $tmpf";
285+
my @cmd = ("$compiler_name $flags $args >/dev/null 2>/dev/null");
286+
system(@cmd) == 0;
287+
if ($? != 0) {
288+
$no_rv64gv = 1;
289+
} else {
290+
$no_rv64gv = 0;
291+
}
292+
unlink("$tmpf.o");
293+
}
294+
}
295+
273296
$c11_atomics = 0;
274297
if ($data =~ /HAVE_C11/) {
275298
eval "use File::Temp qw(tempfile)";
@@ -392,6 +415,7 @@ print MAKEFILE "CROSS=1\n" if $cross != 0;
392415
print MAKEFILE "CEXTRALIB=$linker_L $linker_l $linker_a\n";
393416
print MAKEFILE "HAVE_MSA=1\n" if $have_msa eq 1;
394417
print MAKEFILE "MSA_FLAGS=$msa_flags\n" if $have_msa eq 1;
418+
print MAKEFILE "NO_RV64GV=1\n" if $no_rv64gv eq 1;
395419
print MAKEFILE "NO_AVX512=1\n" if $no_avx512 eq 1;
396420
print MAKEFILE "NO_AVX2=1\n" if $no_avx2 eq 1;
397421
print MAKEFILE "OLDGCC=1\n" if $oldgcc eq 1;

0 commit comments

Comments
 (0)