const DEFAULT: bool = false;
- /// Run this rule for all hosts without cross compiling.
+ /// If true, then this rule should be skipped if --target was specified, but --host was not
const ONLY_HOSTS: bool = false;
/// Primary function to execute this rule. Can call `builder.ensure()`
// Determine the targets participating in this rule.
let targets = if self.only_hosts {
- if !builder.config.run_host_only {
+ if builder.config.skip_only_host_steps {
return; // don't run anything
} else {
&builder.hosts
pub enum Kind {
Build,
Check,
+ Clippy,
+ Fix,
Test,
Bench,
Dist,
tool::Miri,
native::Lld
),
- Kind::Check => describe!(
+ Kind::Check | Kind::Clippy | Kind::Fix => describe!(
check::Std,
check::Test,
check::Rustc,
let (kind, paths) = match build.config.cmd {
Subcommand::Build { ref paths } => (Kind::Build, &paths[..]),
Subcommand::Check { ref paths } => (Kind::Check, &paths[..]),
+ Subcommand::Clippy { ref paths } => (Kind::Clippy, &paths[..]),
+ Subcommand::Fix { ref paths } => (Kind::Fix, &paths[..]),
Subcommand::Doc { ref paths } => (Kind::Doc, &paths[..]),
Subcommand::Test { ref paths, .. } => (Kind::Test, &paths[..]),
Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]),
})
}
+ /// Similar to `compiler`, except handles the full-bootstrap option to
+ /// silently use the stage1 compiler instead of a stage2 compiler if one is
+ /// requested.
+ ///
+ /// Note that this does *not* have the side effect of creating
+ /// `compiler(stage, host)`, unlike `compiler` above which does have such
+ /// a side effect. The returned compiler here can only be used to compile
+ /// new artifacts, it can't be used to rely on the presence of a particular
+ /// sysroot.
+ ///
+ /// See `force_use_stage1` for documentation on what each argument is.
+ pub fn compiler_for(
+ &self,
+ stage: u32,
+ host: Interned<String>,
+ target: Interned<String>,
+ ) -> Compiler {
+ if self.build.force_use_stage1(Compiler { stage, host }, target) {
+ self.compiler(1, self.config.build)
+ } else {
+ self.compiler(stage, host)
+ }
+ }
+
pub fn sysroot(&self, compiler: Compiler) -> Interned<PathBuf> {
self.ensure(compile::Sysroot { compiler })
}
// This is for the original compiler, but if we're forced to use stage 1, then
// std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since
// we copy the libs forward.
- let cmp = if self.force_use_stage1(compiler, target) {
- self.compiler(1, compiler.host)
- } else {
- compiler
- };
+ let cmp = self.compiler_for(compiler.stage, compiler.host, target);
let libstd_stamp = match cmd {
- "check" => check::libstd_stamp(self, cmp, target),
+ "check" | "clippy" | "fix" => check::libstd_stamp(self, cmp, target),
_ => compile::libstd_stamp(self, cmp, target),
};
let libtest_stamp = match cmd {
- "check" => check::libtest_stamp(self, cmp, target),
+ "check" | "clippy" | "fix" => check::libtest_stamp(self, cmp, target),
_ => compile::libstd_stamp(self, cmp, target),
};
let librustc_stamp = match cmd {
- "check" => check::librustc_stamp(self, cmp, target),
+ "check" | "clippy" | "fix" => check::librustc_stamp(self, cmp, target),
_ => compile::librustc_stamp(self, cmp, target),
};
assert_eq!(target, compiler.host);
}
- // Set a flag for `check` so that certain build scripts can do less work
- // (e.g., not building/requiring LLVM).
- if cmd == "check" {
+ // Set a flag for `check`/`clippy`/`fix`, so that certain build
+ // scripts can do less work (e.g. not building/requiring LLVM).
+ if cmd == "check" || cmd == "clippy" || cmd == "fix" {
cargo.env("RUST_CHECK", "1");
}
extra_args.push_str(&s);
}
+ if cmd == "clippy" {
+ extra_args.push_str("-Zforce-unstable-if-unmarked -Zunstable-options \
+ --json-rendered=termcolor");
+ }
+
if !extra_args.is_empty() {
cargo.env(
"RUSTFLAGS",
if let Some(ref error_format) = self.config.rustc_error_format {
cargo.env("RUSTC_ERROR_FORMAT", error_format);
}
- if cmd != "build" && cmd != "check" && cmd != "rustc" && want_rustdoc {
+ if !(["build", "check", "clippy", "fix", "rustc"].contains(&cmd)) && want_rustdoc {
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler));
}
let mut config = Config::default_opts();
// don't save toolstates
config.save_toolstates = None;
- config.run_host_only = true;
+ config.skip_only_host_steps = false;
config.dry_run = true;
// try to avoid spurious failures in dist where we create/delete each others file
let dir = config.out.join("tmp-rustbuild-tests").join(
assert_eq!(
first(builder.cache.all::<dist::Docs>()),
- &[dist::Docs { stage: 2, host: a },]
+ &[dist::Docs { host: a },]
);
assert_eq!(
first(builder.cache.all::<dist::Mingw>()),
assert_eq!(
first(builder.cache.all::<dist::Std>()),
&[dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: a,
},]
);
assert_eq!(
first(builder.cache.all::<dist::Docs>()),
&[
- dist::Docs { stage: 2, host: a },
- dist::Docs { stage: 2, host: b },
+ dist::Docs { host: a },
+ dist::Docs { host: b },
]
);
assert_eq!(
first(builder.cache.all::<dist::Std>()),
&[
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: a,
},
dist::Std {
assert_eq!(
first(builder.cache.all::<dist::Docs>()),
&[
- dist::Docs { stage: 2, host: a },
- dist::Docs { stage: 2, host: b },
+ dist::Docs { host: a },
+ dist::Docs { host: b },
]
);
assert_eq!(
first(builder.cache.all::<dist::Std>()),
&[
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: a,
},
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: b,
},
]
assert_eq!(first(builder.cache.all::<dist::Src>()), &[dist::Src]);
}
+ #[test]
+ fn dist_only_cross_host() {
+ let a = INTERNER.intern_str("A");
+ let b = INTERNER.intern_str("B");
+ let mut build = Build::new(configure(&["B"], &[]));
+ build.config.docs = false;
+ build.config.extended = true;
+ build.hosts = vec![b];
+ let mut builder = Builder::new(&build);
+ builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
+
+ assert_eq!(
+ first(builder.cache.all::<dist::Rustc>()),
+ &[
+ dist::Rustc {
+ compiler: Compiler { host: b, stage: 2 }
+ },
+ ]
+ );
+ assert_eq!(
+ first(builder.cache.all::<compile::Rustc>()),
+ &[
+ compile::Rustc {
+ compiler: Compiler { host: a, stage: 0 },
+ target: a,
+ },
+ compile::Rustc {
+ compiler: Compiler { host: a, stage: 1 },
+ target: b,
+ },
+ ]
+ );
+ }
+
#[test]
fn dist_with_targets_and_hosts() {
let build = Build::new(configure(&["B"], &["C"]));
assert_eq!(
first(builder.cache.all::<dist::Docs>()),
&[
- dist::Docs { stage: 2, host: a },
- dist::Docs { stage: 2, host: b },
- dist::Docs { stage: 2, host: c },
+ dist::Docs { host: a },
+ dist::Docs { host: b },
+ dist::Docs { host: c },
]
);
assert_eq!(
first(builder.cache.all::<dist::Std>()),
&[
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: a,
},
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: b,
},
dist::Std {
#[test]
fn dist_with_target_flag() {
let mut config = configure(&["B"], &["C"]);
- config.run_host_only = false; // as-if --target=C was passed
+ config.skip_only_host_steps = true; // as-if --target=C was passed
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
assert_eq!(
first(builder.cache.all::<dist::Docs>()),
&[
- dist::Docs { stage: 2, host: a },
- dist::Docs { stage: 2, host: b },
- dist::Docs { stage: 2, host: c },
+ dist::Docs { host: a },
+ dist::Docs { host: b },
+ dist::Docs { host: c },
]
);
assert_eq!(
first(builder.cache.all::<dist::Std>()),
&[
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: a,
},
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: b,
},
dist::Std {
assert_eq!(
first(builder.cache.all::<dist::Docs>()),
&[
- dist::Docs { stage: 2, host: a },
- dist::Docs { stage: 2, host: b },
+ dist::Docs { host: a },
+ dist::Docs { host: b },
]
);
assert_eq!(
first(builder.cache.all::<dist::Std>()),
&[
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: a,
},
dist::Std {
- compiler: Compiler { host: a, stage: 2 },
+ compiler: Compiler { host: a, stage: 1 },
target: b,
},
]
compiler: Compiler { host: a, stage: 1 },
target: b,
},
- compile::Test {
- compiler: Compiler { host: a, stage: 2 },
- target: b,
- },
]
);
assert_eq!(
compiler: Compiler { host: b, stage: 2 },
target: a,
},
- compile::Rustc {
- compiler: Compiler { host: a, stage: 0 },
- target: b,
- },
compile::Rustc {
compiler: Compiler { host: a, stage: 1 },
target: b,
compiler: Compiler { host: b, stage: 2 },
target: a,
},
- compile::Test {
- compiler: Compiler { host: a, stage: 0 },
- target: b,
- },
compile::Test {
compiler: Compiler { host: a, stage: 1 },
target: b,
#[test]
fn build_with_target_flag() {
let mut config = configure(&["B"], &["C"]);
- config.run_host_only = false;
+ config.skip_only_host_steps = true;
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
compile::Assemble {
target_compiler: Compiler { host: a, stage: 1 },
},
- compile::Assemble {
- target_compiler: Compiler { host: b, stage: 1 },
- },
compile::Assemble {
target_compiler: Compiler { host: a, stage: 2 },
},
compiler: Compiler { host: a, stage: 1 },
target: a,
},
- compile::Rustc {
- compiler: Compiler { host: a, stage: 0 },
- target: b,
- },
compile::Rustc {
compiler: Compiler { host: a, stage: 1 },
target: b,
compiler: Compiler { host: b, stage: 2 },
target: a,
},
- compile::Test {
- compiler: Compiler { host: a, stage: 0 },
- target: b,
- },
compile::Test {
compiler: Compiler { host: a, stage: 1 },
target: b,