@@ -428,10 +428,14 @@ pub fn create_bcx<'a, 'cfg>(
428
428
remove_duplicate_doc ( build_config, & units, & mut unit_graph) ;
429
429
}
430
430
431
- if build_config
431
+ let host_kind_requested = build_config
432
432
. requested_kinds
433
433
. iter ( )
434
- . any ( CompileKind :: is_host)
434
+ . any ( CompileKind :: is_host) ;
435
+ if host_kind_requested
436
+ || unit_graph
437
+ . iter ( )
438
+ . any ( |unit| unit. 0 . artifact_target_for_features . is_some ( ) )
435
439
{
436
440
// Rebuild the unit graph, replacing the explicit host targets with
437
441
// CompileKind::Host, merging any dependencies shared with build
@@ -441,7 +445,7 @@ pub fn create_bcx<'a, 'cfg>(
441
445
unit_graph,
442
446
& units,
443
447
& scrape_units,
444
- explicit_host_kind,
448
+ host_kind_requested . then_some ( explicit_host_kind) ,
445
449
) ;
446
450
// This would be nicer with destructuring assignment.
447
451
units = new_graph. 0 ;
@@ -575,7 +579,7 @@ fn rebuild_unit_graph_shared(
575
579
unit_graph : UnitGraph ,
576
580
roots : & [ Unit ] ,
577
581
scrape_units : & [ Unit ] ,
578
- to_host : CompileKind ,
582
+ to_host : Option < CompileKind > ,
579
583
) -> ( Vec < Unit > , Vec < Unit > , UnitGraph ) {
580
584
let mut result = UnitGraph :: new ( ) ;
581
585
// Map of the old unit to the new unit, used to avoid recursing into units
@@ -608,7 +612,7 @@ fn traverse_and_share(
608
612
new_graph : & mut UnitGraph ,
609
613
unit_graph : & UnitGraph ,
610
614
unit : & Unit ,
611
- to_host : CompileKind ,
615
+ to_host : Option < CompileKind > ,
612
616
) -> Unit {
613
617
if let Some ( new_unit) = memo. get ( unit) {
614
618
// Already computed, no need to recompute.
@@ -628,10 +632,9 @@ fn traverse_and_share(
628
632
} )
629
633
. collect ( ) ;
630
634
let new_dep_hash = dep_hash. finish ( ) ;
631
- let new_kind = if unit. kind == to_host {
632
- CompileKind :: Host
633
- } else {
634
- unit. kind
635
+ let new_kind = match to_host {
636
+ Some ( to_host) if to_host == unit. kind => CompileKind :: Host ,
637
+ _ => unit. kind ,
635
638
} ;
636
639
let new_unit = interner. intern (
637
640
& unit. pkg ,
@@ -643,6 +646,7 @@ fn traverse_and_share(
643
646
unit. is_std ,
644
647
new_dep_hash,
645
648
unit. artifact ,
649
+ None ,
646
650
) ;
647
651
assert ! ( memo. insert( unit. clone( ) , new_unit. clone( ) ) . is_none( ) ) ;
648
652
new_graph. entry ( new_unit. clone ( ) ) . or_insert ( new_deps) ;
@@ -801,6 +805,7 @@ fn override_rustc_crate_types(
801
805
unit. is_std ,
802
806
unit. dep_hash ,
803
807
unit. artifact ,
808
+ unit. artifact_target_for_features ,
804
809
)
805
810
} ;
806
811
units[ 0 ] = match unit. target . kind ( ) {
0 commit comments