Auto merge of #50265 - japaric:sz, r=alexcrichton
stabilize opt-level={s,z} closes #35784 closes #47651 ### Rationale Since the lastest LLVM upgrade rustc / LLVM does more agressive loop unrolling. This results in increased binary size of embedded / no_std programs: a hundreds of bytes increase, or about a 7x increase, in the case of the smallest Cortex-M binary cf. #49260. As we are shooting for embedded Rust on stable it would be great to also provide a way to optimize for size (which is pretty important for embedded applications that target resource constrained devices) on stable. Also this has been baking in nightly for a long time. r? @alexcrichton which team has to sign off this?
This commit is contained in:
commit
6e6a4b1957
|
@ -2020,27 +2020,15 @@ pub fn build_session_options_and_crate_config(
|
|||
}
|
||||
OptLevel::Default
|
||||
} else {
|
||||
match (
|
||||
cg.opt_level.as_ref().map(String::as_ref),
|
||||
nightly_options::is_nightly_build(),
|
||||
) {
|
||||
(None, _) => OptLevel::No,
|
||||
(Some("0"), _) => OptLevel::No,
|
||||
(Some("1"), _) => OptLevel::Less,
|
||||
(Some("2"), _) => OptLevel::Default,
|
||||
(Some("3"), _) => OptLevel::Aggressive,
|
||||
(Some("s"), true) => OptLevel::Size,
|
||||
(Some("z"), true) => OptLevel::SizeMin,
|
||||
(Some("s"), false) | (Some("z"), false) => {
|
||||
early_error(
|
||||
error_format,
|
||||
&format!(
|
||||
"the optimizations s or z are only \
|
||||
accepted on the nightly compiler"
|
||||
),
|
||||
);
|
||||
}
|
||||
(Some(arg), _) => {
|
||||
match cg.opt_level.as_ref().map(String::as_ref) {
|
||||
None => OptLevel::No,
|
||||
Some("0") => OptLevel::No,
|
||||
Some("1") => OptLevel::Less,
|
||||
Some("2") => OptLevel::Default,
|
||||
Some("3") => OptLevel::Aggressive,
|
||||
Some("s") => OptLevel::Size,
|
||||
Some("z") => OptLevel::SizeMin,
|
||||
Some(arg) => {
|
||||
early_error(
|
||||
error_format,
|
||||
&format!(
|
||||
|
|
Loading…
Reference in a new issue