1
Fork 0

bootstrap: print{,ln}! -> eprint{,ln}!

This commit is contained in:
clubby789 2024-12-03 20:21:19 +00:00 committed by 许杰友 Jieyou Xu (Joe)
parent 1b3fb31675
commit 15d7331a01
21 changed files with 154 additions and 150 deletions

View file

@ -48,9 +48,9 @@ fn main() {
err => {
drop(err);
if let Ok(pid) = pid {
println!("WARNING: build directory locked by process {pid}, waiting for lock");
eprintln!("WARNING: build directory locked by process {pid}, waiting for lock");
} else {
println!("WARNING: build directory locked, waiting for lock");
eprintln!("WARNING: build directory locked, waiting for lock");
}
let mut lock = t!(build_lock.write());
t!(lock.write(process::id().to_string().as_ref()));
@ -70,13 +70,13 @@ fn main() {
// changelog warning, not the `x.py setup` message.
let suggest_setup = config.config.is_none() && !matches!(config.cmd, Subcommand::Setup { .. });
if suggest_setup {
println!("WARNING: you have not made a `config.toml`");
println!(
eprintln!("WARNING: you have not made a `config.toml`");
eprintln!(
"HELP: consider running `./x.py setup` or copying `config.example.toml` by running \
`cp config.example.toml config.toml`"
);
} else if let Some(suggestion) = &changelog_suggestion {
println!("{suggestion}");
eprintln!("{suggestion}");
}
let pre_commit = config.src.join(".git").join("hooks").join("pre-commit");
@ -86,13 +86,13 @@ fn main() {
Build::new(config).build();
if suggest_setup {
println!("WARNING: you have not made a `config.toml`");
println!(
eprintln!("WARNING: you have not made a `config.toml`");
eprintln!(
"HELP: consider running `./x.py setup` or copying `config.example.toml` by running \
`cp config.example.toml config.toml`"
);
} else if let Some(suggestion) = &changelog_suggestion {
println!("{suggestion}");
eprintln!("{suggestion}");
}
// Give a warning if the pre-commit script is in pre-commit and not pre-push.
@ -102,14 +102,14 @@ fn main() {
if fs::read_to_string(pre_commit).is_ok_and(|contents| {
contents.contains("https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570")
}) {
println!(
eprintln!(
"WARNING: You have the pre-push script installed to .git/hooks/pre-commit. \
Consider moving it to .git/hooks/pre-push instead, which runs less often."
);
}
if suggest_setup || changelog_suggestion.is_some() {
println!("NOTE: this message was printed twice to make it more likely to be seen");
eprintln!("NOTE: this message was printed twice to make it more likely to be seen");
}
if dump_bootstrap_shims {

View file

@ -306,7 +306,7 @@ fn main() {
// should run on success, after this block.
}
if verbose > 0 {
println!("\nDid not run successfully: {status}\n{cmd:?}\n-------------");
eprintln!("\nDid not run successfully: {status}\n{cmd:?}\n-------------");
}
if let Some(mut on_fail) = on_fail {

View file

@ -287,7 +287,7 @@ impl Step for CodegenBackend {
fn run(self, builder: &Builder<'_>) {
// FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved
if builder.build.config.vendor && self.backend == "gcc" {
println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
eprintln!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
return;
}

View file

@ -1611,7 +1611,7 @@ impl Step for Sysroot {
let sysroot = sysroot_dir(compiler.stage);
builder
.verbose(|| println!("Removing sysroot {} to avoid caching bugs", sysroot.display()));
.verbose(|| eprintln!("Removing sysroot {} to avoid caching bugs", sysroot.display()));
let _ = fs::remove_dir_all(&sysroot);
t!(fs::create_dir_all(&sysroot));
@ -1681,7 +1681,7 @@ impl Step for Sysroot {
return true;
}
if !filtered_files.iter().all(|f| f != path.file_name().unwrap()) {
builder.verbose_than(1, || println!("ignoring {}", path.display()));
builder.verbose_than(1, || eprintln!("ignoring {}", path.display()));
false
} else {
true
@ -2240,7 +2240,7 @@ pub fn stream_cargo(
cargo.arg(arg);
}
builder.verbose(|| println!("running: {cargo:?}"));
builder.verbose(|| eprintln!("running: {cargo:?}"));
if builder.config.dry_run() {
return true;
@ -2261,12 +2261,12 @@ pub fn stream_cargo(
Ok(msg) => {
if builder.config.json_output {
// Forward JSON to stdout.
println!("{line}");
eprintln!("{line}");
}
cb(msg)
}
// If this was informational, just print it out and continue
Err(_) => println!("{line}"),
Err(_) => eprintln!("{line}"),
}
}

View file

@ -2080,7 +2080,7 @@ fn maybe_install_llvm(
{
let mut cmd = command(llvm_config);
cmd.arg("--libfiles");
builder.verbose(|| println!("running {cmd:?}"));
builder.verbose(|| eprintln!("running {cmd:?}"));
let files = cmd.run_capture_stdout(builder).stdout();
let build_llvm_out = &builder.llvm_out(builder.config.build);
let target_llvm_out = &builder.llvm_out(target);

View file

@ -107,10 +107,10 @@ fn print_paths(verb: &str, adjective: Option<&str>, paths: &[String]) {
if let Some(adjective) = adjective { format!("{adjective} ") } else { String::new() };
if len <= 10 {
for path in paths {
println!("fmt: {verb} {adjective}file {path}");
eprintln!("fmt: {verb} {adjective}file {path}");
}
} else {
println!("fmt: {verb} {len} {adjective}files");
eprintln!("fmt: {verb} {len} {adjective}files");
}
}
@ -199,7 +199,7 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
match get_modified_rs_files(build) {
Ok(Some(files)) => {
if files.is_empty() {
println!("fmt info: No modified files detected for formatting.");
eprintln!("fmt info: No modified files detected for formatting.");
return;
}

View file

@ -134,7 +134,7 @@ impl Step for Profile {
t!(fs::remove_file(path));
}
_ => {
println!("Exiting.");
eprintln!("Exiting.");
crate::exit!(1);
}
}
@ -184,15 +184,15 @@ pub fn setup(config: &Config, profile: Profile) {
Profile::Dist => &["dist", "build"],
};
println!();
eprintln!();
println!("To get started, try one of the following commands:");
eprintln!("To get started, try one of the following commands:");
for cmd in suggestions {
println!("- `x.py {cmd}`");
eprintln!("- `x.py {cmd}`");
}
if profile != Profile::Dist {
println!(
eprintln!(
"For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html"
);
}
@ -224,7 +224,7 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) {
t!(fs::write(path, settings));
let include_path = profile.include_path(&config.src);
println!("`x.py` will now use the configuration at {}", include_path.display());
eprintln!("`x.py` will now use the configuration at {}", include_path.display());
}
/// Creates a toolchain link for stage1 using `rustup`
@ -256,7 +256,7 @@ impl Step for Link {
}
if !rustup_installed(builder) {
println!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking.");
eprintln!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking.");
return;
}
@ -296,7 +296,7 @@ fn attempt_toolchain_link(builder: &Builder<'_>, stage_path: &str) {
}
if try_link_toolchain(builder, stage_path) {
println!(
eprintln!(
"Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain"
);
} else {
@ -321,14 +321,14 @@ fn toolchain_is_linked(builder: &Builder<'_>) -> bool {
return false;
}
// The toolchain has already been linked.
println!(
eprintln!(
"`stage1` toolchain already linked; not attempting to link `stage1` toolchain"
);
}
None => {
// In this case, we don't know if the `stage1` toolchain has been linked;
// but `rustup` failed, so let's not go any further.
println!(
eprintln!(
"`rustup` failed to list current toolchains; not attempting to link `stage1` toolchain"
);
}
@ -389,12 +389,12 @@ pub fn interactive_path() -> io::Result<Profile> {
input.parse()
}
println!("Welcome to the Rust project! What do you want to do with x.py?");
eprintln!("Welcome to the Rust project! What do you want to do with x.py?");
for ((letter, _), profile) in abbrev_all() {
println!("{}) {}: {}", letter, profile, profile.purpose());
eprintln!("{}) {}: {}", letter, profile, profile.purpose());
}
let template = loop {
print!(
eprint!(
"Please choose one ({}): ",
abbrev_all().map(|((l, _), _)| l).collect::<Vec<_>>().join("/")
);
@ -428,7 +428,7 @@ enum PromptResult {
fn prompt_user(prompt: &str) -> io::Result<Option<PromptResult>> {
let mut input = String::new();
loop {
print!("{prompt} ");
eprint!("{prompt} ");
io::stdout().flush()?;
input.clear();
io::stdin().read_line(&mut input)?;
@ -490,7 +490,7 @@ fn install_git_hook_maybe(builder: &Builder<'_>, config: &Config) -> io::Result<
return Ok(());
}
println!(
eprintln!(
"\nRust's CI will automatically fail if it doesn't pass `tidy`, the internal tool for ensuring code quality.
If you'd like, x.py can install a git hook for you that will automatically run `test tidy` before
pushing your code to ensure your code is up to par. If you decide later that this behavior is
@ -498,7 +498,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
);
if prompt_user("Would you like to install the git hook?: [y/N]")? != Some(PromptResult::Yes) {
println!("Ok, skipping installation!");
eprintln!("Ok, skipping installation!");
return Ok(());
}
if !hooks_dir.exists() {
@ -515,7 +515,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
);
return Err(e);
}
Ok(_) => println!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"),
Ok(_) => eprintln!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"),
};
Ok(())
}
@ -541,7 +541,7 @@ Select which editor you would like to set up [default: None]: ";
let mut input = String::new();
loop {
print!("{}", prompt_str);
eprint!("{}", prompt_str);
io::stdout().flush()?;
input.clear();
io::stdin().read_line(&mut input)?;
@ -656,7 +656,7 @@ impl Step for Editor {
if let Some(editor_kind) = editor_kind {
while !t!(create_editor_settings_maybe(config, editor_kind.clone())) {}
} else {
println!("Ok, skipping editor setup!");
eprintln!("Ok, skipping editor setup!");
}
}
Err(e) => eprintln!("Could not determine the editor: {e}"),
@ -689,7 +689,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
mismatched_settings = Some(false);
}
}
println!(
eprintln!(
"\nx.py can automatically install the recommended `{settings_filename}` file for rustc development"
);
@ -708,7 +708,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
Some(PromptResult::Yes) => true,
Some(PromptResult::Print) => false,
_ => {
println!("Ok, skipping settings!");
eprintln!("Ok, skipping settings!");
return Ok(true);
}
};
@ -735,9 +735,9 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
_ => "Created",
};
fs::write(&settings_path, editor.settings_template())?;
println!("{verb} `{}`", settings_filename);
eprintln!("{verb} `{}`", settings_filename);
} else {
println!("\n{}", editor.settings_template());
eprintln!("\n{}", editor.settings_template());
}
Ok(should_create)
}

View file

@ -66,6 +66,6 @@ pub fn suggest(builder: &Builder<'_>, run: bool) {
build.build();
}
} else {
println!("HELP: consider using the `--run` flag to automatically run suggested tests");
eprintln!("HELP: consider using the `--run` flag to automatically run suggested tests");
}
}

View file

@ -471,11 +471,11 @@ impl Miri {
// We re-use the `cargo` from above.
cargo.arg("--print-sysroot");
builder.verbose(|| println!("running: {cargo:?}"));
builder.verbose(|| eprintln!("running: {cargo:?}"));
let stdout = cargo.run_capture_stdout(builder).stdout();
// Output is "<sysroot>\n".
let sysroot = stdout.trim_end();
builder.verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
builder.verbose(|| eprintln!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
PathBuf::from(sysroot)
}
}
@ -2488,7 +2488,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
}
}
builder.verbose(|| println!("doc tests for: {}", markdown.display()));
builder.verbose(|| eprintln!("doc tests for: {}", markdown.display()));
let mut cmd = builder.rustdoc_cmd(compiler);
builder.add_rust_test_threads(&mut cmd);
// allow for unstable options such as new editions

View file

@ -523,7 +523,7 @@ impl Builder<'_> {
let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8");
if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) {
println!("using sysroot {sysroot_str}");
eprintln!("using sysroot {sysroot_str}");
}
let mut rustflags = Rustflags::new(target);

View file

@ -392,14 +392,14 @@ impl StepDescription {
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) {
if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
println!("Skipping {pathset:?} because it is excluded");
eprintln!("Skipping {pathset:?} because it is excluded");
}
return true;
}
if !builder.config.skip.is_empty() && !matches!(builder.config.dry_run, DryRun::SelfCheck) {
builder.verbose(|| {
println!(
eprintln!(
"{:?} not skipped for {:?} -- not in {:?}",
pathset, self.name, builder.config.skip
)
@ -1437,11 +1437,11 @@ impl<'a> Builder<'a> {
panic!("{}", out);
}
if let Some(out) = self.cache.get(&step) {
self.verbose_than(1, || println!("{}c {:?}", " ".repeat(stack.len()), step));
self.verbose_than(1, || eprintln!("{}c {:?}", " ".repeat(stack.len()), step));
return out;
}
self.verbose_than(1, || println!("{}> {:?}", " ".repeat(stack.len()), step));
self.verbose_than(1, || eprintln!("{}> {:?}", " ".repeat(stack.len()), step));
stack.push(Box::new(step.clone()));
}
@ -1462,7 +1462,7 @@ impl<'a> Builder<'a> {
let step_string = format!("{step:?}");
let brace_index = step_string.find('{').unwrap_or(0);
let type_string = type_name::<S>();
println!(
eprintln!(
"[TIMING] {} {} -- {}.{:03}",
&type_string.strip_prefix("bootstrap::").unwrap_or(type_string),
&step_string[brace_index..],
@ -1479,7 +1479,9 @@ impl<'a> Builder<'a> {
let cur_step = stack.pop().expect("step stack empty");
assert_eq!(cur_step.downcast_ref(), Some(&step));
}
self.verbose_than(1, || println!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step));
self.verbose_than(1, || {
eprintln!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)
});
self.cache.put(step, out.clone());
out
}

View file

@ -1293,7 +1293,7 @@ impl Config {
.map(|change_id| change_id.inner.map(crate::find_recent_config_change_ids))
{
if !changes.is_empty() {
println!(
eprintln!(
"WARNING: There have been changes to x.py since you last updated:\n{}",
crate::human_readable_changes(&changes)
);
@ -1559,7 +1559,7 @@ impl Config {
}
if cargo_clippy.is_some() && rustc.is_none() {
println!(
eprintln!(
"WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict."
);
}
@ -1841,7 +1841,7 @@ impl Config {
// FIXME: Remove this option at the end of 2024.
if parallel_compiler.is_some() {
println!(
eprintln!(
"WARNING: The `rust.parallel-compiler` option is deprecated and does nothing. The parallel compiler (with one thread) is now the default"
);
}
@ -1873,7 +1873,7 @@ impl Config {
if available_backends.contains(&backend) {
panic!("Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'.");
} else {
println!("HELP: '{s}' for 'rust.codegen-backends' might fail. \
eprintln!("HELP: '{s}' for 'rust.codegen-backends' might fail. \
Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \
In this case, it would be referred to as '{backend}'.");
}
@ -1902,7 +1902,7 @@ impl Config {
// tests may fail due to using a different channel than the one used by the compiler during tests.
if let Some(commit) = &config.download_rustc_commit {
if is_user_configured_rust_channel {
println!(
eprintln!(
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
);
@ -1992,10 +1992,10 @@ impl Config {
if config.llvm_from_ci {
let warn = |option: &str| {
println!(
eprintln!(
"WARNING: `{option}` will only be used on `compiler/rustc_llvm` build, not for the LLVM build."
);
println!(
eprintln!(
"HELP: To use `{option}` for LLVM builds, set `download-ci-llvm` option to false."
);
};
@ -2014,12 +2014,12 @@ impl Config {
// if they've chosen a different value.
if libzstd.is_some() {
println!(
eprintln!(
"WARNING: when using `download-ci-llvm`, the local `llvm.libzstd` option, \
like almost all `llvm.*` options, will be ignored and set by the LLVM CI \
artifacts builder config."
);
println!(
eprintln!(
"HELP: To use `llvm.libzstd` for LLVM/LLD builds, set `download-ci-llvm` option to false."
);
}
@ -2088,7 +2088,7 @@ impl Config {
if available_backends.contains(&backend) {
panic!("Invalid value '{s}' for 'target.{triple}.codegen-backends'. Instead, please use '{backend}'.");
} else {
println!("HELP: '{s}' for 'target.{triple}.codegen-backends' might fail. \
eprintln!("HELP: '{s}' for 'target.{triple}.codegen-backends' might fail. \
Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \
In this case, it would be referred to as '{backend}'.");
}
@ -2304,7 +2304,7 @@ impl Config {
if self.dry_run() {
return Ok(());
}
self.verbose(|| println!("running: {cmd:?}"));
self.verbose(|| eprintln!("running: {cmd:?}"));
build_helper::util::try_run(cmd, self.is_verbose())
}
@ -2479,7 +2479,7 @@ impl Config {
// This happens when LLVM submodule is updated in CI, we should disable ci-rustc without an error
// to not break CI. For non-CI environments, we should return an error.
if CiEnv::is_ci() {
println!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled.");
eprintln!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled.");
return None;
} else {
panic!("ERROR: LLVM submodule has changes, `download-rustc` can't be used.");
@ -2490,8 +2490,8 @@ impl Config {
let ci_config_toml = match self.get_builder_toml("ci-rustc") {
Ok(ci_config_toml) => ci_config_toml,
Err(e) if e.to_string().contains("unknown field") => {
println!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled.");
println!("HELP: Consider rebasing to a newer commit if available.");
eprintln!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled.");
eprintln!("HELP: Consider rebasing to a newer commit if available.");
return None;
},
Err(e) => {
@ -2516,7 +2516,7 @@ impl Config {
.is_some_and(|s| s == "1" || s == "true");
if disable_ci_rustc_if_incompatible && res.is_err() {
println!("WARNING: download-rustc is disabled with `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` env.");
eprintln!("WARNING: download-rustc is disabled with `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` env.");
return None;
}
@ -2701,7 +2701,7 @@ impl Config {
return;
}
println!("Updating submodule {relative_path}");
eprintln!("Updating submodule {relative_path}");
self.check_run(
helpers::git(Some(&self.src))
.run_always()
@ -2824,7 +2824,7 @@ impl Config {
Some(StringOrBool::Bool(true)) => false,
Some(StringOrBool::String(s)) if s == "if-unchanged" => {
if !self.rust_info.is_managed_git_subrepository() {
println!(
eprintln!(
"ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources."
);
crate::exit!(1);
@ -2857,10 +2857,10 @@ impl Config {
if if_unchanged {
return None;
}
println!("ERROR: could not find commit hash for downloading rustc");
println!("HELP: maybe your repository history is too shallow?");
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
println!("HELP: or fetch enough history to include one upstream commit");
eprintln!("ERROR: could not find commit hash for downloading rustc");
eprintln!("HELP: maybe your repository history is too shallow?");
eprintln!("HELP: consider setting `rust.download-rustc=false` in config.toml");
eprintln!("HELP: or fetch enough history to include one upstream commit");
crate::exit!(1);
}
};
@ -2899,7 +2899,7 @@ impl Config {
let if_unchanged = || {
if self.rust_info.is_from_tarball() {
// Git is needed for running "if-unchanged" logic.
println!(
eprintln!(
"WARNING: 'if-unchanged' has no effect on tarball sources; ignoring `download-ci-llvm`."
);
return false;
@ -2948,10 +2948,10 @@ impl Config {
// Only commits merged by bors will have CI artifacts.
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();
if commit.is_empty() {
println!("error: could not find commit hash for downloading components from CI");
println!("help: maybe your repository history is too shallow?");
println!("help: consider disabling `{option_name}`");
println!("help: or fetch enough history to include one upstream commit");
eprintln!("error: could not find commit hash for downloading components from CI");
eprintln!("help: maybe your repository history is too shallow?");
eprintln!("help: consider disabling `{option_name}`");
eprintln!("help: or fetch enough history to include one upstream commit");
crate::exit!(1);
}
@ -2963,14 +2963,14 @@ impl Config {
if has_changes {
if if_unchanged {
if self.is_verbose() {
println!(
eprintln!(
"warning: saw changes to one of {modified_paths:?} since {commit}; \
ignoring `{option_name}`"
);
}
return None;
}
println!(
eprintln!(
"warning: `{option_name}` is enabled, but there are changes to one of {modified_paths:?}"
);
}
@ -3007,7 +3007,7 @@ pub(crate) fn check_incompatible_options_for_ci_llvm(
($current:expr, $expected:expr) => {
if let Some(current) = &$current {
if Some(current) != $expected.as_ref() {
println!(
eprintln!(
"WARNING: `llvm.{}` has no effect with `llvm.download-ci-llvm`. \
Current value: {:?}, Expected value(s): {}{:?}",
stringify!($expected).replace("_", "-"),
@ -3112,7 +3112,7 @@ fn check_incompatible_options_for_ci_rustc(
($current:expr, $expected:expr, $config_section:expr) => {
if let Some(current) = &$current {
if Some(current) != $expected.as_ref() {
println!(
eprintln!(
"WARNING: `{}` has no effect with `rust.download-rustc`. \
Current value: {:?}, Expected value(s): {}{:?}",
format!("{}.{}", $config_section, stringify!($expected).replace("_", "-")),

View file

@ -196,12 +196,12 @@ impl Flags {
if let Ok(HelpVerboseOnly { help: true, verbose: 1.., cmd: subcommand }) =
HelpVerboseOnly::try_parse_from(normalize_args(args))
{
println!("NOTE: updating submodules before printing available paths");
eprintln!("NOTE: updating submodules before printing available paths");
let config = Config::parse(Self::parse(&[String::from("build")]));
let build = Build::new(config);
let paths = Builder::get_help(&build, subcommand);
if let Some(s) = paths {
println!("{s}");
eprintln!("{s}");
} else {
panic!("No paths available for subcommand `{}`", subcommand.as_str());
}

View file

@ -77,7 +77,7 @@ impl Config {
if self.dry_run() && !cmd.run_always {
return true;
}
self.verbose(|| println!("running: {cmd:?}"));
self.verbose(|| eprintln!("running: {cmd:?}"));
check_run(cmd, self.is_verbose())
}
@ -144,7 +144,7 @@ impl Config {
/// Please see <https://nixos.org/patchelf.html> for more information
fn fix_bin_or_dylib(&self, fname: &Path) {
assert_eq!(SHOULD_FIX_BINS_AND_DYLIBS.get(), Some(&true));
println!("attempting to patch {}", fname.display());
eprintln!("attempting to patch {}", fname.display());
// Only build `.nix-deps` once.
static NIX_DEPS_DIR: OnceLock<PathBuf> = OnceLock::new();
@ -206,7 +206,7 @@ impl Config {
}
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {
self.verbose(|| println!("download {url}"));
self.verbose(|| eprintln!("download {url}"));
// Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
let tempfile = self.tempdir().join(dest_path.file_name().unwrap());
// While bootstrap itself only supports http and https downloads, downstream forks might
@ -226,7 +226,7 @@ impl Config {
}
fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
println!("downloading {url}");
eprintln!("downloading {url}");
// Try curl. If that fails and we are on windows, fallback to PowerShell.
// options should be kept in sync with
// src/bootstrap/src/core/download.rs
@ -341,7 +341,7 @@ impl Config {
short_path = short_path.strip_prefix(pattern).unwrap_or(short_path);
let dst_path = dst.join(short_path);
self.verbose(|| {
println!("extracting {} to {}", original_path.display(), dst.display())
eprintln!("extracting {} to {}", original_path.display(), dst.display())
});
if !t!(member.unpack_in(dst)) {
panic!("path traversal attack ??");
@ -365,7 +365,7 @@ impl Config {
pub(crate) fn verify(&self, path: &Path, expected: &str) -> bool {
use sha2::Digest;
self.verbose(|| println!("verifying {}", path.display()));
self.verbose(|| eprintln!("verifying {}", path.display()));
if self.dry_run() {
return false;
@ -391,7 +391,7 @@ impl Config {
let verified = checksum == expected;
if !verified {
println!(
eprintln!(
"invalid checksum: \n\
found: {checksum}\n\
expected: {expected}",
@ -421,7 +421,7 @@ enum DownloadSource {
/// Functions that are only ever called once, but named for clarify and to avoid thousand-line functions.
impl Config {
pub(crate) fn download_clippy(&self) -> PathBuf {
self.verbose(|| println!("downloading stage0 clippy artifacts"));
self.verbose(|| eprintln!("downloading stage0 clippy artifacts"));
let date = &self.stage0_metadata.compiler.date;
let version = &self.stage0_metadata.compiler.version;
@ -518,7 +518,7 @@ impl Config {
}
pub(crate) fn download_ci_rustc(&self, commit: &str) {
self.verbose(|| println!("using downloaded stage2 artifacts from CI (commit {commit})"));
self.verbose(|| eprintln!("using downloaded stage2 artifacts from CI (commit {commit})"));
let version = self.artifact_version_part(commit);
// download-rustc doesn't need its own cargo, it can just use beta's. But it does need the
@ -539,7 +539,7 @@ impl Config {
#[cfg(not(feature = "bootstrap-self-test"))]
pub(crate) fn download_beta_toolchain(&self) {
self.verbose(|| println!("downloading stage0 beta artifacts"));
self.verbose(|| eprintln!("downloading stage0 beta artifacts"));
let date = &self.stage0_metadata.compiler.date;
let version = &self.stage0_metadata.compiler.version;
@ -677,7 +677,7 @@ impl Config {
return;
} else {
self.verbose(|| {
println!(
eprintln!(
"ignoring cached file {} due to failed verification",
tarball.display()
)
@ -776,10 +776,10 @@ download-rustc = false
t!(check_incompatible_options_for_ci_llvm(current_config_toml, ci_config_toml));
}
Err(e) if e.to_string().contains("unknown field") => {
println!(
eprintln!(
"WARNING: CI LLVM has some fields that are no longer supported in bootstrap; download-ci-llvm will be disabled."
);
println!("HELP: Consider rebasing to a newer commit if available.");
eprintln!("HELP: Consider rebasing to a newer commit if available.");
}
Err(e) => {
eprintln!("ERROR: Failed to parse CI LLVM config.toml: {e}");

View file

@ -237,11 +237,11 @@ than building it.
stage0_supported_target_list.intersection(&missing_targets_hashset).collect();
if !duplicated_targets.is_empty() {
println!(
eprintln!(
"Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list."
);
for duplicated_target in duplicated_targets {
println!(" {duplicated_target}");
eprintln!(" {duplicated_target}");
}
std::process::exit(1);
}

View file

@ -406,11 +406,11 @@ impl Build {
.unwrap()
.trim();
if local_release.split('.').take(2).eq(version.split('.').take(2)) {
build.verbose(|| println!("auto-detected local-rebuild {local_release}"));
build.verbose(|| eprintln!("auto-detected local-rebuild {local_release}"));
build.local_rebuild = true;
}
build.verbose(|| println!("finding compilers"));
build.verbose(|| eprintln!("finding compilers"));
utils::cc_detect::find(&build);
// When running `setup`, the profile is about to change, so any requirements we have now may
// be different on the next invocation. Don't check for them until the next time x.py is
@ -418,7 +418,7 @@ impl Build {
//
// Similarly, for `setup` we don't actually need submodules or cargo metadata.
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
build.verbose(|| println!("running sanity check"));
build.verbose(|| eprintln!("running sanity check"));
crate::core::sanity::check(&mut build);
// Make sure we update these before gathering metadata so we don't get an error about missing
@ -436,7 +436,7 @@ impl Build {
// Now, update all existing submodules.
build.update_existing_submodules();
build.verbose(|| println!("learning about cargo"));
build.verbose(|| eprintln!("learning about cargo"));
crate::core::metadata::build(&mut build);
}
@ -605,7 +605,7 @@ impl Build {
let stamp = dir.join(".stamp");
let mut cleared = false;
if mtime(&stamp) < mtime(input) {
self.verbose(|| println!("Dirty - {}", dir.display()));
self.verbose(|| eprintln!("Dirty - {}", dir.display()));
let _ = fs::remove_dir_all(dir);
cleared = true;
} else if stamp.exists() {
@ -890,7 +890,7 @@ impl Build {
let executed_at = std::panic::Location::caller();
self.verbose(|| {
println!("running: {command:?} (created at {created_at}, executed at {executed_at})")
eprintln!("running: {command:?} (created at {created_at}, executed at {executed_at})")
});
let cmd = command.as_command_mut();
@ -947,7 +947,7 @@ Executed at: {executed_at}"#,
let fail = |message: &str, output: CommandOutput| -> ! {
if self.is_verbose() {
println!("{message}");
eprintln!("{message}");
} else {
let (stdout, stderr) = (output.stdout_if_present(), output.stderr_if_present());
// If the command captures output, the user would not see any indication that
@ -957,16 +957,16 @@ Executed at: {executed_at}"#,
if let Some(stdout) =
output.stdout_if_present().take_if(|s| !s.trim().is_empty())
{
println!("STDOUT:\n{stdout}\n");
eprintln!("STDOUT:\n{stdout}\n");
}
if let Some(stderr) =
output.stderr_if_present().take_if(|s| !s.trim().is_empty())
{
println!("STDERR:\n{stderr}\n");
eprintln!("STDERR:\n{stderr}\n");
}
println!("Command {command:?} has failed. Rerun with -v to see more details.");
eprintln!("Command {command:?} has failed. Rerun with -v to see more details.");
} else {
println!("Command has failed. Rerun with -v to see more details.");
eprintln!("Command has failed. Rerun with -v to see more details.");
}
}
exit!(1);
@ -1011,7 +1011,7 @@ Executed at: {executed_at}"#,
match self.config.dry_run {
DryRun::SelfCheck => (),
DryRun::Disabled | DryRun::UserSelected => {
println!("{msg}");
eprintln!("{msg}");
}
}
}
@ -1666,7 +1666,7 @@ Executed at: {executed_at}"#,
if self.config.dry_run() {
return;
}
self.verbose_than(1, || println!("Copy/Link {src:?} to {dst:?}"));
self.verbose_than(1, || eprintln!("Copy/Link {src:?} to {dst:?}"));
if src == dst {
return;
}
@ -1775,7 +1775,7 @@ Executed at: {executed_at}"#,
return;
}
let dst = dstdir.join(src.file_name().unwrap());
self.verbose_than(1, || println!("Install {src:?} to {dst:?}"));
self.verbose_than(1, || eprintln!("Install {src:?} to {dst:?}"));
t!(fs::create_dir_all(dstdir));
if !src.exists() {
panic!("ERROR: File \"{}\" not found!", src.display());

View file

@ -155,15 +155,15 @@ pub fn find_target(build: &Build, target: TargetSelection) {
build.cxx.borrow_mut().insert(target, compiler);
}
build.verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target)));
build.verbose(|| println!("CFLAGS_{} = {cflags:?}", target.triple));
build.verbose(|| eprintln!("CC_{} = {:?}", target.triple, build.cc(target)));
build.verbose(|| eprintln!("CFLAGS_{} = {cflags:?}", target.triple));
if let Ok(cxx) = build.cxx(target) {
let cxxflags = build.cflags(target, GitRepo::Rustc, CLang::Cxx);
build.verbose(|| println!("CXX_{} = {cxx:?}", target.triple));
build.verbose(|| println!("CXXFLAGS_{} = {cxxflags:?}", target.triple));
build.verbose(|| eprintln!("CXX_{} = {cxx:?}", target.triple));
build.verbose(|| eprintln!("CXXFLAGS_{} = {cxxflags:?}", target.triple));
}
if let Some(ar) = ar {
build.verbose(|| println!("AR_{} = {ar:?}", target.triple));
build.verbose(|| eprintln!("AR_{} = {ar:?}", target.triple));
build.ar.borrow_mut().insert(target, ar);
}

View file

@ -135,7 +135,7 @@ impl Drop for TimeIt {
fn drop(&mut self) {
let time = self.1.elapsed();
if !self.0 {
println!("\tfinished in {}.{:03} seconds", time.as_secs(), time.subsec_millis());
eprintln!("\tfinished in {}.{:03} seconds", time.as_secs(), time.subsec_millis());
}
}
}
@ -267,12 +267,12 @@ pub fn check_run(cmd: &mut BootstrapCommand, print_cmd_on_fail: bool) -> bool {
let status = match cmd.as_command_mut().status() {
Ok(status) => status,
Err(e) => {
println!("failed to execute command: {cmd:?}\nERROR: {e}");
eprintln!("failed to execute command: {cmd:?}\nERROR: {e}");
return false;
}
};
if !status.success() && print_cmd_on_fail {
println!(
eprintln!(
"\n\ncommand did not execute successfully: {cmd:?}\n\
expected success, got: {status}\n\n"
);

View file

@ -185,7 +185,7 @@ impl BuildMetrics {
if version.format_version == CURRENT_FORMAT_VERSION {
t!(serde_json::from_slice::<JsonRoot>(&contents)).invocations
} else {
println!(
eprintln!(
"WARNING: overriding existing build/metrics.json, as it's not \
compatible with build metrics format version {CURRENT_FORMAT_VERSION}."
);

View file

@ -56,7 +56,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) ->
let cmd = cmd.as_command_mut();
cmd.stdout(Stdio::piped());
builder.verbose(|| println!("running: {cmd:?}"));
builder.verbose(|| eprintln!("running: {cmd:?}"));
let mut process = cmd.spawn().unwrap();
@ -71,7 +71,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) ->
let result = process.wait_with_output().unwrap();
if !result.status.success() && builder.is_verbose() {
println!(
eprintln!(
"\n\ncommand did not execute successfully: {cmd:?}\n\
expected success, got: {}",
result.status
@ -135,7 +135,9 @@ impl<'a> Renderer<'a> {
if self.up_to_date_tests > 0 {
let n = self.up_to_date_tests;
let s = if n > 1 { "s" } else { "" };
println!("help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n");
eprintln!(
"help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n"
);
}
}
@ -185,12 +187,12 @@ impl<'a> Renderer<'a> {
}
fn render_test_outcome_verbose(&self, outcome: Outcome<'_>, test: &TestOutcome) {
print!("test {} ... ", test.name);
self.builder.colored_stdout(|stdout| outcome.write_long(stdout)).unwrap();
eprint!("test {} ... ", test.name);
self.builder.colored_stderr(|stdout| outcome.write_long(stdout)).unwrap();
if let Some(exec_time) = test.exec_time {
print!(" ({exec_time:.2?})");
eprint!(" ({exec_time:.2?})");
}
println!();
eprintln!();
}
fn render_test_outcome_terse(&mut self, outcome: Outcome<'_>, test: &TestOutcome) {
@ -198,45 +200,45 @@ impl<'a> Renderer<'a> {
if let Some(total) = self.tests_count {
let total = total.to_string();
let executed = format!("{:>width$}", self.executed_tests - 1, width = total.len());
print!(" {executed}/{total}");
eprint!(" {executed}/{total}");
}
println!();
eprintln!();
self.terse_tests_in_line = 0;
}
self.terse_tests_in_line += 1;
self.builder.colored_stdout(|stdout| outcome.write_short(stdout, &test.name)).unwrap();
self.builder.colored_stderr(|stdout| outcome.write_short(stdout, &test.name)).unwrap();
let _ = std::io::stdout().flush();
}
fn render_suite_outcome(&self, outcome: Outcome<'_>, suite: &SuiteOutcome) {
// The terse output doesn't end with a newline, so we need to add it ourselves.
if !self.builder.config.verbose_tests {
println!();
eprintln!();
}
if !self.failures.is_empty() {
println!("\nfailures:\n");
eprintln!("\nfailures:\n");
for failure in &self.failures {
if failure.stdout.is_some() || failure.message.is_some() {
println!("---- {} stdout ----", failure.name);
eprintln!("---- {} stdout ----", failure.name);
if let Some(stdout) = &failure.stdout {
println!("{stdout}");
eprintln!("{stdout}");
}
if let Some(message) = &failure.message {
println!("NOTE: {message}");
eprintln!("NOTE: {message}");
}
}
}
println!("\nfailures:");
eprintln!("\nfailures:");
for failure in &self.failures {
println!(" {}", failure.name);
eprintln!(" {}", failure.name);
}
}
if !self.benches.is_empty() {
println!("\nbenchmarks:");
eprintln!("\nbenchmarks:");
let mut rows = Vec::new();
for bench in &self.benches {
@ -251,13 +253,13 @@ impl<'a> Renderer<'a> {
let max_1 = rows.iter().map(|r| r.1.len()).max().unwrap_or(0);
let max_2 = rows.iter().map(|r| r.2.len()).max().unwrap_or(0);
for row in &rows {
println!(" {:<max_0$} {:>max_1$} {:>max_2$}", row.0, row.1, row.2);
eprintln!(" {:<max_0$} {:>max_1$} {:>max_2$}", row.0, row.1, row.2);
}
}
print!("\ntest result: ");
self.builder.colored_stdout(|stdout| outcome.write_long(stdout)).unwrap();
println!(
eprint!("\ntest result: ");
self.builder.colored_stderr(|stdout| outcome.write_long(stdout)).unwrap();
eprintln!(
". {} passed; {} failed; {} ignored; {} measured; {} filtered out{time}\n",
suite.passed,
suite.failed,
@ -274,7 +276,7 @@ impl<'a> Renderer<'a> {
fn render_message(&mut self, message: Message) {
match message {
Message::Suite(SuiteMessage::Started { test_count }) => {
println!("\nrunning {test_count} tests");
eprintln!("\nrunning {test_count} tests");
self.executed_tests = 0;
self.terse_tests_in_line = 0;
self.tests_count = Some(test_count);
@ -314,7 +316,7 @@ impl<'a> Renderer<'a> {
self.failures.push(outcome);
}
Message::Test(TestMessage::Timeout { name }) => {
println!("test {name} has been running for a long time");
eprintln!("test {name} has been running for a long time");
}
Message::Test(TestMessage::Started) => {} // Not useful
}

View file

@ -344,7 +344,7 @@ impl<'a> Tarball<'a> {
// For `x install` tarball files aren't needed, so we can speed up the process by not producing them.
let compression_profile = if self.builder.kind == Kind::Install {
self.builder.verbose(|| {
println!("Forcing dist.compression-profile = 'no-op' for `x install`.")
eprintln!("Forcing dist.compression-profile = 'no-op' for `x install`.")
});
// "no-op" indicates that the rust-installer won't produce compressed tarball sources.
"no-op"