@@ -15,17 +15,19 @@ use git_testament::{git_testament, render_testament};
15
15
use tracing:: { debug, error, info, trace, warn} ;
16
16
17
17
use super :: self_update;
18
- use crate :: cli:: download_tracker:: DownloadTracker ;
19
- use crate :: dist:: {
20
- manifest:: ComponentStatus , notifications as dist_notifications, TargetTriple , ToolchainDesc ,
18
+ use crate :: {
19
+ cli:: download_tracker:: DownloadTracker ,
20
+ config:: Cfg ,
21
+ dist:: {
22
+ manifest:: ComponentStatus , notifications as dist_notifications, PartialToolchainDesc ,
23
+ TargetTriple , ToolchainDesc ,
24
+ } ,
25
+ install:: UpdateStatus ,
26
+ notifications:: Notification ,
27
+ process:: { terminalsource, Process } ,
28
+ toolchain:: { DistributableToolchain , LocalToolchainName , Toolchain , ToolchainName } ,
29
+ utils:: { notifications as util_notifications, notify:: NotificationLevel , utils} ,
21
30
} ;
22
- use crate :: install:: UpdateStatus ;
23
- use crate :: process:: { terminalsource, Process } ;
24
- use crate :: toolchain:: { DistributableToolchain , LocalToolchainName , Toolchain , ToolchainName } ;
25
- use crate :: utils:: notifications as util_notifications;
26
- use crate :: utils:: notify:: NotificationLevel ;
27
- use crate :: utils:: utils;
28
- use crate :: { config:: Cfg , notifications:: Notification } ;
29
31
30
32
pub ( crate ) const WARN_COMPLETE_PROFILE : & str = "downloading with complete profile isn't recommended unless you are a developer of the rust language" ;
31
33
@@ -633,6 +635,25 @@ pub(crate) fn ignorable_error(
633
635
}
634
636
}
635
637
638
+ /// Warns if rustup is trying to install a toolchain that might not be
639
+ /// able to run on the host system.
640
+ pub ( crate ) fn warn_if_host_is_incompatible (
641
+ process : & Process ,
642
+ name : & PartialToolchainDesc ,
643
+ force_non_host : bool ,
644
+ ) -> Result < ( ) > {
645
+ if name. has_triple ( ) {
646
+ let host_arch = TargetTriple :: from_host_or_build ( process) ;
647
+ let target_triple = name. clone ( ) . resolve ( & host_arch) ?. target ;
648
+ if !force_non_host && !host_arch. can_run ( & target_triple) ? {
649
+ error ! ( "DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain." ) ;
650
+ warn ! ( "toolchain '{name}' may not be able to run on this system." ) ;
651
+ warn ! ( "If you meant to build software to target that platform, perhaps try `rustup target add {target_triple}` instead?" ) ;
652
+ }
653
+ }
654
+ Ok ( ( ) )
655
+ }
656
+
636
657
/// Warns if rustup is running under emulation, such as macOS Rosetta
637
658
pub ( crate ) fn warn_if_host_is_emulated ( process : & Process ) {
638
659
if TargetTriple :: is_host_emulated ( ) {
0 commit comments