Skip to content

Commit 3b81573

Browse files
committed
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 (Bump to 1.23 and update bootstrap).
1 parent fbc3642 commit 3b81573

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/bootstrap/compile.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,18 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) {
860860
// have a hash in the name, but there's a version of this file in
861861
// the `deps` folder which *does* have a hash in the name. That's
862862
// the one we'll want to we'll probe for it later.
863-
toplevel.push((filename.file_stem().unwrap()
864-
.to_str().unwrap().to_string(),
865-
filename.extension().unwrap().to_owned()
866-
.to_str().unwrap().to_string()));
863+
//
864+
// We do not use `Path::file_stem` or `Path::extension` here,
865+
// because some generated files may have multiple extensions e.g.
866+
// `std-<hash>.dll.lib` on Windows. The aforementioned methods only
867+
// split the file name by the last extension (`.lib`) while we need
868+
// to split by all extensions (`.dll.lib`).
869+
let filename = filename.file_name().unwrap().to_str().unwrap();
870+
let mut parts = filename.splitn(2, '.');
871+
let file_stem = parts.next().unwrap().to_owned();
872+
let extension = parts.next().unwrap().to_owned();
873+
874+
toplevel.push((file_stem, extension));
867875
}
868876
}
869877

0 commit comments

Comments
 (0)