Skip to content

Commit e0c54d8

Browse files
committed
add --release flag support
Signed-off-by: onur-ozkan <[email protected]>
1 parent 6365178 commit e0c54d8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ pub struct Config {
227227
pub incremental: bool,
228228
pub dry_run: DryRun,
229229
pub dump_bootstrap_shims: bool,
230+
pub enable_release_build: bool,
230231
/// Arguments appearing after `--` to be forwarded to tools,
231232
/// e.g. `--fix-broken` or test arguments.
232233
pub free_args: Vec<String>,
@@ -1355,6 +1356,7 @@ impl Config {
13551356
config.llvm_profile_generate = flags.llvm_profile_generate;
13561357
config.enable_bolt_settings = flags.enable_bolt_settings;
13571358
config.bypass_bootstrap_lock = flags.bypass_bootstrap_lock;
1359+
config.enable_release_build = flags.release || CiEnv::is_ci();
13581360

13591361
// Infer the rest of the configuration.
13601362

@@ -2182,7 +2184,14 @@ impl Config {
21822184
config.llvm_enzyme = llvm_enzyme.unwrap_or(false);
21832185
config.llvm_offload = llvm_offload.unwrap_or(false);
21842186
config.llvm_plugins = llvm_plugins.unwrap_or(false);
2185-
config.rust_optimize = optimize.unwrap_or(RustOptimize::Bool(true));
2187+
2188+
config.rust_optimize = match optimize {
2189+
Some(inner) => match inner {
2190+
RustOptimize::Bool(false) => RustOptimize::Bool(config.enable_release_build),
2191+
t => t,
2192+
},
2193+
None => RustOptimize::Bool(true),
2194+
};
21862195

21872196
// We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will
21882197
// build our internal lld and use it as the default linker, by setting the `rust.lld` config

src/bootstrap/src/core/config/flags.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ pub struct Flags {
142142
/// Unless you know exactly what you are doing, you probably don't need this.
143143
pub bypass_bootstrap_lock: bool,
144144

145+
#[arg(global = true, long)]
146+
// Build artifacts in release mode
147+
pub release: bool,
148+
145149
/// generate PGO profile with rustc build
146150
#[arg(global = true, value_hint = clap::ValueHint::FilePath, long, value_name = "PROFILE")]
147151
pub rust_profile_generate: Option<String>,

0 commit comments

Comments
 (0)