mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Fix parallel rustc not being reproducible due to unstable sorting of items.
This commit is contained in:
@@ -689,6 +689,7 @@ macro_rules! untracked {
|
||||
// Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
|
||||
// tidy-alphabetical-start
|
||||
untracked!(assert_incr_state, Some(String::from("loaded")));
|
||||
untracked!(codegen_source_order, true);
|
||||
untracked!(deduplicate_diagnostics, false);
|
||||
untracked!(dump_dep_graph, true);
|
||||
untracked!(dump_mir, Some(String::from("abc")));
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
use rustc_hir::ItemId;
|
||||
use rustc_hir::attrs::InlineAttr;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, LOCAL_CRATE};
|
||||
use rustc_index::Idx;
|
||||
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
use rustc_session::config::OptLevel;
|
||||
@@ -526,44 +525,50 @@ pub fn items_in_deterministic_order(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Vec<(MonoItem<'tcx>, MonoItemData)> {
|
||||
// The codegen tests rely on items being process in the same order as
|
||||
// they appear in the file, so for local items, we sort by node_id first
|
||||
// they appear in the file, so for local items, we sort by span first
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
struct ItemSortKey<'tcx>(Option<usize>, SymbolName<'tcx>);
|
||||
struct ItemSortKey<'tcx>(Option<Span>, SymbolName<'tcx>);
|
||||
|
||||
// We only want to take HirIds of user-defines instances into account.
|
||||
// The others don't matter for the codegen tests and can even make item
|
||||
// order unstable.
|
||||
fn local_item_id<'tcx>(item: MonoItem<'tcx>) -> Option<DefId> {
|
||||
match item {
|
||||
MonoItem::Fn(ref instance) => match instance.def {
|
||||
InstanceKind::Item(def) => def.as_local().map(|_| def),
|
||||
InstanceKind::VTableShim(..)
|
||||
| InstanceKind::ReifyShim(..)
|
||||
| InstanceKind::Intrinsic(..)
|
||||
| InstanceKind::FnPtrShim(..)
|
||||
| InstanceKind::Virtual(..)
|
||||
| InstanceKind::ClosureOnceShim { .. }
|
||||
| InstanceKind::ConstructCoroutineInClosureShim { .. }
|
||||
| InstanceKind::DropGlue(..)
|
||||
| InstanceKind::CloneShim(..)
|
||||
| InstanceKind::ThreadLocalShim(..)
|
||||
| InstanceKind::FnPtrAddrShim(..)
|
||||
| InstanceKind::AsyncDropGlue(..)
|
||||
| InstanceKind::FutureDropPollShim(..)
|
||||
| InstanceKind::AsyncDropGlueCtorShim(..) => None,
|
||||
},
|
||||
MonoItem::Static(def_id) => def_id.as_local().map(|_| def_id),
|
||||
MonoItem::GlobalAsm(item_id) => Some(item_id.owner_id.def_id.to_def_id()),
|
||||
}
|
||||
}
|
||||
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<'tcx> {
|
||||
ItemSortKey(
|
||||
match item {
|
||||
MonoItem::Fn(ref instance) => {
|
||||
match instance.def {
|
||||
// We only want to take HirIds of user-defined
|
||||
// instances into account. The others don't matter for
|
||||
// the codegen tests and can even make item order
|
||||
// unstable.
|
||||
InstanceKind::Item(def) => def.as_local().map(Idx::index),
|
||||
InstanceKind::VTableShim(..)
|
||||
| InstanceKind::ReifyShim(..)
|
||||
| InstanceKind::Intrinsic(..)
|
||||
| InstanceKind::FnPtrShim(..)
|
||||
| InstanceKind::Virtual(..)
|
||||
| InstanceKind::ClosureOnceShim { .. }
|
||||
| InstanceKind::ConstructCoroutineInClosureShim { .. }
|
||||
| InstanceKind::DropGlue(..)
|
||||
| InstanceKind::CloneShim(..)
|
||||
| InstanceKind::ThreadLocalShim(..)
|
||||
| InstanceKind::FnPtrAddrShim(..)
|
||||
| InstanceKind::AsyncDropGlue(..)
|
||||
| InstanceKind::FutureDropPollShim(..)
|
||||
| InstanceKind::AsyncDropGlueCtorShim(..) => None,
|
||||
}
|
||||
}
|
||||
MonoItem::Static(def_id) => def_id.as_local().map(Idx::index),
|
||||
MonoItem::GlobalAsm(item_id) => Some(item_id.owner_id.def_id.index()),
|
||||
},
|
||||
local_item_id(item)
|
||||
.map(|def_id| tcx.def_span(def_id).find_ancestor_not_from_macro())
|
||||
.flatten(),
|
||||
item.symbol_name(tcx),
|
||||
)
|
||||
}
|
||||
|
||||
let mut items: Vec<_> = self.items().iter().map(|(&i, &data)| (i, data)).collect();
|
||||
if !tcx.sess.opts.unstable_opts.codegen_source_order {
|
||||
// It's already deterministic, so we can just use it.
|
||||
return items;
|
||||
}
|
||||
items.sort_by_cached_key(|&(i, _)| item_sort_key(tcx, i));
|
||||
items
|
||||
}
|
||||
|
||||
@@ -2165,6 +2165,8 @@ pub(crate) fn parse_align(slot: &mut Option<Align>, v: Option<&str>) -> bool {
|
||||
"hash algorithm of source files used to check freshness in cargo (`blake3` or `sha256`)"),
|
||||
codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||
"the backend to use"),
|
||||
codegen_source_order: bool = (false, parse_bool, [UNTRACKED],
|
||||
"emit mono items in the order of spans in source files (default: no)"),
|
||||
contract_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"emit runtime checks for contract pre- and post-conditions (default: no)"),
|
||||
coverage_options: CoverageOptions = (CoverageOptions::default(), parse_coverage_options, [TRACKED],
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# `codegen-source-order`
|
||||
|
||||
---
|
||||
|
||||
This feature allows you to have a predictive and
|
||||
deterministic order for items after codegen, which
|
||||
is the same as in source code.
|
||||
|
||||
For every `CodegenUnit`, local `MonoItem`s would
|
||||
be sorted by `(Span, SymbolName)`, which
|
||||
makes codegen tests rely on the order of items in
|
||||
source files work.
|
||||
@@ -1695,6 +1695,10 @@ fn make_compile_args(
|
||||
}
|
||||
TestMode::Assembly | TestMode::Codegen => {
|
||||
rustc.arg("-Cdebug-assertions=no");
|
||||
// For assembly and codegen tests, we want to use the same order
|
||||
// of the items of a codegen unit as the source order, so that
|
||||
// we can compare the output with the source code through filecheck.
|
||||
rustc.arg("-Zcodegen-source-order");
|
||||
}
|
||||
TestMode::Crashes => {
|
||||
set_mir_dump_dir(&mut rustc);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo`
|
||||
--> $DIR/bad-intrinsic-monomorphization.rs:16:5
|
||||
error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo`
|
||||
--> $DIR/bad-intrinsic-monomorphization.rs:26:5
|
||||
|
|
||||
LL | intrinsics::cttz(v)
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
LL | intrinsics::simd::simd_add(a, b)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `fadd_fast` intrinsic: expected basic float type, found `Foo`
|
||||
--> $DIR/bad-intrinsic-monomorphization.rs:21:5
|
||||
@@ -10,11 +10,11 @@ error[E0511]: invalid monomorphization of `fadd_fast` intrinsic: expected basic
|
||||
LL | intrinsics::fadd_fast(a, b)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo`
|
||||
--> $DIR/bad-intrinsic-monomorphization.rs:26:5
|
||||
error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo`
|
||||
--> $DIR/bad-intrinsic-monomorphization.rs:16:5
|
||||
|
|
||||
LL | intrinsics::simd::simd_add(a, b)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | intrinsics::cttz(v)
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
||||
@@ -1,65 +1,23 @@
|
||||
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `bool`
|
||||
--> $DIR/non-integer-atomic.rs:15:5
|
||||
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
|
||||
--> $DIR/non-integer-atomic.rs:55:5
|
||||
|
|
||||
LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `bool`
|
||||
--> $DIR/non-integer-atomic.rs:20:5
|
||||
|
|
||||
LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `bool`
|
||||
--> $DIR/non-integer-atomic.rs:25:5
|
||||
|
|
||||
LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `bool`
|
||||
--> $DIR/non-integer-atomic.rs:30:5
|
||||
|
|
||||
LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `Foo`
|
||||
--> $DIR/non-integer-atomic.rs:35:5
|
||||
|
|
||||
LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `Foo`
|
||||
--> $DIR/non-integer-atomic.rs:40:5
|
||||
|
|
||||
LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `Foo`
|
||||
--> $DIR/non-integer-atomic.rs:45:5
|
||||
|
|
||||
LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `Foo`
|
||||
--> $DIR/non-integer-atomic.rs:50:5
|
||||
|
|
||||
LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
|
||||
--> $DIR/non-integer-atomic.rs:55:5
|
||||
|
|
||||
LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
|
||||
--> $DIR/non-integer-atomic.rs:60:5
|
||||
|
|
||||
LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
|
||||
--> $DIR/non-integer-atomic.rs:65:5
|
||||
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
|
||||
--> $DIR/non-integer-atomic.rs:85:5
|
||||
|
|
||||
LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -70,30 +28,72 @@ error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected bas
|
||||
LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
|
||||
--> $DIR/non-integer-atomic.rs:75:5
|
||||
|
|
||||
LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
|
||||
--> $DIR/non-integer-atomic.rs:80:5
|
||||
error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `Foo`
|
||||
--> $DIR/non-integer-atomic.rs:40:5
|
||||
|
|
||||
LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
|
||||
--> $DIR/non-integer-atomic.rs:85:5
|
||||
|
|
||||
LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
|
||||
--> $DIR/non-integer-atomic.rs:90:5
|
||||
|
|
||||
LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
|
||||
--> $DIR/non-integer-atomic.rs:80:5
|
||||
|
|
||||
LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `bool`
|
||||
--> $DIR/non-integer-atomic.rs:20:5
|
||||
|
|
||||
LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
|
||||
--> $DIR/non-integer-atomic.rs:65:5
|
||||
|
|
||||
LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
|
||||
--> $DIR/non-integer-atomic.rs:75:5
|
||||
|
|
||||
LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `bool`
|
||||
--> $DIR/non-integer-atomic.rs:15:5
|
||||
|
|
||||
LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `bool`
|
||||
--> $DIR/non-integer-atomic.rs:30:5
|
||||
|
|
||||
LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `Foo`
|
||||
--> $DIR/non-integer-atomic.rs:50:5
|
||||
|
|
||||
LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `Foo`
|
||||
--> $DIR/non-integer-atomic.rs:45:5
|
||||
|
|
||||
LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `bool`
|
||||
--> $DIR/non-integer-atomic.rs:25:5
|
||||
|
|
||||
LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0511`.
|
||||
|
||||
Reference in New Issue
Block a user