@@ -827,7 +827,7 @@ impl<'test> TestCx<'test> {
827
827
_ => AllowUnused :: No ,
828
828
} ;
829
829
830
- let rustc = self . make_compile_args (
830
+ let mut rustc = self . make_compile_args (
831
831
& self . testpaths . file ,
832
832
output_file,
833
833
emit,
@@ -836,6 +836,12 @@ impl<'test> TestCx<'test> {
836
836
passes,
837
837
) ;
838
838
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
+
839
845
self . compose_and_run_compiler ( rustc, None , self . testpaths )
840
846
}
841
847
@@ -1108,8 +1114,8 @@ impl<'test> TestCx<'test> {
1108
1114
}
1109
1115
}
1110
1116
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`.
1113
1119
fn compose_and_run_compiler (
1114
1120
& self ,
1115
1121
mut rustc : Command ,
@@ -1129,6 +1135,37 @@ impl<'test> TestCx<'test> {
1129
1135
)
1130
1136
}
1131
1137
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
+
1132
1169
/// Builds an aux dependency.
1133
1170
fn build_auxiliary (
1134
1171
& self ,
@@ -1420,6 +1457,11 @@ impl<'test> TestCx<'test> {
1420
1457
rustc. arg ( dir_opt) ;
1421
1458
} ;
1422
1459
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
+
1423
1465
match self . config . mode {
1424
1466
Incremental => {
1425
1467
// If we are extracting and matching errors in the new
0 commit comments