@@ -682,34 +682,29 @@ impl<'cfg> RustcTargetData<'cfg> {
682682 ) -> CargoResult < RustcTargetData < ' cfg > > {
683683 let config = ws. config ( ) ;
684684 let rustc = config. load_global_rustc ( Some ( ws) ) ?;
685- let host_info = TargetInfo :: new ( config, requested_kinds, & rustc, CompileKind :: Host ) ?;
686685 let mut target_config = HashMap :: new ( ) ;
687686 let mut target_info = HashMap :: new ( ) ;
687+ let target_applies_to_host = config. target_applies_to_host ( ) ?;
688+ let host_info = TargetInfo :: new ( config, requested_kinds, & rustc, CompileKind :: Host ) ?;
689+ let host_config = if target_applies_to_host {
690+ config. target_cfg_triple ( & rustc. host ) ?
691+ } else {
692+ config. host_cfg_triple ( & rustc. host ) ?
693+ } ;
688694
689695 // This is a hack. The unit_dependency graph builder "pretends" that
690696 // `CompileKind::Host` is `CompileKind::Target(host)` if the
691697 // `--target` flag is not specified. Since the unit_dependency code
692698 // needs access to the target config data, create a copy so that it
693699 // can be found. See `rebuild_unit_graph_shared` for why this is done.
694- let target_applies_to_host = config. target_applies_to_host ( ) ?;
695- let host_config = if requested_kinds. iter ( ) . any ( CompileKind :: is_host) {
700+ if requested_kinds. iter ( ) . any ( CompileKind :: is_host) {
696701 let ct = CompileTarget :: new ( & rustc. host ) ?;
697702 target_info. insert ( ct, host_info. clone ( ) ) ;
698- let target_host_config = if target_applies_to_host {
699- let target_cfg_clone = config. target_cfg_triple ( & rustc. host ) ?;
700- target_config. insert ( ct, target_cfg_clone. clone ( ) ) ;
701- target_cfg_clone
703+ if target_applies_to_host {
704+ target_config. insert ( ct, host_config. clone ( ) ) ;
702705 } else {
703706 target_config. insert ( ct, config. target_cfg_triple ( & rustc. host ) ?) ;
704- config. host_cfg_triple ( & rustc. host ) ?
705707 } ;
706- target_host_config
707- } else {
708- if target_applies_to_host {
709- config. target_cfg_triple ( & rustc. host ) ?
710- } else {
711- config. host_cfg_triple ( & rustc. host ) ?
712- }
713708 } ;
714709
715710 let mut res = RustcTargetData {
0 commit comments