Skip to content

Commit 375d5ac

Browse files
committed
Auto merge of #108302 - Kobzol:revert-107834, r=albertlarsan68
Revert #107834 This reverts commit [41c6c5d](#107834). Trying to check if this fixes building `rustc` for perf bot.
2 parents 246eae2 + 6ca499b commit 375d5ac

File tree

4 files changed

+12
-86
lines changed

4 files changed

+12
-86
lines changed

src/bootstrap/compile.rs

-66
Original file line numberDiff line numberDiff line change
@@ -459,72 +459,6 @@ impl Step for StdLink {
459459
let libdir = builder.sysroot_libdir(target_compiler, target);
460460
let hostdir = builder.sysroot_libdir(target_compiler, compiler.host);
461461
add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
462-
463-
if compiler.stage == 0 {
464-
// special handling for stage0, to make `rustup toolchain link` and `x dist --stage 0`
465-
// work for stage0-sysroot
466-
let sysroot = builder.out.join(&compiler.host.triple).join("stage0-sysroot");
467-
468-
let host_lib_dir = builder.initial_rustc.ancestors().nth(2).unwrap().join("lib");
469-
let host_bin_dir = builder.out.join(&builder.initial_rustc.parent().unwrap());
470-
let host_codegen_backends =
471-
host_lib_dir.join("rustlib").join(&compiler.host.triple).join("codegen-backends");
472-
let sysroot_bin_dir = sysroot.join("bin");
473-
let sysroot_lib_dir = sysroot.join("lib");
474-
let sysroot_codegen_backends = builder.sysroot_codegen_backends(compiler);
475-
476-
// Create the `bin` directory in stage0-sysroot
477-
t!(fs::create_dir_all(&sysroot_bin_dir));
478-
479-
// copy bin files from `builder.initial_rustc/./` to `stage0-sysroot/bin`
480-
if let Ok(files) = fs::read_dir(&host_bin_dir) {
481-
for file in files {
482-
let file = t!(file);
483-
if file.file_name() == "rustfmt" {
484-
// This is when `rustc` and `cargo` are set in `config.toml`
485-
if !file.path().starts_with(&builder.out) {
486-
builder.copy(
487-
&file.path().into_boxed_path(),
488-
&sysroot_bin_dir.join(file.file_name()),
489-
);
490-
} else {
491-
builder.copy(
492-
&builder
493-
.out
494-
.join(&compiler.host.triple)
495-
.join("rustfmt/bin/rustfmt"),
496-
&sysroot_bin_dir.join(file.file_name()),
497-
);
498-
}
499-
} else {
500-
builder.copy(
501-
&file.path().into_boxed_path(),
502-
&sysroot_bin_dir.join(file.file_name()),
503-
);
504-
}
505-
}
506-
}
507-
508-
// copy dylib files from `builder.initial_rustc/../lib/*` while excluding the `rustlib` directory to `stage0-sysroot/lib`
509-
if let Ok(files) = fs::read_dir(&host_lib_dir) {
510-
for file in files {
511-
let file = t!(file);
512-
let path = file.path();
513-
if path.is_file()
514-
&& is_dylib(&file.file_name().into_string().unwrap())
515-
&& !path.starts_with(sysroot_lib_dir.join("rustlib").into_boxed_path())
516-
{
517-
builder.copy(&path, &sysroot_lib_dir.join(path.file_name().unwrap()));
518-
}
519-
}
520-
}
521-
522-
t!(fs::create_dir_all(&sysroot_codegen_backends));
523-
// copy `codegen-backends` from `host_lib_dir/rustlib/codegen_backends` to `stage0-sysroot/lib/rustlib/host-triple/codegen-backends` if it exists.
524-
if host_codegen_backends.exists() {
525-
builder.cp_r(&host_codegen_backends, &sysroot_codegen_backends);
526-
}
527-
}
528462
}
529463
}
530464

src/bootstrap/download.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{
22
env,
33
ffi::{OsStr, OsString},
44
fs::{self, File},
5-
io::{self, BufRead, BufReader, ErrorKind},
5+
io::{BufRead, BufReader, ErrorKind},
66
path::{Path, PathBuf},
77
process::{Command, Stdio},
88
};
@@ -26,14 +26,6 @@ impl Config {
2626
self.verbose > 0
2727
}
2828

29-
pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {
30-
#[cfg(unix)]
31-
use std::os::unix::fs::symlink as symlink_file;
32-
#[cfg(windows)]
33-
use std::os::windows::fs::symlink_file;
34-
if !self.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
35-
}
36-
3729
pub(crate) fn create(&self, path: &Path, s: &str) {
3830
if self.dry_run() {
3931
return;
@@ -338,15 +330,6 @@ impl Config {
338330
let bin_root = self.out.join(host.triple).join("rustfmt");
339331
let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host));
340332
let rustfmt_stamp = bin_root.join(".rustfmt-stamp");
341-
342-
#[cfg(not(windows))]
343-
{
344-
let legacy_rustfmt = self.initial_rustc.with_file_name(exe("rustfmt", host));
345-
if !legacy_rustfmt.exists() {
346-
t!(self.symlink_file(&rustfmt_path, &legacy_rustfmt));
347-
}
348-
}
349-
350333
if rustfmt_path.exists() && !program_out_of_date(&rustfmt_stamp, &channel) {
351334
return Some(rustfmt_path);
352335
}

src/bootstrap/lib.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::cell::{Cell, RefCell};
2020
use std::collections::{HashMap, HashSet};
2121
use std::env;
2222
use std::fs::{self, File};
23+
use std::io;
2324
use std::io::ErrorKind;
2425
use std::path::{Path, PathBuf};
2526
use std::process::{Command, Stdio};
@@ -1406,7 +1407,7 @@ impl Build {
14061407
src = t!(fs::canonicalize(src));
14071408
} else {
14081409
let link = t!(fs::read_link(src));
1409-
t!(self.config.symlink_file(link, dst));
1410+
t!(self.symlink_file(link, dst));
14101411
return;
14111412
}
14121413
}
@@ -1524,6 +1525,14 @@ impl Build {
15241525
iter.map(|e| t!(e)).collect::<Vec<_>>().into_iter()
15251526
}
15261527

1528+
fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {
1529+
#[cfg(unix)]
1530+
use std::os::unix::fs::symlink as symlink_file;
1531+
#[cfg(windows)]
1532+
use std::os::windows::fs::symlink_file;
1533+
if !self.config.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
1534+
}
1535+
15271536
/// Returns if config.ninja is enabled, and checks for ninja existence,
15281537
/// exiting with a nicer error message if not.
15291538
fn ninja(&self) -> bool {

src/bootstrap/native.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl Step for Llvm {
516516

517517
let lib_llvm = out_dir.join("build").join("lib").join(lib_name);
518518
if !lib_llvm.exists() {
519-
t!(builder.build.config.symlink_file("libLLVM.dylib", &lib_llvm));
519+
t!(builder.symlink_file("libLLVM.dylib", &lib_llvm));
520520
}
521521
}
522522

0 commit comments

Comments
 (0)