@@ -30,6 +30,22 @@ use crate::{envify, CLang, DocTests, GitRepo, Mode};
30
30
31
31
const ADB_TEST_DIR : & str = "/data/local/tmp/work" ;
32
32
33
+ // mir-opt tests have different variants depending on whether a target is 32bit or 64bit, and
34
+ // blessing them requires blessing with each target. To aid developers, when blessing the mir-opt
35
+ // test suite the corresponding target of the opposite pointer size is also blessed.
36
+ //
37
+ // This array serves as the known mappings between 32bit and 64bit targets. If you're developing on
38
+ // a target where a target with the opposite pointer size exists, feel free to add it here.
39
+ const MIR_OPT_BLESS_TARGET_MAPPING : & [ ( & str , & str ) ] = & [
40
+ // (32bit, 64bit)
41
+ ( "i686-unknown-linux-gnu" , "x86_64-unknown-linux-gnu" ) ,
42
+ ( "i686-unknown-linux-musl" , "x86_64-unknown-linux-musl" ) ,
43
+ ( "i686-pc-windows-msvc" , "x86_64-pc-windows-msvc" ) ,
44
+ ( "i686-pc-windows-gnu" , "x86_64-pc-windows-gnu" ) ,
45
+ ( "i686-apple-darwin" , "x86_64-apple-darwin" ) ,
46
+ ( "i686-apple-darwin" , "aarch64-apple-darwin" ) ,
47
+ ] ;
48
+
33
49
fn try_run ( builder : & Builder < ' _ > , cmd : & mut Command ) -> bool {
34
50
if !builder. fail_fast {
35
51
if !builder. try_run ( cmd) {
@@ -1319,14 +1335,60 @@ impl Step for MirOpt {
1319
1335
}
1320
1336
1321
1337
fn run ( self , builder : & Builder < ' _ > ) {
1322
- builder. ensure ( Compiletest {
1323
- compiler : self . compiler ,
1324
- target : self . target ,
1325
- mode : "mir-opt" ,
1326
- suite : "mir-opt" ,
1327
- path : "tests/mir-opt" ,
1328
- compare_mode : None ,
1329
- } ) ;
1338
+ let run = |target| {
1339
+ builder. ensure ( Compiletest {
1340
+ compiler : self . compiler ,
1341
+ target : target,
1342
+ mode : "mir-opt" ,
1343
+ suite : "mir-opt" ,
1344
+ path : "tests/mir-opt" ,
1345
+ compare_mode : None ,
1346
+ } )
1347
+ } ;
1348
+
1349
+ // We use custom logic to bless the mir-opt suite: mir-opt tests have multiple variants
1350
+ // (32bit vs 64bit), and all of them needs to be blessed. When blessing, we try best-effort
1351
+ // to also bless the other variants, to aid developers.
1352
+ if builder. config . cmd . bless ( ) {
1353
+ let targets = MIR_OPT_BLESS_TARGET_MAPPING
1354
+ . iter ( )
1355
+ . filter ( |( target_32bit, target_64bit) | {
1356
+ * target_32bit == & * self . target . triple || * target_64bit == & * self . target . triple
1357
+ } )
1358
+ . next ( )
1359
+ . map ( |( target_32bit, target_64bit) | {
1360
+ let target_32bit = TargetSelection :: from_user ( target_32bit) ;
1361
+ let target_64bit = TargetSelection :: from_user ( target_64bit) ;
1362
+
1363
+ // Running compiletest requires a C compiler to be available, but it might not
1364
+ // have been detected by bootstrap if the target we're testing wasn't in the
1365
+ // --target flags.
1366
+ if !builder. cc . borrow ( ) . contains_key ( & target_32bit) {
1367
+ crate :: cc_detect:: find_target ( builder, target_32bit) ;
1368
+ }
1369
+ if !builder. cc . borrow ( ) . contains_key ( & target_64bit) {
1370
+ crate :: cc_detect:: find_target ( builder, target_64bit) ;
1371
+ }
1372
+
1373
+ vec ! [ target_32bit, target_64bit]
1374
+ } )
1375
+ . unwrap_or_else ( || {
1376
+ eprintln ! (
1377
+ "\
1378
+ Note that not all variants of mir-opt tests are going to be blessed, as no mapping between
1379
+ a 32bit and a 64bit target was found for {target}.
1380
+ You can add that mapping by changing MIR_OPT_BLESS_TARGET_MAPPING in src/bootstrap/test.rs" ,
1381
+ target = self . target,
1382
+ ) ;
1383
+ vec ! [ self . target]
1384
+ } ) ;
1385
+
1386
+ for target in targets {
1387
+ run ( target) ;
1388
+ }
1389
+ } else {
1390
+ run ( self . target ) ;
1391
+ }
1330
1392
}
1331
1393
}
1332
1394
0 commit comments