Skip to content

Commit

Permalink
Place optimize for size and minsize rustc invocation options behind a…
Browse files Browse the repository at this point in the history
… nightly

compiler check to prevent their inclusion in the stable / beta compilers.
  • Loading branch information
brandonedens committed Apr 29, 2016
1 parent 8a8493a commit 49d2825
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/librustc/session/config.rs
Expand Up @@ -1127,17 +1127,18 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}
OptLevel::Default
} else {
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) => {
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(arg), _) => {
early_error(error_format, &format!("optimization level needs to be \
between 0-3, s, or z (instead was `{}`)",
between 0-3 (instead was `{}`)",
arg));
}
}
Expand Down Expand Up @@ -1308,7 +1309,7 @@ pub mod nightly_options {
is_nightly_build() && matches.opt_strs("Z").iter().any(|x| *x == "unstable-options")
}

fn is_nightly_build() -> bool {
pub fn is_nightly_build() -> bool {
match get_unstable_features_setting() {
UnstableFeatures::Allow | UnstableFeatures::Cheat => true,
_ => false,
Expand Down

0 comments on commit 49d2825

Please sign in to comment.