@@ -198,6 +198,9 @@ pub struct TestProps {
198
198
pub no_auto_check_cfg : bool ,
199
199
/// Run tests which require enzyme being build
200
200
pub has_enzyme : bool ,
201
+ /// Build and use `minicore` as `core` stub for `no_core` tests in cross-compilation scenarios
202
+ /// that don't otherwise want/need `-Z build-std`.
203
+ pub add_core_stubs : bool ,
201
204
}
202
205
203
206
mod directives {
@@ -243,6 +246,7 @@ mod directives {
243
246
pub const LLVM_COV_FLAGS : & ' static str = "llvm-cov-flags" ;
244
247
pub const FILECHECK_FLAGS : & ' static str = "filecheck-flags" ;
245
248
pub const NO_AUTO_CHECK_CFG : & ' static str = "no-auto-check-cfg" ;
249
+ pub const ADD_CORE_STUBS : & ' static str = "add-core-stubs" ;
246
250
// This isn't a real directive, just one that is probably mistyped often
247
251
pub const INCORRECT_COMPILER_FLAGS : & ' static str = "compiler-flags" ;
248
252
}
@@ -300,6 +304,7 @@ impl TestProps {
300
304
filecheck_flags : vec ! [ ] ,
301
305
no_auto_check_cfg : false ,
302
306
has_enzyme : false ,
307
+ add_core_stubs : false ,
303
308
}
304
309
}
305
310
@@ -564,6 +569,8 @@ impl TestProps {
564
569
}
565
570
566
571
config. set_name_directive ( ln, NO_AUTO_CHECK_CFG , & mut self . no_auto_check_cfg ) ;
572
+
573
+ self . update_add_core_stubs ( ln, config) ;
567
574
} ,
568
575
) ;
569
576
@@ -677,6 +684,27 @@ impl TestProps {
677
684
pub fn local_pass_mode ( & self ) -> Option < PassMode > {
678
685
self . pass_mode
679
686
}
687
+
688
+ pub fn update_add_core_stubs ( & mut self , ln : & str , config : & Config ) {
689
+ let add_core_stubs = config. parse_name_directive ( ln, directives:: ADD_CORE_STUBS ) ;
690
+ if add_core_stubs {
691
+ if !matches ! ( config. mode, Mode :: Ui | Mode :: Codegen | Mode :: Assembly ) {
692
+ panic ! (
693
+ "`add-core-stubs` is currently only supported for ui, codegen and assembly test modes"
694
+ ) ;
695
+ }
696
+
697
+ // FIXME(jieyouxu): this check is currently order-dependent, but we should probably
698
+ // collect all directives in one go then perform a validation pass after that.
699
+ if self . local_pass_mode ( ) . is_some_and ( |pm| pm == PassMode :: Run ) {
700
+ // `minicore` can only be used with non-run modes, because it's `core` prelude stubs
701
+ // and can't run.
702
+ panic ! ( "`add-core-stubs` cannot be used to run the test binary" ) ;
703
+ }
704
+
705
+ self . add_core_stubs = add_core_stubs;
706
+ }
707
+ }
680
708
}
681
709
682
710
/// If the given line begins with the appropriate comment prefix for a directive,
0 commit comments