3 files changed +32
-42
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -11,10 +11,40 @@ use run_make_support::llvm_readobj;
11
11
use run_make_support:: rustc;
12
12
use run_make_support:: { cmd, run_with_args, target} ;
13
13
14
+ // Minimum major versions supporting -static-pie
15
+ const GCC_VERSION : u32 = 8 ;
16
+ const CLANG_VERSION : u32 = 9 ;
17
+
18
+ // Return `true` if the `compiler` version supports `-static-pie`.
14
19
fn ok_compiler_version ( compiler : & str ) -> bool {
15
- let check_file = format ! ( "check_{compiler}_version.sh" ) ;
20
+ let version_threshold = match compiler {
21
+ "clang" => CLANG_VERSION ,
22
+ "gcc" => GCC_VERSION ,
23
+ other => panic ! ( "unexpected compiler '{other}', expected 'clang' or 'gcc'" ) ,
24
+ } ;
16
25
17
- Command :: new ( check_file) . status ( ) . is_ok_and ( |status| status. success ( ) )
26
+ if Command :: new ( compiler) . spawn ( ) . is_err ( ) {
27
+ eprintln ! ( "No {compiler} version detected" ) ;
28
+ return false ;
29
+ }
30
+ // 'major.minor.patch', 'major.minor', or 'major'
31
+ let version: u32 = cmd ( compiler)
32
+ . arg ( "-dumpversion" )
33
+ . run ( )
34
+ . stdout_utf8 ( )
35
+ . split ( "." )
36
+ . next ( )
37
+ . unwrap ( )
38
+ . parse ( )
39
+ . unwrap ( ) ;
40
+
41
+ if version >= version_threshold {
42
+ eprintln ! ( "{compiler} supports -static-pie" ) ;
43
+ true
44
+ } else {
45
+ eprintln ! ( "{compiler} too old to support -static-pie, skipping test" ) ;
46
+ false
47
+ }
18
48
}
19
49
20
50
fn test ( compiler : & str ) {
0 commit comments