1
1
# !/usr/bin/perl
2
2
3
- use File::Basename;
4
- use File::Temp qw( tempfile) ;
3
+ # use File::Basename;
4
+ # use File::Temp qw(tempfile);
5
5
6
6
# Checking cross compile
7
7
$hostos = ` uname -s | sed -e s/\- .*//` ; chop ($hostos );
@@ -12,7 +12,7 @@ $hostarch = "arm64" if ($hostarch eq "aarch64");
12
12
$hostarch = " power" if ($hostarch =~ / ^(powerpc|ppc).*/ );
13
13
$hostarch = " zarch" if ($hostarch eq " s390x" );
14
14
15
- $tmpf = new File::Temp( UNLINK => 1 );
15
+ # $tmpf = new File::Temp( UNLINK => 1 );
16
16
$binary = $ENV {" BINARY" };
17
17
18
18
$makefile = shift (@ARGV );
@@ -31,12 +31,25 @@ if ($?) {
31
31
32
32
$cross_suffix = " " ;
33
33
34
- if (dirname($compiler_name ) ne " ." ) {
35
- $cross_suffix .= dirname($compiler_name ) . " /" ;
36
- }
34
+ eval " use File::Basename" ;
35
+ if ($@ ){
36
+ warn " could not load PERL module File::Basename, emulating its functionality" ;
37
+ my $dirnam = substr ($compiler_name , 0, rindex ($compiler_name , " /" )-1 );
38
+ if ($dirnam ne " ." ) {
39
+ $cross_suffix .= $dirnam . " /" ;
40
+ }
41
+ my $basnam = substr ($compiler_name , rindex ($compiler_name ," /" )+1, length ($compiler_name )-rindex ($compiler_name ," /" )-1);
42
+ if ($basnam =~ / ([^\s ]*-)(.*)/ ) {
43
+ $cross_suffix .= $1 ;
44
+ }
45
+ } else {
46
+ if (dirname($compiler_name ) ne " ." ) {
47
+ $cross_suffix .= dirname($compiler_name ) . " /" ;
48
+ }
37
49
38
- if (basename($compiler_name ) =~ / ([^\s ]*-)(.*)/ ) {
39
- $cross_suffix .= $1 ;
50
+ if (basename($compiler_name ) =~ / ([^\s ]*-)(.*)/ ) {
51
+ $cross_suffix .= $1 ;
52
+ }
40
53
}
41
54
42
55
$compiler = " " ;
@@ -171,20 +184,26 @@ if ($?) {
171
184
172
185
$have_msa = 0;
173
186
if (($architecture eq " mips" ) || ($architecture eq " mips64" )) {
174
- $code = ' "addvi.b $w0, $w1, 1"' ;
175
- $msa_flags = " -mmsa -mfp64 -msched-weight -mload-store-pairs" ;
176
- print $tmpf " #include <msa.h>\n\n " ;
177
- print $tmpf " void main(void){ __asm__ volatile($code ); }\n " ;
178
-
179
- $args = " $msa_flags -o $tmpf .o -x c $tmpf " ;
180
- my @cmd = (" $compiler_name $args " );
181
- system (@cmd ) == 0;
182
- if ($? != 0) {
183
- $have_msa = 0;
187
+ eval " use File::Temp qw(tempfile)" ;
188
+ if ($@ ){
189
+ warn " could not load PERL module File::Temp, so could not check MSA capatibility" ;
184
190
} else {
185
- $have_msa = 1;
191
+ $tmpf = new File::Temp( UNLINK => 1 );
192
+ $code = ' "addvi.b $w0, $w1, 1"' ;
193
+ $msa_flags = " -mmsa -mfp64 -msched-weight -mload-store-pairs" ;
194
+ print $tmpf " #include <msa.h>\n\n " ;
195
+ print $tmpf " void main(void){ __asm__ volatile($code ); }\n " ;
196
+
197
+ $args = " $msa_flags -o $tmpf .o -x c $tmpf " ;
198
+ my @cmd = (" $compiler_name $args " );
199
+ system (@cmd ) == 0;
200
+ if ($? != 0) {
201
+ $have_msa = 0;
202
+ } else {
203
+ $have_msa = 1;
204
+ }
205
+ unlink (" $tmpf .o" );
186
206
}
187
- unlink (" $tmpf .o" );
188
207
}
189
208
190
209
$architecture = x 86 if ($data =~ / ARCH_X86/ );
@@ -204,17 +223,25 @@ $binformat = bin64 if ($data =~ /BINARY_64/);
204
223
205
224
$no_avx512 = 0;
206
225
if (($architecture eq " x86" ) || ($architecture eq " x86_64" )) {
207
- $code = ' "vbroadcastss -4 * 4(%rsi), %zmm2"' ;
208
- print $tmpf " #include <immintrin.h>\n\n int main(void){ __asm__ volatile($code ); }\n " ;
209
- $args = " -march=skylake-avx512 -o $tmpf .o -x c $tmpf " ;
210
- my @cmd = (" $compiler_name $args >/dev/null 2>/dev/null" );
211
- system (@cmd ) == 0;
212
- if ($? != 0) {
213
- $no_avx512 = 1;
214
- } else {
226
+ eval " use File::Temp qw(tempfile)" ;
227
+ if ($@ ){
228
+ warn " could not load PERL module File::Temp, so could not check compiler compatibility with AVX512" ;
215
229
$no_avx512 = 0;
230
+ } else {
231
+ # $tmpf = new File::Temp( UNLINK => 1 );
232
+ ($fh ,$tmpf ) = tempfile( UNLINK => 1 );
233
+ $code = ' "vbroadcastss -4 * 4(%rsi), %zmm2"' ;
234
+ print $tmpf " #include <immintrin.h>\n\n int main(void){ __asm__ volatile($code ); }\n " ;
235
+ $args = " -march=skylake-avx512 -o $tmpf .o -x c $tmpf " ;
236
+ my @cmd = (" $compiler_name $args >/dev/null 2>/dev/null" );
237
+ system (@cmd ) == 0;
238
+ if ($? != 0) {
239
+ $no_avx512 = 1;
240
+ } else {
241
+ $no_avx512 = 0;
242
+ }
243
+ unlink (" tmpf.o" );
216
244
}
217
- unlink (" tmpf.o" );
218
245
}
219
246
220
247
$data = ` $compiler_name -S ctest1.c && grep globl ctest1.s | head -n 1 && rm -f ctest1.s` ;
0 commit comments