@@ -1150,14 +1150,20 @@ impl<'test> TestCx<'test> {
1150
1150
}
1151
1151
}
1152
1152
1153
- /// `root_testpaths` refers to the path of the original test.
1154
- /// the auxiliary and the test with an aux-build have the same `root_testpaths`.
1153
+ /// `root_testpaths` refers to the path of the original test. the auxiliary and the test with an
1154
+ /// aux-build have the same `root_testpaths`.
1155
1155
fn compose_and_run_compiler (
1156
1156
& self ,
1157
1157
mut rustc : Command ,
1158
1158
input : Option < String > ,
1159
1159
root_testpaths : & TestPaths ,
1160
1160
) -> ProcRes {
1161
+ if self . props . add_core_stubs {
1162
+ let minicore_path = self . build_minicore ( ) ;
1163
+ rustc. arg ( "--extern" ) ;
1164
+ rustc. arg ( & format ! ( "minicore={}" , minicore_path. to_str( ) . unwrap( ) ) ) ;
1165
+ }
1166
+
1161
1167
let aux_dir = self . aux_output_dir ( ) ;
1162
1168
self . build_all_auxiliary ( root_testpaths, & aux_dir, & mut rustc) ;
1163
1169
@@ -1171,6 +1177,37 @@ impl<'test> TestCx<'test> {
1171
1177
)
1172
1178
}
1173
1179
1180
+ /// Builds `minicore`. Returns the path to the minicore rlib within the base test output
1181
+ /// directory.
1182
+ fn build_minicore ( & self ) -> PathBuf {
1183
+ let output_file_path = self . output_base_dir ( ) . join ( "libminicore.rlib" ) ;
1184
+ let mut rustc = self . make_compile_args (
1185
+ & self . config . minicore_path ,
1186
+ TargetLocation :: ThisFile ( output_file_path. clone ( ) ) ,
1187
+ Emit :: None ,
1188
+ AllowUnused :: Yes ,
1189
+ LinkToAux :: No ,
1190
+ vec ! [ ] ,
1191
+ ) ;
1192
+
1193
+ rustc. args ( & [ "--crate-type" , "rlib" ] ) ;
1194
+ rustc. arg ( "-Cpanic=abort" ) ;
1195
+
1196
+ let res =
1197
+ self . compose_and_run ( rustc, self . config . compile_lib_path . to_str ( ) . unwrap ( ) , None , None ) ;
1198
+ if !res. status . success ( ) {
1199
+ self . fatal_proc_rec (
1200
+ & format ! (
1201
+ "auxiliary build of {:?} failed to compile: " ,
1202
+ self . config. minicore_path. display( )
1203
+ ) ,
1204
+ & res,
1205
+ ) ;
1206
+ }
1207
+
1208
+ output_file_path
1209
+ }
1210
+
1174
1211
/// Builds an aux dependency.
1175
1212
fn build_auxiliary (
1176
1213
& self ,
@@ -1662,6 +1699,15 @@ impl<'test> TestCx<'test> {
1662
1699
1663
1700
rustc. args ( & self . props . compile_flags ) ;
1664
1701
1702
+ // FIXME(jieyouxu): we should report a fatal error or warning if user wrote `-Cpanic=` with
1703
+ // something that's not `abort`, however, by moving this last we should override previous
1704
+ // `-Cpanic=`s
1705
+ //
1706
+ // `minicore` requires `#![no_std]` and `#![no_core]`, which means no unwinding panics.
1707
+ if self . props . add_core_stubs {
1708
+ rustc. arg ( "-Cpanic=abort" ) ;
1709
+ }
1710
+
1665
1711
rustc
1666
1712
}
1667
1713
0 commit comments