Skip to content

Commit 9cfe5f6

Browse files
committed
bootstrap: split runtime DLL part out of make_win_dist
1 parent 987a49b commit 9cfe5f6

File tree

1 file changed

+35
-39
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+35
-39
lines changed

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,7 @@ fn find_files(files: &[&str], path: &[PathBuf]) -> Vec<PathBuf> {
174174
found
175175
}
176176

177-
fn make_win_dist(
178-
rust_root: &Path,
179-
plat_root: &Path,
180-
target: TargetSelection,
181-
builder: &Builder<'_>,
182-
) {
177+
fn make_win_dist(plat_root: &Path, target: TargetSelection, builder: &Builder<'_>) {
183178
if builder.config.dry_run() {
184179
return;
185180
}
@@ -194,12 +189,6 @@ fn make_win_dist(
194189
"gcc.exe"
195190
};
196191
let target_tools = [compiler, "ld.exe", "dlltool.exe", "libwinpthread-1.dll"];
197-
let mut rustc_dlls = vec!["libwinpthread-1.dll"];
198-
if target.starts_with("i686-") {
199-
rustc_dlls.push("libgcc_s_dw2-1.dll");
200-
} else {
201-
rustc_dlls.push("libgcc_s_seh-1.dll");
202-
}
203192

204193
// Libraries necessary to link the windows-gnu toolchains.
205194
// System libraries will be preferred if they are available (see #67429).
@@ -255,25 +244,8 @@ fn make_win_dist(
255244

256245
//Find mingw artifacts we want to bundle
257246
let target_tools = find_files(&target_tools, &bin_path);
258-
let rustc_dlls = find_files(&rustc_dlls, &bin_path);
259247
let target_libs = find_files(&target_libs, &lib_path);
260248

261-
// Copy runtime dlls next to rustc.exe
262-
let rust_bin_dir = rust_root.join("bin/");
263-
fs::create_dir_all(&rust_bin_dir).expect("creating rust_bin_dir failed");
264-
for src in &rustc_dlls {
265-
builder.copy_link_to_folder(src, &rust_bin_dir);
266-
}
267-
268-
if builder.config.lld_enabled {
269-
// rust-lld.exe also needs runtime dlls
270-
let rust_target_bin_dir = rust_root.join("lib/rustlib").join(target).join("bin");
271-
fs::create_dir_all(&rust_target_bin_dir).expect("creating rust_target_bin_dir failed");
272-
for src in &rustc_dlls {
273-
builder.copy_link_to_folder(src, &rust_target_bin_dir);
274-
}
275-
}
276-
277249
//Copy platform tools to platform-specific bin directory
278250
let plat_target_bin_self_contained_dir =
279251
plat_root.join("lib/rustlib").join(target).join("bin/self-contained");
@@ -301,6 +273,37 @@ fn make_win_dist(
301273
}
302274
}
303275

276+
fn runtime_dll_dist(rust_root: &Path, target: TargetSelection, builder: &Builder<'_>) {
277+
if builder.config.dry_run() {
278+
return;
279+
}
280+
281+
let (bin_path, _) = get_cc_search_dirs(target, builder);
282+
283+
let mut rustc_dlls = vec!["libwinpthread-1.dll"];
284+
if target.starts_with("i686-") {
285+
rustc_dlls.push("libgcc_s_dw2-1.dll");
286+
} else {
287+
rustc_dlls.push("libgcc_s_seh-1.dll");
288+
}
289+
let rustc_dlls = find_files(&rustc_dlls, &bin_path);
290+
291+
// Copy runtime dlls next to rustc.exe
292+
let rust_bin_dir = rust_root.join("bin/");
293+
fs::create_dir_all(&rust_bin_dir).expect("creating rust_bin_dir failed");
294+
for src in &rustc_dlls {
295+
builder.copy_link_to_folder(src, &rust_bin_dir);
296+
}
297+
298+
if builder.config.lld_enabled {
299+
// rust-lld.exe also needs runtime dlls
300+
let rust_target_bin_dir = rust_root.join("lib/rustlib").join(target).join("bin");
301+
fs::create_dir_all(&rust_target_bin_dir).expect("creating rust_target_bin_dir failed");
302+
for src in &rustc_dlls {
303+
builder.copy_link_to_folder(src, &rust_target_bin_dir);
304+
}
305+
}
306+
}
304307

305308
fn get_cc_search_dirs(
306309
target: TargetSelection,
@@ -359,11 +362,7 @@ impl Step for Mingw {
359362
let mut tarball = Tarball::new(builder, "rust-mingw", &host.triple);
360363
tarball.set_product_name("Rust MinGW");
361364

362-
// The first argument is a "temporary directory" which is just
363-
// thrown away (this contains the runtime DLLs included in the rustc package
364-
// above) and the second argument is where to place all the MinGW components
365-
// (which is what we want).
366-
make_win_dist(&tmpdir(builder), tarball.image_dir(), host, builder);
365+
make_win_dist(tarball.image_dir(), host, builder);
367366

368367
Some(tarball.generate())
369368
}
@@ -403,17 +402,14 @@ impl Step for Rustc {
403402
prepare_image(builder, compiler, tarball.image_dir());
404403

405404
// On MinGW we've got a few runtime DLL dependencies that we need to
406-
// include. The first argument to this script is where to put these DLLs
407-
// (the image we're creating), and the second argument is a junk directory
408-
// to ignore all other MinGW stuff the script creates.
409-
//
405+
// include.
410406
// On 32-bit MinGW we're always including a DLL which needs some extra
411407
// licenses to distribute. On 64-bit MinGW we don't actually distribute
412408
// anything requiring us to distribute a license, but it's likely the
413409
// install will *also* include the rust-mingw package, which also needs
414410
// licenses, so to be safe we just include it here in all MinGW packages.
415411
if host.ends_with("pc-windows-gnu") && builder.config.dist_include_mingw_linker {
416-
make_win_dist(tarball.image_dir(), &tmpdir(builder), host, builder);
412+
runtime_dll_dist(tarball.image_dir(), host, builder);
417413
tarball.add_dir(builder.src.join("src/etc/third-party"), "share/doc");
418414
}
419415

0 commit comments

Comments
 (0)