diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-06-07 15:23:44 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-07-07 15:32:51 +0200 |
| commit | 2977dff116a3ec93135c349ed39a46eec008c51c (patch) | |
| tree | b6c00453db9f375869c5e476dad4c2366d9d33a7 /compiler/rustc_codegen_ssa/src | |
| parent | 9a27044f42ace9eb652781b53f598e25d4e7e918 (diff) | |
| download | rust-2977dff116a3ec93135c349ed39a46eec008c51c.tar.gz rust-2977dff116a3ec93135c349ed39a46eec008c51c.zip | |
Remove a sorting operation from used_crates
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/base.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 0036935be67..15c4ce8a4d0 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -19,7 +19,7 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::lang_items::LangItem; use rustc_index::vec::Idx; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; -use rustc_middle::middle::cstore::{self, EncodedMetadata}; +use rustc_middle::middle::cstore::EncodedMetadata; use rustc_middle::middle::lang_items; use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem}; use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout}; @@ -769,6 +769,22 @@ impl CrateInfo { subsystem.to_string() }); + // This list is used when generating the command line to pass through to + // system linker. The linker expects undefined symbols on the left of the + // command line to be defined in libraries on the right, not the other way + // around. For more info, see some comments in the add_used_library function + // below. + // + // In order to get this left-to-right dependency ordering, we use the reverse + // postorder of all crates putting the leaves at the right-most positions. + let used_crates = tcx + .postorder_cnums(()) + .iter() + .rev() + .copied() + .filter(|&cnum| !tcx.dep_kind(cnum).macros_only()) + .collect(); + let mut info = CrateInfo { local_crate_name, panic_runtime: None, @@ -778,7 +794,7 @@ impl CrateInfo { native_libraries: Default::default(), used_libraries: tcx.native_libraries(LOCAL_CRATE).iter().map(Into::into).collect(), crate_name: Default::default(), - used_crates: cstore::used_crates(tcx), + used_crates, used_crate_source: Default::default(), lang_item_to_crate: Default::default(), missing_lang_items: Default::default(), |
