Skip to content

Commit

Permalink
Revert "Rollup merge of #134040 - clubby789:bootstrap-eprintln, r=jie…
Browse files Browse the repository at this point in the history
…youxu"

This reverts commit b282774, reversing
changes made to e0f3db0.
  • Loading branch information
jieyouxu committed Dec 12, 2024
1 parent 50fac07 commit 3c3512c
Show file tree
Hide file tree
Showing 32 changed files with 207 additions and 211 deletions.
20 changes: 10 additions & 10 deletions src/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ fn main() {
err => {
drop(err);
if let Ok(pid) = pid {
eprintln!("WARNING: build directory locked by process {pid}, waiting for lock");
println!("WARNING: build directory locked by process {pid}, waiting for lock");
} else {
eprintln!("WARNING: build directory locked, waiting for lock");
println!("WARNING: build directory locked, waiting for lock");
}
let mut lock = t!(build_lock.write());
t!(lock.write(process::id().to_string().as_ref()));
Expand All @@ -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 {
eprintln!("WARNING: you have not made a `config.toml`");
eprintln!(
println!("WARNING: you have not made a `config.toml`");
println!(
"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 {
eprintln!("{suggestion}");
println!("{suggestion}");
}

let pre_commit = config.src.join(".git").join("hooks").join("pre-commit");
Expand All @@ -86,13 +86,13 @@ fn main() {
Build::new(config).build();

if suggest_setup {
eprintln!("WARNING: you have not made a `config.toml`");
eprintln!(
println!("WARNING: you have not made a `config.toml`");
println!(
"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 {
eprintln!("{suggestion}");
println!("{suggestion}");
}

// Give a warning if the pre-commit script is in pre-commit and not pre-push.
Expand All @@ -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")
}) {
eprintln!(
println!(
"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() {
eprintln!("NOTE: this message was printed twice to make it more likely to be seen");
println!("NOTE: this message was printed twice to make it more likely to be seen");
}

if dump_bootstrap_shims {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ fn main() {
// should run on success, after this block.
}
if verbose > 0 {
eprintln!("\nDid not run successfully: {status}\n{cmd:?}\n-------------");
println!("\nDid not run successfully: {status}\n{cmd:?}\n-------------");
}

if let Some(mut on_fail) = on_fail {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
eprintln!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
return;
}

Expand Down
10 changes: 5 additions & 5 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ impl Step for Sysroot {
let sysroot = sysroot_dir(compiler.stage);

builder
.verbose(|| eprintln!("Removing sysroot {} to avoid caching bugs", sysroot.display()));
.verbose(|| println!("Removing sysroot {} to avoid caching bugs", sysroot.display()));
let _ = fs::remove_dir_all(&sysroot);
t!(fs::create_dir_all(&sysroot));

Expand Down Expand Up @@ -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, || eprintln!("ignoring {}", path.display()));
builder.verbose_than(1, || println!("ignoring {}", path.display()));
false
} else {
true
Expand Down Expand Up @@ -2240,7 +2240,7 @@ pub fn stream_cargo(
cargo.arg(arg);
}

builder.verbose(|| eprintln!("running: {cargo:?}"));
builder.verbose(|| println!("running: {cargo:?}"));

if builder.config.dry_run() {
return true;
Expand All @@ -2261,12 +2261,12 @@ pub fn stream_cargo(
Ok(msg) => {
if builder.config.json_output {
// Forward JSON to stdout.
eprintln!("{line}");
println!("{line}");
}
cb(msg)
}
// If this was informational, just print it out and continue
Err(_) => eprintln!("{line}"),
Err(_) => println!("{line}"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ fn maybe_install_llvm(
{
let mut cmd = command(llvm_config);
cmd.arg("--libfiles");
builder.verbose(|| eprintln!("running {cmd:?}"));
builder.verbose(|| println!("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);
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/src/core/build_steps/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
eprintln!("fmt: {verb} {adjective}file {path}");
println!("fmt: {verb} {adjective}file {path}");
}
} else {
eprintln!("fmt: {verb} {len} {adjective}files");
println!("fmt: {verb} {len} {adjective}files");
}
}

Expand Down Expand Up @@ -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() {
eprintln!("fmt info: No modified files detected for formatting.");
println!("fmt info: No modified files detected for formatting.");
return;
}

Expand Down
46 changes: 23 additions & 23 deletions src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Step for Profile {
t!(fs::remove_file(path));
}
_ => {
eprintln!("Exiting.");
println!("Exiting.");
crate::exit!(1);
}
}
Expand Down Expand Up @@ -184,15 +184,15 @@ pub fn setup(config: &Config, profile: Profile) {
Profile::Dist => &["dist", "build"],
};

eprintln!();
println!();

eprintln!("To get started, try one of the following commands:");
println!("To get started, try one of the following commands:");
for cmd in suggestions {
eprintln!("- `x.py {cmd}`");
println!("- `x.py {cmd}`");
}

if profile != Profile::Dist {
eprintln!(
println!(
"For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html"
);
}
Expand Down Expand Up @@ -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);
eprintln!("`x.py` will now use the configuration at {}", include_path.display());
println!("`x.py` will now use the configuration at {}", include_path.display());
}

/// Creates a toolchain link for stage1 using `rustup`
Expand Down Expand Up @@ -256,7 +256,7 @@ impl Step for Link {
}

if !rustup_installed(builder) {
eprintln!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking.");
println!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking.");
return;
}

Expand Down Expand Up @@ -296,7 +296,7 @@ fn attempt_toolchain_link(builder: &Builder<'_>, stage_path: &str) {
}

if try_link_toolchain(builder, stage_path) {
eprintln!(
println!(
"Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain"
);
} else {
Expand All @@ -321,14 +321,14 @@ fn toolchain_is_linked(builder: &Builder<'_>) -> bool {
return false;
}
// The toolchain has already been linked.
eprintln!(
println!(
"`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.
eprintln!(
println!(
"`rustup` failed to list current toolchains; not attempting to link `stage1` toolchain"
);
}
Expand Down Expand Up @@ -389,12 +389,12 @@ pub fn interactive_path() -> io::Result<Profile> {
input.parse()
}

eprintln!("Welcome to the Rust project! What do you want to do with x.py?");
println!("Welcome to the Rust project! What do you want to do with x.py?");
for ((letter, _), profile) in abbrev_all() {
eprintln!("{}) {}: {}", letter, profile, profile.purpose());
println!("{}) {}: {}", letter, profile, profile.purpose());
}
let template = loop {
eprint!(
print!(
"Please choose one ({}): ",
abbrev_all().map(|((l, _), _)| l).collect::<Vec<_>>().join("/")
);
Expand Down Expand Up @@ -428,7 +428,7 @@ enum PromptResult {
fn prompt_user(prompt: &str) -> io::Result<Option<PromptResult>> {
let mut input = String::new();
loop {
eprint!("{prompt} ");
print!("{prompt} ");
io::stdout().flush()?;
input.clear();
io::stdin().read_line(&mut input)?;
Expand Down Expand Up @@ -490,15 +490,15 @@ fn install_git_hook_maybe(builder: &Builder<'_>, config: &Config) -> io::Result<
return Ok(());
}

eprintln!(
println!(
"\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
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) {
eprintln!("Ok, skipping installation!");
println!("Ok, skipping installation!");
return Ok(());
}
if !hooks_dir.exists() {
Expand All @@ -515,7 +515,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
);
return Err(e);
}
Ok(_) => eprintln!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"),
Ok(_) => println!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"),
};
Ok(())
}
Expand All @@ -541,7 +541,7 @@ Select which editor you would like to set up [default: None]: ";

let mut input = String::new();
loop {
eprint!("{}", prompt_str);
print!("{}", prompt_str);
io::stdout().flush()?;
input.clear();
io::stdin().read_line(&mut input)?;
Expand Down Expand Up @@ -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 {
eprintln!("Ok, skipping editor setup!");
println!("Ok, skipping editor setup!");
}
}
Err(e) => eprintln!("Could not determine the editor: {e}"),
Expand Down Expand Up @@ -689,7 +689,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
mismatched_settings = Some(false);
}
}
eprintln!(
println!(
"\nx.py can automatically install the recommended `{settings_filename}` file for rustc development"
);

Expand All @@ -708,7 +708,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
Some(PromptResult::Yes) => true,
Some(PromptResult::Print) => false,
_ => {
eprintln!("Ok, skipping settings!");
println!("Ok, skipping settings!");
return Ok(true);
}
};
Expand All @@ -735,9 +735,9 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
_ => "Created",
};
fs::write(&settings_path, editor.settings_template())?;
eprintln!("{verb} `{}`", settings_filename);
println!("{verb} `{}`", settings_filename);
} else {
eprintln!("\n{}", editor.settings_template());
println!("\n{}", editor.settings_template());
}
Ok(should_create)
}
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ pub fn suggest(builder: &Builder<'_>, run: bool) {
build.build();
}
} else {
eprintln!("HELP: consider using the `--run` flag to automatically run suggested tests");
println!("HELP: consider using the `--run` flag to automatically run suggested tests");
}
}
6 changes: 3 additions & 3 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,11 @@ impl Miri {
// We re-use the `cargo` from above.
cargo.arg("--print-sysroot");

builder.verbose(|| eprintln!("running: {cargo:?}"));
builder.verbose(|| println!("running: {cargo:?}"));
let stdout = cargo.run_capture_stdout(builder).stdout();
// Output is "<sysroot>\n".
let sysroot = stdout.trim_end();
builder.verbose(|| eprintln!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
builder.verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
PathBuf::from(sysroot)
}
}
Expand Down Expand Up @@ -2488,7 +2488,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
}
}

builder.verbose(|| eprintln!("doc tests for: {}", markdown.display()));
builder.verbose(|| println!("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
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
eprintln!("using sysroot {sysroot_str}");
println!("using sysroot {sysroot_str}");
}

let mut rustflags = Rustflags::new(target);
Expand Down
Loading

0 comments on commit 3c3512c

Please sign in to comment.