about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2017-10-26 03:02:52 +0800
committerGitHub <noreply@github.com>2017-10-26 03:02:52 +0800
commit7ccdc105cffbb594a519c3fdfc1e9d95ac6afccc (patch)
tree9ee6232fbfba586e06c6d9511319e98f15e4cf4c
parent86360b7ef5771ea7d091d50fe9735f6767acbb21 (diff)
parent3b815730a711186a3bbe105800fb2dfa5f4d8caf (diff)
downloadrust-7ccdc105cffbb594a519c3fdfc1e9d95ac6afccc.tar.gz
rust-7ccdc105cffbb594a519c3fdfc1e9d95ac6afccc.zip
Rollup merge of #45496 - kennytm:bootstrap-fix-extension-check, r=alexcrichton
rustbuild: Fix `no output generated` error for next bootstrap cargo.

Due to rust-lang/cargo#4570, a `*.dll.lib` file is uplifted when building dynamic libraries on Windows. The current bootstrap code does not understand files with multiple extensions, and will instead assume `xxxx.dll` is the file name. This caused a `no output generated` error because it tries to search for `xxxx.dll-hash.lib` inside the `deps/` folder, while it should check for `xxxx-hash.dll.lib` instead.

This PR is blocking #45285, see https://github.com/rust-lang/rust/pull/45285#issuecomment-338454149 and the rest of the comments for detail.
-rw-r--r--src/bootstrap/compile.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index a8162f0a92f..4540f620872 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -860,10 +860,18 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) {
             // have a hash in the name, but there's a version of this file in
             // the `deps` folder which *does* have a hash in the name. That's
             // the one we'll want to we'll probe for it later.
-            toplevel.push((filename.file_stem().unwrap()
-                                    .to_str().unwrap().to_string(),
-                            filename.extension().unwrap().to_owned()
-                                    .to_str().unwrap().to_string()));
+            //
+            // We do not use `Path::file_stem` or `Path::extension` here,
+            // because some generated files may have multiple extensions e.g.
+            // `std-<hash>.dll.lib` on Windows. The aforementioned methods only
+            // split the file name by the last extension (`.lib`) while we need
+            // to split by all extensions (`.dll.lib`).
+            let filename = filename.file_name().unwrap().to_str().unwrap();
+            let mut parts = filename.splitn(2, '.');
+            let file_stem = parts.next().unwrap().to_owned();
+            let extension = parts.next().unwrap().to_owned();
+
+            toplevel.push((file_stem, extension));
         }
     }