@@ -354,7 +354,9 @@ fn link_rlib<'a>(
354
354
continue ;
355
355
} ;
356
356
if flavor == RlibFlavor :: Normal
357
- && ( sess. opts . unstable_opts . packed_bundled_libs || whole_archive == Some ( true ) )
357
+ && ( sess. opts . unstable_opts . packed_bundled_libs
358
+ || whole_archive == Some ( true )
359
+ || lib. cfg . is_some ( ) )
358
360
{
359
361
let name = lib. filename . unwrap ( ) ;
360
362
let path = find_native_static_library ( name. as_str ( ) , true , & lib_search_paths, sess) ;
@@ -525,7 +527,7 @@ fn link_staticlib<'a>(
525
527
false
526
528
} ) ,
527
529
)
528
- . unwrap ( ) ; // It may be error?
530
+ . unwrap ( ) ;
529
531
530
532
let bundled: FxHashSet < _ > = native_libs. iter ( ) . filter_map ( |lib| lib. filename ) . collect ( ) ;
531
533
archive_builder_builder
@@ -2547,20 +2549,8 @@ fn add_static_crate<'a>(
2547
2549
cmd. link_rlib ( & fix_windows_verbatim_for_gcc ( path) ) ;
2548
2550
} ;
2549
2551
2550
- // See the comment above in `link_staticlib` and `link_rlib` for why if
2551
- // there's a static library that's not relevant we skip all object
2552
- // files.
2553
- let native_libs = & codegen_results. crate_info . native_libraries [ & cnum] ;
2554
- let skip_native = native_libs. iter ( ) . any ( |lib| {
2555
- matches ! ( lib. kind, NativeLibKind :: Static { bundle: None | Some ( true ) , .. } )
2556
- && !relevant_lib ( sess, lib)
2557
- } ) ;
2558
- let _ = skip_native;
2559
- let skip_native = false ;
2560
-
2561
- if ( !are_upstream_rust_objects_already_included ( sess)
2562
- || ignored_for_lto ( sess, & codegen_results. crate_info , cnum) )
2563
- && !skip_native
2552
+ if !are_upstream_rust_objects_already_included ( sess)
2553
+ || ignored_for_lto ( sess, & codegen_results. crate_info , cnum)
2564
2554
{
2565
2555
link_upstream ( cratepath) ;
2566
2556
return ;
@@ -2591,17 +2581,13 @@ fn add_static_crate<'a>(
2591
2581
let is_rust_object =
2592
2582
canonical. starts_with ( & canonical_name) && looks_like_rust_object_file ( & f) ;
2593
2583
2594
- // If we've been requested to skip all native object files
2595
- // (those not generated by the rust compiler) then we can skip
2596
- // this file. See above for why we may want to do this.
2597
- let skip_because_cfg_say_so = skip_native && !is_rust_object;
2598
-
2599
2584
// If we're performing LTO and this is a rust-generated object
2600
2585
// file, then we don't need the object file as it's part of the
2601
2586
// LTO module. Note that `#![no_builtins]` is excluded from LTO,
2602
2587
// though, so we let that object file slide.
2603
- let skip_because_lto =
2604
- upstream_rust_objects_already_included && is_rust_object && is_builtins;
2588
+ if upstream_rust_objects_already_included && is_rust_object && is_builtins {
2589
+ return true ;
2590
+ }
2605
2591
2606
2592
// We skip native libraries because:
2607
2593
// 1. This native libraries won't be used from the generated rlib,
@@ -2612,10 +2598,6 @@ fn add_static_crate<'a>(
2612
2598
return true ;
2613
2599
}
2614
2600
2615
- if skip_because_cfg_say_so || skip_because_lto {
2616
- return true ;
2617
- }
2618
-
2619
2601
false
2620
2602
} ) ,
2621
2603
) {
0 commit comments