@@ -88,12 +88,14 @@ impl HostFlags {
88
88
#[ derive( Debug ) ]
89
89
pub struct Cargo {
90
90
command : BootstrapCommand ,
91
+ args : Vec < OsString > ,
91
92
compiler : Compiler ,
92
93
target : TargetSelection ,
93
94
rustflags : Rustflags ,
94
95
rustdocflags : Rustflags ,
95
96
hostflags : HostFlags ,
96
97
allow_features : String ,
98
+ release_build : bool ,
97
99
}
98
100
99
101
impl Cargo {
@@ -121,6 +123,10 @@ impl Cargo {
121
123
cargo
122
124
}
123
125
126
+ pub fn release_build ( & mut self , release_build : bool ) {
127
+ self . release_build = release_build;
128
+ }
129
+
124
130
pub fn compiler ( & self ) -> Compiler {
125
131
self . compiler
126
132
}
@@ -153,7 +159,7 @@ impl Cargo {
153
159
}
154
160
155
161
pub fn arg ( & mut self , arg : impl AsRef < OsStr > ) -> & mut Cargo {
156
- self . command . arg ( arg. as_ref ( ) ) ;
162
+ self . args . push ( arg. as_ref ( ) . into ( ) ) ;
157
163
self
158
164
}
159
165
@@ -335,6 +341,12 @@ impl Cargo {
335
341
336
342
impl From < Cargo > for BootstrapCommand {
337
343
fn from ( mut cargo : Cargo ) -> BootstrapCommand {
344
+ if cargo. release_build {
345
+ cargo. args . insert ( 0 , "--release" . into ( ) ) ;
346
+ }
347
+
348
+ cargo. command . args ( cargo. args ) ;
349
+
338
350
let rustflags = & cargo. rustflags . 0 ;
339
351
if !rustflags. is_empty ( ) {
340
352
cargo. command . env ( "RUSTFLAGS" , rustflags) ;
@@ -353,6 +365,7 @@ impl From<Cargo> for BootstrapCommand {
353
365
if !cargo. allow_features . is_empty ( ) {
354
366
cargo. command . env ( "RUSTC_ALLOW_FEATURES" , cargo. allow_features ) ;
355
367
}
368
+
356
369
cargo. command
357
370
}
358
371
}
@@ -422,13 +435,6 @@ impl Builder<'_> {
422
435
assert_eq ! ( target, compiler. host) ;
423
436
}
424
437
425
- if self . config . rust_optimize . is_release ( ) &&
426
- // cargo bench/install do not accept `--release` and miri doesn't want it
427
- !matches ! ( cmd_kind, Kind :: Bench | Kind :: Install | Kind :: Miri | Kind :: MiriSetup | Kind :: MiriTest )
428
- {
429
- cargo. arg ( "--release" ) ;
430
- }
431
-
432
438
// Remove make-related flags to ensure Cargo can correctly set things up
433
439
cargo. env_remove ( "MAKEFLAGS" ) ;
434
440
cargo. env_remove ( "MFLAGS" ) ;
@@ -1214,14 +1220,20 @@ impl Builder<'_> {
1214
1220
rustflags. arg ( "-Zmir_strip_debuginfo=locals-in-tiny-functions" ) ;
1215
1221
}
1216
1222
1223
+ let release_build = self . config . rust_optimize . is_release ( ) &&
1224
+ // cargo bench/install do not accept `--release` and miri doesn't want it
1225
+ !matches ! ( cmd_kind, Kind :: Bench | Kind :: Install | Kind :: Miri | Kind :: MiriSetup | Kind :: MiriTest ) ;
1226
+
1217
1227
Cargo {
1218
1228
command : cargo,
1229
+ args : vec ! [ ] ,
1219
1230
compiler,
1220
1231
target,
1221
1232
rustflags,
1222
1233
rustdocflags,
1223
1234
hostflags,
1224
1235
allow_features,
1236
+ release_build,
1225
1237
}
1226
1238
}
1227
1239
}
0 commit comments