@@ -827,7 +827,7 @@ impl<'test> TestCx<'test> {
827827 _ => AllowUnused :: No ,
828828 } ;
829829
830- let rustc = self . make_compile_args (
830+ let mut rustc = self . make_compile_args (
831831 & self . testpaths . file ,
832832 output_file,
833833 emit,
@@ -836,6 +836,12 @@ impl<'test> TestCx<'test> {
836836 passes,
837837 ) ;
838838
839+ if self . props . use_minicore {
840+ let minicore_path = self . build_minicore ( ) ;
841+ rustc. arg ( "--extern" ) ;
842+ rustc. arg ( & format ! ( "minicore={}" , minicore_path. to_str( ) . unwrap( ) ) ) ;
843+ }
844+
839845 self . compose_and_run_compiler ( rustc, None , self . testpaths )
840846 }
841847
@@ -1108,8 +1114,8 @@ impl<'test> TestCx<'test> {
11081114 }
11091115 }
11101116
1111- /// `root_testpaths` refers to the path of the original test.
1112- /// the auxiliary and the test with an aux-build have the same `root_testpaths`.
1117+ /// `root_testpaths` refers to the path of the original test. the auxiliary and the test with an
1118+ /// aux-build have the same `root_testpaths`.
11131119 fn compose_and_run_compiler (
11141120 & self ,
11151121 mut rustc : Command ,
@@ -1129,6 +1135,37 @@ impl<'test> TestCx<'test> {
11291135 )
11301136 }
11311137
1138+ /// Builds `minicore`. Returns the path to the minicore rlib within the base test output
1139+ /// directory.
1140+ fn build_minicore ( & self ) -> PathBuf {
1141+ let output_file_path = self . output_base_dir ( ) . join ( "libminicore.rlib" ) ;
1142+ let mut rustc = self . make_compile_args (
1143+ & self . config . minicore_path ,
1144+ TargetLocation :: ThisFile ( output_file_path. clone ( ) ) ,
1145+ Emit :: None ,
1146+ AllowUnused :: Yes ,
1147+ LinkToAux :: No ,
1148+ vec ! [ ] ,
1149+ ) ;
1150+
1151+ rustc. args ( & [ "--crate-type" , "rlib" ] ) ;
1152+ rustc. arg ( "-Cpanic=abort" ) ;
1153+
1154+ let res =
1155+ self . compose_and_run ( rustc, self . config . compile_lib_path . to_str ( ) . unwrap ( ) , None , None ) ;
1156+ if !res. status . success ( ) {
1157+ self . fatal_proc_rec (
1158+ & format ! (
1159+ "auxiliary build of {:?} failed to compile: " ,
1160+ self . config. minicore_path. display( )
1161+ ) ,
1162+ & res,
1163+ ) ;
1164+ }
1165+
1166+ output_file_path
1167+ }
1168+
11321169 /// Builds an aux dependency.
11331170 fn build_auxiliary (
11341171 & self ,
@@ -1420,6 +1457,11 @@ impl<'test> TestCx<'test> {
14201457 rustc. arg ( dir_opt) ;
14211458 } ;
14221459
1460+ // `use-minicore` requires `#![no_std]` and `#![no_core]`, which means no unwinding panics.
1461+ if self . props . use_minicore {
1462+ rustc. arg ( "-Cpanic=abort" ) ;
1463+ }
1464+
14231465 match self . config . mode {
14241466 Incremental => {
14251467 // If we are extracting and matching errors in the new
0 commit comments