@@ -3,7 +3,7 @@ use rustc_data_structures::temp_dir::MaybeTempDir;
33use rustc_errors:: Handler ;
44use rustc_fs_util:: fix_windows_verbatim_for_gcc;
55use rustc_hir:: def_id:: CrateNum ;
6- use rustc_middle:: middle:: cstore:: { DllImport , LibSource } ;
6+ use rustc_middle:: middle:: cstore:: DllImport ;
77use rustc_middle:: middle:: dependency_format:: Linkage ;
88use rustc_session:: config:: { self , CFGuard , CrateType , DebugInfo , LdImpl , Strip } ;
99use rustc_session:: config:: { OutputFilenames , OutputType , PrintRequest } ;
@@ -238,7 +238,7 @@ pub fn each_linked_rlib(
238238 info : & CrateInfo ,
239239 f : & mut dyn FnMut ( CrateNum , & Path ) ,
240240) -> Result < ( ) , String > {
241- let crates = info. used_crates_static . iter ( ) ;
241+ let crates = info. used_crates . iter ( ) ;
242242 let mut fmts = None ;
243243 for ( ty, list) in info. dependency_formats . iter ( ) {
244244 match ty {
@@ -256,22 +256,23 @@ pub fn each_linked_rlib(
256256 Some ( f) => f,
257257 None => return Err ( "could not find formats for rlibs" . to_string ( ) ) ,
258258 } ;
259- for & ( cnum, ref path ) in crates {
259+ for & cnum in crates {
260260 match fmts. get ( cnum. as_usize ( ) - 1 ) {
261261 Some ( & Linkage :: NotLinked | & Linkage :: IncludedFromDylib ) => continue ,
262262 Some ( _) => { }
263263 None => return Err ( "could not find formats for rlibs" . to_string ( ) ) ,
264264 }
265265 let name = & info. crate_name [ & cnum] ;
266- let path = match * path {
267- LibSource :: Some ( ref p) => p,
268- LibSource :: MetadataOnly => {
269- return Err ( format ! (
270- "could not find rlib for: `{}`, found rmeta (metadata) file" ,
271- name
272- ) ) ;
273- }
274- LibSource :: None => return Err ( format ! ( "could not find rlib for: `{}`" , name) ) ,
266+ let used_crate_source = & info. used_crate_source [ & cnum] ;
267+ let path = if let Some ( ( path, _) ) = & used_crate_source. rlib {
268+ path
269+ } else if used_crate_source. rmeta . is_some ( ) {
270+ return Err ( format ! (
271+ "could not find rlib for: `{}`, found rmeta (metadata) file" ,
272+ name
273+ ) ) ;
274+ } else {
275+ return Err ( format ! ( "could not find rlib for: `{}`" , name) ) ;
275276 } ;
276277 f ( cnum, & path) ;
277278 }
@@ -1759,8 +1760,19 @@ fn add_rpath_args(
17591760 // where extern libraries might live, based on the
17601761 // add_lib_search_paths
17611762 if sess. opts . cg . rpath {
1763+ let libs = codegen_results
1764+ . crate_info
1765+ . used_crates
1766+ . iter ( )
1767+ . filter_map ( |cnum| {
1768+ codegen_results. crate_info . used_crate_source [ cnum]
1769+ . dylib
1770+ . as_ref ( )
1771+ . map ( |( path, _) | & * * path)
1772+ } )
1773+ . collect :: < Vec < _ > > ( ) ;
17621774 let mut rpath_config = RPathConfig {
1763- used_crates : & codegen_results . crate_info . used_crates_dynamic ,
1775+ libs : & * libs ,
17641776 out_filename : out_filename. to_path_buf ( ) ,
17651777 has_rpath : sess. target . has_rpath ,
17661778 is_like_osx : sess. target . is_like_osx ,
@@ -2121,7 +2133,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
21212133
21222134 // Invoke get_used_crates to ensure that we get a topological sorting of
21232135 // crates.
2124- let deps = & codegen_results. crate_info . used_crates_dynamic ;
2136+ let deps = & codegen_results. crate_info . used_crates ;
21252137
21262138 // There's a few internal crates in the standard library (aka libcore and
21272139 // libstd) which actually have a circular dependence upon one another. This
@@ -2149,7 +2161,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
21492161 let mut required = FxHashSet :: default ( ) ;
21502162
21512163 let info = & codegen_results. crate_info ;
2152- for & ( cnum, _ ) in deps. iter ( ) . rev ( ) {
2164+ for & cnum in deps. iter ( ) . rev ( ) {
21532165 if let Some ( missing) = info. missing_lang_items . get ( & cnum) {
21542166 let missing_crates = missing. iter ( ) . map ( |i| info. lang_item_to_crate . get ( i) . copied ( ) ) ;
21552167 required. extend ( missing_crates) ;
@@ -2176,7 +2188,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
21762188
21772189 let mut compiler_builtins = None ;
21782190
2179- for & ( cnum, _ ) in deps. iter ( ) {
2191+ for & cnum in deps. iter ( ) {
21802192 if group_start == Some ( cnum) {
21812193 cmd. group_start ( ) ;
21822194 }
@@ -2388,9 +2400,9 @@ fn add_upstream_native_libraries(
23882400 . find ( |( ty, _) | * ty == crate_type)
23892401 . expect ( "failed to find crate type in dependency format list" ) ;
23902402
2391- let crates = & codegen_results. crate_info . used_crates_static ;
2403+ let crates = & codegen_results. crate_info . used_crates ;
23922404 let mut last = ( NativeLibKind :: Unspecified , None ) ;
2393- for & ( cnum, _ ) in crates {
2405+ for & cnum in crates {
23942406 for lib in codegen_results. crate_info . native_libraries [ & cnum] . iter ( ) {
23952407 let name = match lib. name {
23962408 Some ( l) => l,
0 commit comments