@@ -174,12 +174,7 @@ fn find_files(files: &[&str], path: &[PathBuf]) -> Vec<PathBuf> {
174
174
found
175
175
}
176
176
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 < ' _ > ) {
183
178
if builder. config . dry_run ( ) {
184
179
return ;
185
180
}
@@ -194,12 +189,6 @@ fn make_win_dist(
194
189
"gcc.exe"
195
190
} ;
196
191
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
- }
203
192
204
193
// Libraries necessary to link the windows-gnu toolchains.
205
194
// System libraries will be preferred if they are available (see #67429).
@@ -255,25 +244,8 @@ fn make_win_dist(
255
244
256
245
//Find mingw artifacts we want to bundle
257
246
let target_tools = find_files ( & target_tools, & bin_path) ;
258
- let rustc_dlls = find_files ( & rustc_dlls, & bin_path) ;
259
247
let target_libs = find_files ( & target_libs, & lib_path) ;
260
248
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
-
277
249
//Copy platform tools to platform-specific bin directory
278
250
let plat_target_bin_self_contained_dir =
279
251
plat_root. join ( "lib/rustlib" ) . join ( target) . join ( "bin/self-contained" ) ;
@@ -301,6 +273,37 @@ fn make_win_dist(
301
273
}
302
274
}
303
275
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
+ }
304
307
305
308
fn get_cc_search_dirs (
306
309
target : TargetSelection ,
@@ -359,11 +362,7 @@ impl Step for Mingw {
359
362
let mut tarball = Tarball :: new ( builder, "rust-mingw" , & host. triple ) ;
360
363
tarball. set_product_name ( "Rust MinGW" ) ;
361
364
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) ;
367
366
368
367
Some ( tarball. generate ( ) )
369
368
}
@@ -403,17 +402,14 @@ impl Step for Rustc {
403
402
prepare_image ( builder, compiler, tarball. image_dir ( ) ) ;
404
403
405
404
// 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.
410
406
// On 32-bit MinGW we're always including a DLL which needs some extra
411
407
// licenses to distribute. On 64-bit MinGW we don't actually distribute
412
408
// anything requiring us to distribute a license, but it's likely the
413
409
// install will *also* include the rust-mingw package, which also needs
414
410
// licenses, so to be safe we just include it here in all MinGW packages.
415
411
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) ;
417
413
tarball. add_dir ( builder. src . join ( "src/etc/third-party" ) , "share/doc" ) ;
418
414
}
419
415
0 commit comments