@@ -13,7 +13,21 @@ macro_rules! eprintln {
13
13
}
14
14
}
15
15
16
- const MIRI_PATH : & ' static str = concat ! ( "target/" , env!( "PROFILE" ) , "/miri" ) ;
16
+ fn miri_path ( ) -> PathBuf {
17
+ if rustc_test_suite ( ) . is_some ( ) {
18
+ PathBuf :: from ( option_env ! ( "MIRI_PATH" ) . unwrap ( ) )
19
+ } else {
20
+ PathBuf :: from ( concat ! ( "target/" , env!( "PROFILE" ) , "/miri" ) )
21
+ }
22
+ }
23
+
24
+ fn rustc_test_suite ( ) -> Option < PathBuf > {
25
+ option_env ! ( "RUSTC_TEST_SUITE" ) . map ( PathBuf :: from)
26
+ }
27
+
28
+ fn rustc_lib_path ( ) -> PathBuf {
29
+ option_env ! ( "RUSTC_LIB_PATH" ) . unwrap ( ) . into ( )
30
+ }
17
31
18
32
fn compile_fail ( sysroot : & Path , path : & str , target : & str , host : & str , fullmir : bool ) {
19
33
eprintln ! (
@@ -23,9 +37,14 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: b
23
37
) ;
24
38
let mut config = compiletest:: default_config ( ) ;
25
39
config. mode = "compile-fail" . parse ( ) . expect ( "Invalid mode" ) ;
26
- config. rustc_path = MIRI_PATH . into ( ) ;
40
+ config. rustc_path = miri_path ( ) ;
27
41
let mut flags = Vec :: new ( ) ;
28
- if fullmir {
42
+ if rustc_test_suite ( ) . is_some ( ) {
43
+ config. run_lib_path = rustc_lib_path ( ) ;
44
+ config. compile_lib_path = rustc_lib_path ( ) ;
45
+ }
46
+ // if we are building as part of the rustc test suite, we already have fullmir for everything
47
+ if fullmir && rustc_test_suite ( ) . is_none ( ) {
29
48
if host != target {
30
49
// skip fullmir on nonhost
31
50
return ;
@@ -50,7 +69,14 @@ fn run_pass(path: &str) {
50
69
let mut config = compiletest:: default_config ( ) ;
51
70
config. mode = "run-pass" . parse ( ) . expect ( "Invalid mode" ) ;
52
71
config. src_base = PathBuf :: from ( path) ;
53
- config. target_rustcflags = Some ( "-Dwarnings" . to_string ( ) ) ;
72
+ if let Some ( rustc_path) = rustc_test_suite ( ) {
73
+ config. rustc_path = rustc_path;
74
+ config. run_lib_path = rustc_lib_path ( ) ;
75
+ config. compile_lib_path = rustc_lib_path ( ) ;
76
+ config. target_rustcflags = Some ( format ! ( "-Dwarnings --sysroot {}" , get_sysroot( ) . display( ) ) ) ;
77
+ } else {
78
+ config. target_rustcflags = Some ( "-Dwarnings" . to_owned ( ) ) ;
79
+ }
54
80
config. host_rustcflags = Some ( "-Dwarnings" . to_string ( ) ) ;
55
81
compiletest:: run_tests ( & config) ;
56
82
}
@@ -68,9 +94,14 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) {
68
94
config. src_base = PathBuf :: from ( path) ;
69
95
config. target = target. to_owned ( ) ;
70
96
config. host = host. to_owned ( ) ;
71
- config. rustc_path = MIRI_PATH . into ( ) ;
97
+ config. rustc_path = miri_path ( ) ;
98
+ if rustc_test_suite ( ) . is_some ( ) {
99
+ config. run_lib_path = rustc_lib_path ( ) ;
100
+ config. compile_lib_path = rustc_lib_path ( ) ;
101
+ }
72
102
let mut flags = Vec :: new ( ) ;
73
- if fullmir {
103
+ // if we are building as part of the rustc test suite, we already have fullmir for everything
104
+ if fullmir && rustc_test_suite ( ) . is_none ( ) {
74
105
if host != target {
75
106
// skip fullmir on nonhost
76
107
return ;
0 commit comments