@@ -92,27 +92,35 @@ pub struct QualifiedToolchain {
9292}
9393
9494impl QualifiedToolchain {
95- pub fn new ( channel : & str , date : & Option < String > , host : & ImagePlatform , sysroot : & Path ) -> Self {
95+ pub fn new (
96+ channel : & str ,
97+ date : & Option < String > ,
98+ host : & ImagePlatform ,
99+ sysroot : & Path ,
100+ is_custom : bool ,
101+ ) -> Self {
96102 let mut this = Self {
97103 channel : channel. to_owned ( ) ,
98104 date : date. clone ( ) ,
99105 host : host. clone ( ) ,
100- is_custom : false ,
106+ is_custom,
101107 full : if let Some ( date) = date {
102108 format ! ( "{}-{}-{}" , channel, date, host. target)
103109 } else {
104110 format ! ( "{}-{}" , channel, host. target)
105111 } ,
106112 sysroot : sysroot. to_owned ( ) ,
107113 } ;
108- this. sysroot . set_file_name ( & this. full ) ;
114+ if !is_custom {
115+ this. sysroot . set_file_name ( & this. full ) ;
116+ }
109117 this
110118 }
111119
112120 /// Replace the host, does nothing if ran on a custom toolchain
113121 pub fn replace_host ( & mut self , host : & ImagePlatform ) -> & mut Self {
114122 if !self . is_custom {
115- * self = Self :: new ( & self . channel , & self . date , host, & self . sysroot ) ;
123+ * self = Self :: new ( & self . channel , & self . date , host, & self . sysroot , false ) ;
116124 self . sysroot . set_file_name ( & self . full ) ;
117125 }
118126 self
@@ -168,8 +176,8 @@ impl QualifiedToolchain {
168176 & build_date,
169177 & ImagePlatform :: from_target ( host. into ( ) ) ?,
170178 sysroot,
179+ true ,
171180 ) ;
172- toolchain. is_custom = true ;
173181 toolchain. full = name. to_owned ( ) ;
174182 return Ok ( toolchain) ;
175183 }
@@ -217,6 +225,7 @@ impl QualifiedToolchain {
217225 & date,
218226 & host,
219227 & self . sysroot ,
228+ false ,
220229 ) )
221230 }
222231
@@ -256,7 +265,11 @@ impl QualifiedToolchain {
256265 Ok ( _) | Err ( _) if config. custom_toolchain ( ) => {
257266 QualifiedToolchain :: custom ( toolchain, & sysroot, config, msg_info)
258267 }
259- Ok ( _) => eyre:: bail!( "toolchain is not fully qualified" ) ,
268+ Ok ( _) => return Err ( eyre:: eyre!( "toolchain is not fully qualified" )
269+ . with_note ( || "cross expects the toolchain to be a rustup installed toolchain" )
270+ . with_suggestion ( || {
271+ "if you're using a custom toolchain try setting `CROSS_CUSTOM_TOOLCHAIN=1` or install rust via rustup"
272+ } ) ) ,
260273 Err ( e) => Err ( e) ,
261274 }
262275 }
0 commit comments