@@ -1284,7 +1284,13 @@ impl Step for RustDemangler {
1284
1284
const ONLY_HOSTS : bool = true ;
1285
1285
1286
1286
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
1287
- run. path ( "rust-demangler" )
1287
+ // While other tools use `should_build_extended_tool` to decide whether to be run by
1288
+ // default or not, `rust-demangler` must be build when *either* it's enabled as a tool like
1289
+ // the other ones or if `profiler = true`. Because we don't know the target at this stage
1290
+ // we run the step by default when only `extended = true`, and decide whether to actually
1291
+ // run it or not later.
1292
+ let default = run. builder . config . extended ;
1293
+ run. path ( "rust-demangler" ) . default_condition ( default)
1288
1294
}
1289
1295
1290
1296
fn make_run ( run : RunConfig < ' _ > ) {
@@ -1301,11 +1307,11 @@ impl Step for RustDemangler {
1301
1307
fn run ( self , builder : & Builder < ' _ > ) -> Option < GeneratedTarball > {
1302
1308
let compiler = self . compiler ;
1303
1309
let target = self . target ;
1304
- assert ! ( builder. config. extended) ;
1305
1310
1306
1311
// Only build this extended tool if explicitly included in `tools`, or if `profiler = true`
1307
- let profiler = builder. config . profiler_enabled ( target) ;
1308
- if !builder. config . tools . as_ref ( ) . map_or ( profiler, |t| t. contains ( "rust-demangler" ) ) {
1312
+ let condition = should_build_extended_tool ( builder, "rust-demangler" )
1313
+ || builder. config . profiler_enabled ( target) ;
1314
+ if builder. config . extended && !condition {
1309
1315
return None ;
1310
1316
}
1311
1317
@@ -1380,6 +1386,15 @@ impl Step for Extended {
1380
1386
tarballs. push ( builder. ensure ( Docs { host : target } ) ) ;
1381
1387
}
1382
1388
1389
+ if builder. config . profiler_enabled ( target)
1390
+ || should_build_extended_tool ( builder, "rust-demangler" )
1391
+ {
1392
+ if let Some ( tarball) = builder. ensure ( RustDemangler { compiler, target } ) {
1393
+ tarballs. push ( tarball) ;
1394
+ built_tools. insert ( "rust-demangler" ) ;
1395
+ }
1396
+ }
1397
+
1383
1398
add_tool ! ( "cargo" => Cargo { compiler, target } ) ;
1384
1399
add_tool ! ( "rustfmt" => Rustfmt { compiler, target } ) ;
1385
1400
add_tool ! ( "rls" => Rls { compiler, target } ) ;
@@ -1389,7 +1404,6 @@ impl Step for Extended {
1389
1404
add_tool ! ( "miri" => Miri { compiler, target } ) ;
1390
1405
add_tool ! ( "analysis" => Analysis { compiler, target } ) ;
1391
1406
1392
- let rust_demangler_installer = builder. ensure ( RustDemangler { compiler, target } ) ;
1393
1407
let mingw_installer = builder. ensure ( Mingw { host : target } ) ;
1394
1408
1395
1409
let etc = builder. src . join ( "src/etc/installer" ) ;
@@ -1399,8 +1413,6 @@ impl Step for Extended {
1399
1413
return ;
1400
1414
}
1401
1415
1402
- tarballs. extend ( rust_demangler_installer. clone ( ) ) ;
1403
-
1404
1416
if target. contains ( "pc-windows-gnu" ) {
1405
1417
tarballs. push ( mingw_installer. unwrap ( ) ) ;
1406
1418
}
@@ -1447,11 +1459,7 @@ impl Step for Extended {
1447
1459
1448
1460
let xform = |p : & Path | {
1449
1461
let mut contents = t ! ( fs:: read_to_string( p) ) ;
1450
- if rust_demangler_installer. is_none ( ) {
1451
- contents = filter ( & contents, "rust-demangler" ) ;
1452
- }
1453
-
1454
- for tool in & [ "rls" , "rust-analyzer" , "miri" , "rustfmt" ] {
1462
+ for tool in & [ "rust-demangler" , "rls" , "rust-analyzer" , "miri" , "rustfmt" ] {
1455
1463
if !built_tools. contains ( tool) {
1456
1464
contents = filter ( & contents, tool) ;
1457
1465
}
@@ -1492,10 +1500,7 @@ impl Step for Extended {
1492
1500
prepare ( "rust-std" ) ;
1493
1501
prepare ( "rust-analysis" ) ;
1494
1502
prepare ( "clippy" ) ;
1495
- if rust_demangler_installer. is_some ( ) {
1496
- prepare ( "rust-demangler" ) ;
1497
- }
1498
- for tool in & [ "rls" , "rust-analyzer" , "miri" ] {
1503
+ for tool in & [ "rust-demangler" , "rls" , "rust-analyzer" , "miri" ] {
1499
1504
if built_tools. contains ( tool) {
1500
1505
prepare ( tool) ;
1501
1506
}
@@ -1556,10 +1561,7 @@ impl Step for Extended {
1556
1561
prepare ( "rust-docs" ) ;
1557
1562
prepare ( "rust-std" ) ;
1558
1563
prepare ( "clippy" ) ;
1559
- if rust_demangler_installer. is_some ( ) {
1560
- prepare ( "rust-demangler" ) ;
1561
- }
1562
- for tool in & [ "rls" , "rust-analyzer" , "miri" ] {
1564
+ for tool in & [ "rust-demangler" , "rls" , "rust-analyzer" , "miri" ] {
1563
1565
if built_tools. contains ( tool) {
1564
1566
prepare ( tool) ;
1565
1567
}
@@ -1696,7 +1698,7 @@ impl Step for Extended {
1696
1698
. arg ( "-t" )
1697
1699
. arg ( etc. join ( "msi/remove-duplicates.xsl" ) ) ,
1698
1700
) ;
1699
- if rust_demangler_installer . is_some ( ) {
1701
+ if built_tools . contains ( "rust-demangler" ) {
1700
1702
builder. run (
1701
1703
Command :: new ( & heat)
1702
1704
. current_dir ( & exe)
@@ -1788,7 +1790,7 @@ impl Step for Extended {
1788
1790
. arg ( & input) ;
1789
1791
add_env ( builder, & mut cmd, target) ;
1790
1792
1791
- if rust_demangler_installer . is_some ( ) {
1793
+ if built_tools . contains ( "rust-demangler" ) {
1792
1794
cmd. arg ( "-dRustDemanglerDir=rust-demangler" ) ;
1793
1795
}
1794
1796
if built_tools. contains ( "rls" ) {
@@ -1813,7 +1815,7 @@ impl Step for Extended {
1813
1815
candle ( "CargoGroup.wxs" . as_ref ( ) ) ;
1814
1816
candle ( "StdGroup.wxs" . as_ref ( ) ) ;
1815
1817
candle ( "ClippyGroup.wxs" . as_ref ( ) ) ;
1816
- if rust_demangler_installer . is_some ( ) {
1818
+ if built_tools . contains ( "rust-demangler" ) {
1817
1819
candle ( "RustDemanglerGroup.wxs" . as_ref ( ) ) ;
1818
1820
}
1819
1821
if built_tools. contains ( "rls" ) {
@@ -1862,7 +1864,7 @@ impl Step for Extended {
1862
1864
if built_tools. contains ( "rust-analyzer" ) {
1863
1865
cmd. arg ( "RustAnalyzerGroup.wixobj" ) ;
1864
1866
}
1865
- if rust_demangler_installer . is_some ( ) {
1867
+ if built_tools . contains ( "rust-demangler" ) {
1866
1868
cmd. arg ( "RustDemanglerGroup.wixobj" ) ;
1867
1869
}
1868
1870
if built_tools. contains ( "miri" ) {
0 commit comments