about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-13 18:07:59 +0000
committerbors <bors@rust-lang.org>2024-01-13 18:07:59 +0000
commit23148b175bb912dfced55b1ffdefcc8d2945702b (patch)
treefb75a0e8f018b2e0f55059bf882c7f5e83d4ca36 /compiler/rustc_codegen_ssa/src/back
parentc6c4abf58499d89000e333627237e63dbca24437 (diff)
parent4612edc53f998994cffaa1b5856d624ad3910c18 (diff)
downloadrust-23148b175bb912dfced55b1ffdefcc8d2945702b.tar.gz
rust-23148b175bb912dfced55b1ffdefcc8d2945702b.zip
Auto merge of #119409 - Kobzol:rustc-codegen-ssa-query-instability, r=Nilstrieb
rustc_codegen_ssa: Enforce `rustc::potential_query_instability` lint

Part of https://github.com/rust-lang/rust/issues/84447.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs14
-rw-r--r--compiler/rustc_codegen_ssa/src/back/symbol_export.rs2
2 files changed, 14 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index ace356ab153..f654d58f02a 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -554,6 +554,11 @@ fn link_staticlib<'a>(
             archive_builder_builder
                 .extract_bundled_libs(path, tempdir.as_ref(), &relevant_libs)
                 .unwrap_or_else(|e| sess.dcx().emit_fatal(e));
+
+            // We sort the libraries below
+            #[allow(rustc::potential_query_instability)]
+            let mut relevant_libs: Vec<Symbol> = relevant_libs.into_iter().collect();
+            relevant_libs.sort_unstable();
             for filename in relevant_libs {
                 let joined = tempdir.as_ref().join(filename.as_str());
                 let path = joined.as_path();
@@ -2201,14 +2206,19 @@ fn linker_with_args<'a>(
         .iter()
         .find(|(ty, _)| *ty == crate_type)
         .expect("failed to find crate type in dependency format list");
-    let native_libraries_from_nonstatics = codegen_results
+
+    // We sort the libraries below
+    #[allow(rustc::potential_query_instability)]
+    let mut native_libraries_from_nonstatics = codegen_results
         .crate_info
         .native_libraries
         .iter()
         .filter_map(|(cnum, libraries)| {
             (dependency_linkage[cnum.as_usize() - 1] != Linkage::Static).then_some(libraries)
         })
-        .flatten();
+        .flatten()
+        .collect::<Vec<_>>();
+    native_libraries_from_nonstatics.sort_unstable_by(|a, b| a.name.as_str().cmp(b.name.as_str()));
     for (raw_dylib_name, raw_dylib_imports) in
         collate_raw_dylibs(sess, native_libraries_from_nonstatics)?
     {
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
index cae7c40c5ad..2dba04e0bb7 100644
--- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
+++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
@@ -319,6 +319,8 @@ fn exported_symbols_provider_local(
 
         let (_, cgus) = tcx.collect_and_partition_mono_items(());
 
+        // The symbols created in this loop are sorted below it
+        #[allow(rustc::potential_query_instability)]
         for (mono_item, data) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
             if data.linkage != Linkage::External {
                 // We can only re-use things with external linkage, otherwise