@@ -92,27 +92,35 @@ pub struct QualifiedToolchain {
92
92
}
93
93
94
94
impl 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 {
96
102
let mut this = Self {
97
103
channel : channel. to_owned ( ) ,
98
104
date : date. clone ( ) ,
99
105
host : host. clone ( ) ,
100
- is_custom : false ,
106
+ is_custom,
101
107
full : if let Some ( date) = date {
102
108
format ! ( "{}-{}-{}" , channel, date, host. target)
103
109
} else {
104
110
format ! ( "{}-{}" , channel, host. target)
105
111
} ,
106
112
sysroot : sysroot. to_owned ( ) ,
107
113
} ;
108
- this. sysroot . set_file_name ( & this. full ) ;
114
+ if !is_custom {
115
+ this. sysroot . set_file_name ( & this. full ) ;
116
+ }
109
117
this
110
118
}
111
119
112
120
/// Replace the host, does nothing if ran on a custom toolchain
113
121
pub fn replace_host ( & mut self , host : & ImagePlatform ) -> & mut Self {
114
122
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 ) ;
116
124
self . sysroot . set_file_name ( & self . full ) ;
117
125
}
118
126
self
@@ -168,8 +176,8 @@ impl QualifiedToolchain {
168
176
& build_date,
169
177
& ImagePlatform :: from_target ( host. into ( ) ) ?,
170
178
sysroot,
179
+ true ,
171
180
) ;
172
- toolchain. is_custom = true ;
173
181
toolchain. full = name. to_owned ( ) ;
174
182
return Ok ( toolchain) ;
175
183
}
@@ -217,6 +225,7 @@ impl QualifiedToolchain {
217
225
& date,
218
226
& host,
219
227
& self . sysroot ,
228
+ false ,
220
229
) )
221
230
}
222
231
@@ -256,7 +265,11 @@ impl QualifiedToolchain {
256
265
Ok ( _) | Err ( _) if config. custom_toolchain ( ) => {
257
266
QualifiedToolchain :: custom ( toolchain, & sysroot, config, msg_info)
258
267
}
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
+ } ) ) ,
260
273
Err ( e) => Err ( e) ,
261
274
}
262
275
}
0 commit comments