Skip to content

Commit

Permalink
Auto merge of #73964 - jyn514:sane-defaults, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Improve defaults in x.py

- Make the default stage dependent on the subcommand
- Don't build stage1 rustc artifacts with x.py build --stage 1. If this is what you want, use x.py build --stage 2 instead, which gives you a working libstd.
- Change default debuginfo when debug = true from 2 to 1

I tried to fix CI to use `--stage 2` everywhere it currently has no stage, but I might have missed a spot.
This does not update much of the documentation - most of it is in https://github.com/rust-lang/rustc-dev-guide/ or https://github.com/rust-lang/rust-forge and will need a separate PR.

See individual commits for a detailed rationale of each change.
See also the MCP: rust-lang/compiler-team#326

r? @Mark-Simulacrum , but anyone is free to give an opinion.
  • Loading branch information
bors committed Jul 28, 2020
2 parents 2c28244 + da40cf8 commit 7b3a781
Show file tree
Hide file tree
Showing 31 changed files with 660 additions and 536 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ jobs:
os: windows-latest-xl
- name: x86_64-msvc-cargo
env:
SCRIPT: python x.py test src/tools/cargotest src/tools/cargo
SCRIPT: python x.py --stage 2 test src/tools/cargotest src/tools/cargo
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-lld"
VCVARS_BAT: vcvars64.bat
NO_DEBUG_ASSERTIONS: 1
Expand Down Expand Up @@ -598,7 +598,7 @@ jobs:
os: macos-latest
- name: x86_64-apple
env:
SCRIPT: "./x.py test"
SCRIPT: "./x.py --stage 2 test"
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc"
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
MACOSX_DEPLOYMENT_TARGET: 10.8
Expand Down
5 changes: 4 additions & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@
# Debuginfo for tests run with compiletest is not controlled by this option
# and needs to be enabled separately with `debuginfo-level-tests`.
#
# Defaults to 2 if debug is true
# Note that debuginfo-level = 2 generates several gigabytes of debuginfo
# and will slow down the linking process significantly.
#
# Defaults to 1 if debug is true
#debuginfo-level = 0

# Debuginfo level for the compiler.
Expand Down
60 changes: 41 additions & 19 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl StepDescription {
}

if !attempted_run {
panic!("Error: no rules matched {}.", path.display());
panic!("error: no rules matched {}", path.display());
}
}
}
Expand Down Expand Up @@ -501,16 +501,7 @@ impl<'a> Builder<'a> {
_ => return None,
};

let builder = Builder {
build,
top_stage: build.config.stage.unwrap_or(2),
kind,
cache: Cache::new(),
stack: RefCell::new(Vec::new()),
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
paths: vec![],
};

let builder = Self::new_internal(build, kind, vec![]);
let builder = &builder;
let mut should_run = ShouldRun::new(builder);
for desc in Builder::get_step_descriptions(builder.kind) {
Expand All @@ -535,6 +526,32 @@ impl<'a> Builder<'a> {
Some(help)
}

fn new_internal(build: &Build, kind: Kind, paths: Vec<PathBuf>) -> Builder<'_> {
let top_stage = if let Some(explicit_stage) = build.config.stage {
explicit_stage
} else {
// See https://github.com/rust-lang/compiler-team/issues/326
match kind {
Kind::Doc => 0,
Kind::Build | Kind::Test => 1,
Kind::Bench | Kind::Dist | Kind::Install => 2,
// These are all bootstrap tools, which don't depend on the compiler.
// The stage we pass shouldn't matter, but use 0 just in case.
Kind::Check | Kind::Clippy | Kind::Fix | Kind::Run | Kind::Format => 0,
}
};

Builder {
build,
top_stage,
kind,
cache: Cache::new(),
stack: RefCell::new(Vec::new()),
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
paths,
}
}

pub fn new(build: &Build) -> Builder<'_> {
let (kind, paths) = match build.config.cmd {
Subcommand::Build { ref paths } => (Kind::Build, &paths[..]),
Expand All @@ -550,15 +567,20 @@ impl<'a> Builder<'a> {
Subcommand::Format { .. } | Subcommand::Clean { .. } => panic!(),
};

Builder {
build,
top_stage: build.config.stage.unwrap_or(2),
kind,
cache: Cache::new(),
stack: RefCell::new(Vec::new()),
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
paths: paths.to_owned(),
let this = Self::new_internal(build, kind, paths.to_owned());

// CI should always run stage 2 builds, unless it specifically states otherwise
#[cfg(not(test))]
if build.config.stage.is_none() && build.ci_env != crate::CiEnv::None {
match kind {
Kind::Test | Kind::Doc | Kind::Build | Kind::Bench | Kind::Dist | Kind::Install => {
assert_eq!(this.top_stage, 2)
}
Kind::Check | Kind::Clippy | Kind::Fix | Kind::Run | Kind::Format => {}
}
}

this
}

pub fn execute_cli(&self) {
Expand Down
Loading

0 comments on commit 7b3a781

Please sign in to comment.