]> git.lizzy.rs Git - rust.git/commitdiff
Fix custom relative libdir.
authorO01eg <o01eg@yandex.ru>
Sun, 31 Mar 2019 19:28:12 +0000 (22:28 +0300)
committerO01eg <o01eg@yandex.ru>
Sun, 31 Mar 2019 19:28:12 +0000 (22:28 +0300)
Uses relative libdir to place libraries on all stages.
Adds verbose installation output.

src/bootstrap/builder.rs
src/bootstrap/compile.rs
src/bootstrap/dist.rs
src/bootstrap/lib.rs

index 8d3c8fc435c8dd20c77cfd7e12169375ca2a0a29..522466314d66045306e65b71763a6f4ea1e88669 100644 (file)
@@ -634,7 +634,28 @@ pub fn rustc_libdir(&self, compiler: Compiler) -> PathBuf {
         if compiler.is_snapshot(self) {
             self.rustc_snapshot_libdir()
         } else {
-            self.sysroot(compiler).join(libdir(&compiler.host))
+            match self.config.libdir_relative() {
+                Some(relative_libdir) if compiler.stage >= 1
+                    => self.sysroot(compiler).join(relative_libdir),
+                _ => self.sysroot(compiler).join(libdir(&compiler.host))
+            }
+        }
+    }
+
+    /// Returns the compiler's relative libdir where it stores the dynamic libraries that
+    /// it itself links against.
+    ///
+    /// For example this returns `lib` on Unix and `bin` on
+    /// Windows.
+    pub fn libdir_relative(&self, compiler: Compiler) -> &Path {
+        if compiler.is_snapshot(self) {
+            libdir(&self.config.build).as_ref()
+        } else {
+            match self.config.libdir_relative() {
+                Some(relative_libdir) if compiler.stage >= 1
+                    => relative_libdir,
+                _ => libdir(&compiler.host).as_ref()
+            }
         }
     }
 
index 237f5c0ea2f158ca99aac32ab274d4fdaaeeaa27..08316b71ea85b36b2e807102dfc96a8b92e8e9aa 100644 (file)
@@ -20,7 +20,7 @@
 use serde_json;
 
 use crate::dist;
-use crate::util::{exe, libdir, is_dylib};
+use crate::util::{exe, is_dylib};
 use crate::{Compiler, Mode, GitRepo};
 use crate::native;
 
@@ -1005,13 +1005,13 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
 
         // Link in all dylibs to the libdir
         let sysroot = builder.sysroot(target_compiler);
-        let sysroot_libdir = sysroot.join(libdir(&*host));
-        t!(fs::create_dir_all(&sysroot_libdir));
+        let rustc_libdir = builder.rustc_libdir(target_compiler);
+        t!(fs::create_dir_all(&rustc_libdir));
         let src_libdir = builder.sysroot_libdir(build_compiler, host);
         for f in builder.read_dir(&src_libdir) {
             let filename = f.file_name().into_string().unwrap();
             if is_dylib(&filename) {
-                builder.copy(&f.path(), &sysroot_libdir.join(&filename));
+                builder.copy(&f.path(), &rustc_libdir.join(&filename));
             }
         }
 
index d982330a6164019701cf1e75159af8b4eaae449e..a4d924d64ee78487156f20b6d79328b01b3cac2c 100644 (file)
@@ -18,7 +18,7 @@
 
 use crate::{Compiler, Mode, LLVM_TOOLS};
 use crate::channel;
-use crate::util::{libdir, is_dylib, exe};
+use crate::util::{is_dylib, exe};
 use crate::builder::{Builder, RunConfig, ShouldRun, Step};
 use crate::compile;
 use crate::tool::{self, Tool};
@@ -473,7 +473,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
         fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
             let host = compiler.host;
             let src = builder.sysroot(compiler);
-            let libdir = libdir(&host);
+            let libdir = builder.rustc_libdir(compiler);
 
             // Copy rustc/rustdoc binaries
             t!(fs::create_dir_all(image.join("bin")));
@@ -481,13 +481,15 @@ fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
 
             builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);
 
+            let libdir_relative = builder.libdir_relative(compiler);
+
             // Copy runtime DLLs needed by the compiler
-            if libdir != "bin" {
-                for entry in builder.read_dir(&src.join(libdir)) {
+            if libdir_relative.to_str() != Some("bin") {
+                for entry in builder.read_dir(&libdir) {
                     let name = entry.file_name();
                     if let Some(s) = name.to_str() {
                         if is_dylib(s) {
-                            builder.install(&entry.path(), &image.join(libdir), 0o644);
+                            builder.install(&entry.path(), &image.join(&libdir_relative), 0o644);
                         }
                     }
                 }
@@ -516,7 +518,8 @@ fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
                     .join("bin")
                     .join(&exe);
                 // for the rationale about this rename check `compile::copy_lld_to_sysroot`
-                let dst = image.join("lib/rustlib")
+                let dst = image.join(libdir_relative)
+                    .join("rustlib")
                     .join(&*host)
                     .join("bin")
                     .join(&exe);
index 2394ae7fb79139292a312c7dbc4d8997d02ecb7b..47ac04baf6d6d73563a854aab14b278eda6d5a73 100644 (file)
@@ -1275,6 +1275,7 @@ fn copy_to_folder(&self, src: &Path, dest_folder: &Path) {
     fn install(&self, src: &Path, dstdir: &Path, perms: u32) {
         if self.config.dry_run { return; }
         let dst = dstdir.join(src.file_name().unwrap());
+        self.verbose_than(1, &format!("Install {:?} to {:?}", src, dst));
         t!(fs::create_dir_all(dstdir));
         drop(fs::remove_file(&dst));
         {