about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-02-21 23:24:59 +0000
committerbors <bors@rust-lang.org>2023-02-21 23:24:59 +0000
commit375d5ace705f8494af06b545291d64486fbada06 (patch)
tree8e6ceef6a8e5e1d8466a2db7c38e622094d5d443
parent246eae2fab54a5139365c4e1a08c5724fb385fbf (diff)
parent6ca499bf2b3da83d60062da649805c36c03ce194 (diff)
downloadrust-375d5ace705f8494af06b545291d64486fbada06.tar.gz
rust-375d5ace705f8494af06b545291d64486fbada06.zip
Auto merge of #108302 - Kobzol:revert-107834, r=albertlarsan68
Revert #107834

This reverts commit [41c6c5d4996728b5a635319ef9b077a3d0ccc480](https://github.com/rust-lang/rust/pull/107834). Trying to check if this fixes building `rustc` for perf bot.
-rw-r--r--src/bootstrap/compile.rs66
-rw-r--r--src/bootstrap/download.rs19
-rw-r--r--src/bootstrap/lib.rs11
-rw-r--r--src/bootstrap/native.rs2
4 files changed, 12 insertions, 86 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index f0fcdf0d5a0..348d22a9ce6 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -459,72 +459,6 @@ impl Step for StdLink {
         let libdir = builder.sysroot_libdir(target_compiler, target);
         let hostdir = builder.sysroot_libdir(target_compiler, compiler.host);
         add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
-
-        if compiler.stage == 0 {
-            // special handling for stage0, to make `rustup toolchain link` and `x dist --stage 0`
-            // work for stage0-sysroot
-            let sysroot = builder.out.join(&compiler.host.triple).join("stage0-sysroot");
-
-            let host_lib_dir = builder.initial_rustc.ancestors().nth(2).unwrap().join("lib");
-            let host_bin_dir = builder.out.join(&builder.initial_rustc.parent().unwrap());
-            let host_codegen_backends =
-                host_lib_dir.join("rustlib").join(&compiler.host.triple).join("codegen-backends");
-            let sysroot_bin_dir = sysroot.join("bin");
-            let sysroot_lib_dir = sysroot.join("lib");
-            let sysroot_codegen_backends = builder.sysroot_codegen_backends(compiler);
-
-            // Create the `bin` directory in stage0-sysroot
-            t!(fs::create_dir_all(&sysroot_bin_dir));
-
-            // copy bin files from `builder.initial_rustc/./` to `stage0-sysroot/bin`
-            if let Ok(files) = fs::read_dir(&host_bin_dir) {
-                for file in files {
-                    let file = t!(file);
-                    if file.file_name() == "rustfmt" {
-                        // This is when `rustc` and `cargo` are set in `config.toml`
-                        if !file.path().starts_with(&builder.out) {
-                            builder.copy(
-                                &file.path().into_boxed_path(),
-                                &sysroot_bin_dir.join(file.file_name()),
-                            );
-                        } else {
-                            builder.copy(
-                                &builder
-                                    .out
-                                    .join(&compiler.host.triple)
-                                    .join("rustfmt/bin/rustfmt"),
-                                &sysroot_bin_dir.join(file.file_name()),
-                            );
-                        }
-                    } else {
-                        builder.copy(
-                            &file.path().into_boxed_path(),
-                            &sysroot_bin_dir.join(file.file_name()),
-                        );
-                    }
-                }
-            }
-
-            // copy dylib files from `builder.initial_rustc/../lib/*` while excluding the `rustlib` directory to `stage0-sysroot/lib`
-            if let Ok(files) = fs::read_dir(&host_lib_dir) {
-                for file in files {
-                    let file = t!(file);
-                    let path = file.path();
-                    if path.is_file()
-                        && is_dylib(&file.file_name().into_string().unwrap())
-                        && !path.starts_with(sysroot_lib_dir.join("rustlib").into_boxed_path())
-                    {
-                        builder.copy(&path, &sysroot_lib_dir.join(path.file_name().unwrap()));
-                    }
-                }
-            }
-
-            t!(fs::create_dir_all(&sysroot_codegen_backends));
-            // copy `codegen-backends` from `host_lib_dir/rustlib/codegen_backends` to `stage0-sysroot/lib/rustlib/host-triple/codegen-backends` if it exists.
-            if host_codegen_backends.exists() {
-                builder.cp_r(&host_codegen_backends, &sysroot_codegen_backends);
-            }
-        }
     }
 }
 
diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs
index d6592d2d771..d1e2149d3f9 100644
--- a/src/bootstrap/download.rs
+++ b/src/bootstrap/download.rs
@@ -2,7 +2,7 @@ use std::{
     env,
     ffi::{OsStr, OsString},
     fs::{self, File},
-    io::{self, BufRead, BufReader, ErrorKind},
+    io::{BufRead, BufReader, ErrorKind},
     path::{Path, PathBuf},
     process::{Command, Stdio},
 };
@@ -26,14 +26,6 @@ impl Config {
         self.verbose > 0
     }
 
-    pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {
-        #[cfg(unix)]
-        use std::os::unix::fs::symlink as symlink_file;
-        #[cfg(windows)]
-        use std::os::windows::fs::symlink_file;
-        if !self.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
-    }
-
     pub(crate) fn create(&self, path: &Path, s: &str) {
         if self.dry_run() {
             return;
@@ -338,15 +330,6 @@ impl Config {
         let bin_root = self.out.join(host.triple).join("rustfmt");
         let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host));
         let rustfmt_stamp = bin_root.join(".rustfmt-stamp");
-
-        #[cfg(not(windows))]
-        {
-            let legacy_rustfmt = self.initial_rustc.with_file_name(exe("rustfmt", host));
-            if !legacy_rustfmt.exists() {
-                t!(self.symlink_file(&rustfmt_path, &legacy_rustfmt));
-            }
-        }
-
         if rustfmt_path.exists() && !program_out_of_date(&rustfmt_stamp, &channel) {
             return Some(rustfmt_path);
         }
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index f753720b353..f4abdf1cc57 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -20,6 +20,7 @@ use std::cell::{Cell, RefCell};
 use std::collections::{HashMap, HashSet};
 use std::env;
 use std::fs::{self, File};
+use std::io;
 use std::io::ErrorKind;
 use std::path::{Path, PathBuf};
 use std::process::{Command, Stdio};
@@ -1406,7 +1407,7 @@ impl Build {
                 src = t!(fs::canonicalize(src));
             } else {
                 let link = t!(fs::read_link(src));
-                t!(self.config.symlink_file(link, dst));
+                t!(self.symlink_file(link, dst));
                 return;
             }
         }
@@ -1524,6 +1525,14 @@ impl Build {
         iter.map(|e| t!(e)).collect::<Vec<_>>().into_iter()
     }
 
+    fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {
+        #[cfg(unix)]
+        use std::os::unix::fs::symlink as symlink_file;
+        #[cfg(windows)]
+        use std::os::windows::fs::symlink_file;
+        if !self.config.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
+    }
+
     /// Returns if config.ninja is enabled, and checks for ninja existence,
     /// exiting with a nicer error message if not.
     fn ninja(&self) -> bool {
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index d6e63fb937e..21157b02a78 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -516,7 +516,7 @@ impl Step for Llvm {
 
             let lib_llvm = out_dir.join("build").join("lib").join(lib_name);
             if !lib_llvm.exists() {
-                t!(builder.build.config.symlink_file("libLLVM.dylib", &lib_llvm));
+                t!(builder.symlink_file("libLLVM.dylib", &lib_llvm));
             }
         }