Skip to content

Commit 6e6a4b1

Browse files
committed
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?
2 parents 21b5367 + 2b09d7c commit 6e6a4b1

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

src/librustc/session/config.rs

+9-21
Original file line numberDiff line numberDiff line change
@@ -2020,27 +2020,15 @@ pub fn build_session_options_and_crate_config(
20202020
}
20212021
OptLevel::Default
20222022
} else {
2023-
match (
2024-
cg.opt_level.as_ref().map(String::as_ref),
2025-
nightly_options::is_nightly_build(),
2026-
) {
2027-
(None, _) => OptLevel::No,
2028-
(Some("0"), _) => OptLevel::No,
2029-
(Some("1"), _) => OptLevel::Less,
2030-
(Some("2"), _) => OptLevel::Default,
2031-
(Some("3"), _) => OptLevel::Aggressive,
2032-
(Some("s"), true) => OptLevel::Size,
2033-
(Some("z"), true) => OptLevel::SizeMin,
2034-
(Some("s"), false) | (Some("z"), false) => {
2035-
early_error(
2036-
error_format,
2037-
&format!(
2038-
"the optimizations s or z are only \
2039-
accepted on the nightly compiler"
2040-
),
2041-
);
2042-
}
2043-
(Some(arg), _) => {
2023+
match cg.opt_level.as_ref().map(String::as_ref) {
2024+
None => OptLevel::No,
2025+
Some("0") => OptLevel::No,
2026+
Some("1") => OptLevel::Less,
2027+
Some("2") => OptLevel::Default,
2028+
Some("3") => OptLevel::Aggressive,
2029+
Some("s") => OptLevel::Size,
2030+
Some("z") => OptLevel::SizeMin,
2031+
Some(arg) => {
20442032
early_error(
20452033
error_format,
20462034
&format!(

0 commit comments

Comments
 (0)