@@ -335,8 +335,8 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
335335 }
336336
337337 let Some ( name) = lib. name else {
338- continue ;
339- } ;
338+ continue ;
339+ } ;
340340
341341 let location = find_library (
342342 name. as_str ( ) ,
@@ -345,23 +345,28 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
345345 sess,
346346 ) ;
347347
348- if ( flavor == RlibFlavor :: Normal ) && sess. opts . unstable_opts . split_bundled_libs {
348+ if flavor == RlibFlavor :: Normal && sess. opts . unstable_opts . split_bundled_libs {
349349 let suffix = & sess. target . staticlib_suffix ;
350- let crate_name = out_filename. to_str ( ) . unwrap ( ) ;
351- let bundle_lib = PathBuf :: from ( & format ! ( "{crate_name}.bundle.{name}{suffix}" ) ) ;
352- fs:: copy ( location, bundle_lib) . unwrap ( ) ;
353- continue ;
350+ let bundle_lib = PathBuf :: from ( format ! ( "{}.bundle.{name}{suffix}" , out_filename. display( ) ) ) ;
351+ match fs:: copy ( location, bundle_lib) {
352+ Ok ( _) => { } ,
353+ Err ( _) => sess. fatal ( "unable to create file for bundle lib" ) ,
354+ }
355+ } else {
356+ ab. add_archive ( & location, |_| false ) . unwrap_or_else ( |e| {
357+ sess. fatal ( & format ! (
358+ "failed to add native library {}: {}" ,
359+ location. to_string_lossy( ) ,
360+ e
361+ ) ) ;
362+ } ) ;
354363 }
355-
356- ab. add_archive ( & location, |_| false ) . unwrap_or_else ( |e| {
357- sess. fatal ( & format ! (
358- "failed to add native library {}: {}" ,
359- location. to_string_lossy( ) ,
360- e
361- ) ) ;
362- } ) ;
363364 }
364- _ => { }
365+ NativeLibKind :: Static { bundle : Some ( false ) , .. }
366+ | NativeLibKind :: Dylib { .. }
367+ | NativeLibKind :: Framework { .. }
368+ | NativeLibKind :: RawDylib
369+ | NativeLibKind :: Unspecified => continue ,
365370 }
366371 }
367372
@@ -2376,40 +2381,39 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
23762381 ( lib. name , lib. kind , lib. verbatim )
23772382 } ;
23782383
2379- if sess. opts . unstable_opts . split_bundled_libs {
2380- if let NativeLibKind :: Static {
2381- bundle : Some ( true ) | None ,
2382- whole_archive,
2383- } = lib. kind
2384+ match lib. kind {
2385+ NativeLibKind :: Static { bundle : None | Some ( true ) , whole_archive }
2386+ if sess. opts . unstable_opts . split_bundled_libs =>
23842387 {
23852388 let suffix = & sess. target . staticlib_suffix ;
2386- let crate_path = src. paths ( ) . next ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
2389+ let cratepath = & src. rlib . as_ref ( ) . unwrap ( ) . 0 ;
23872390 let bundle_lib =
2388- PathBuf :: from ( & format ! ( "{crate_path }.bundle.{name}{suffix}" ) ) ;
2391+ PathBuf :: from ( format ! ( "{}.bundle.{name}{suffix}" , cratepath . display ( ) ) ) ;
23892392 if whole_archive == Some ( true ) {
2390- cmd. link_whole_rlib ( & bundle_lib) ;
2393+ cmd. link_whole_rlib ( & fix_windows_verbatim_for_gcc ( & bundle_lib) ) ;
23912394 } else {
2392- cmd. link_rlib ( & bundle_lib) ;
2395+ cmd. link_rlib ( & fix_windows_verbatim_for_gcc ( & bundle_lib) ) ;
23932396 }
2394-
2395- continue ;
23962397 }
2397- }
23982398
2399- if let NativeLibKind :: Static { bundle : Some ( false ) , whole_archive } =
2400- lib. kind
2401- {
2402- let verbatim = lib. verbatim . unwrap_or ( false ) ;
2403- if whole_archive == Some ( true ) {
2404- cmd. link_whole_staticlib (
2405- name,
2406- verbatim,
2407- search_path. get_or_init ( || archive_search_paths ( sess) ) ,
2408- ) ;
2409- } else {
2410- cmd. link_staticlib ( name, verbatim) ;
2399+ NativeLibKind :: Static { bundle : Some ( false ) , whole_archive } => {
2400+ let verbatim = lib. verbatim . unwrap_or ( false ) ;
2401+ if whole_archive == Some ( true ) {
2402+ cmd. link_whole_staticlib (
2403+ name,
2404+ verbatim,
2405+ search_path. get_or_init ( || archive_search_paths ( sess) ) ,
2406+ ) ;
2407+ } else {
2408+ cmd. link_staticlib ( name, verbatim) ;
2409+ }
24112410 }
2412- }
2411+ NativeLibKind :: Static { bundle : None | Some ( true ) , .. }
2412+ | NativeLibKind :: Dylib { .. }
2413+ | NativeLibKind :: Framework { .. }
2414+ | NativeLibKind :: RawDylib
2415+ | NativeLibKind :: Unspecified => { }
2416+ } ;
24132417 }
24142418 }
24152419 }
0 commit comments