Ensure that crates are linked with compatible panic-in-drop settings
This commit is contained in:
parent
007bd17a68
commit
a149bed3bd
5 changed files with 30 additions and 9 deletions
|
@ -400,12 +400,12 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) {
|
|||
continue;
|
||||
}
|
||||
let cnum = CrateNum::new(i + 1);
|
||||
let found_strategy = tcx.panic_strategy(cnum);
|
||||
let is_compiler_builtins = tcx.is_compiler_builtins(cnum);
|
||||
if is_compiler_builtins || desired_strategy == found_strategy {
|
||||
if tcx.is_compiler_builtins(cnum) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let found_strategy = tcx.panic_strategy(cnum);
|
||||
if desired_strategy != found_strategy {
|
||||
sess.err(&format!(
|
||||
"the crate `{}` is compiled with the \
|
||||
panic strategy `{}` which is \
|
||||
|
@ -416,5 +416,19 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) {
|
|||
desired_strategy.desc()
|
||||
));
|
||||
}
|
||||
|
||||
let found_drop_strategy = tcx.panic_in_drop_strategy(cnum);
|
||||
if tcx.sess.opts.debugging_opts.panic_in_drop != found_drop_strategy {
|
||||
sess.err(&format!(
|
||||
"the crate `{}` is compiled with the \
|
||||
panic-in-drop strategy `{}` which is \
|
||||
incompatible with this crate's \
|
||||
strategy of `{}`",
|
||||
tcx.crate_name(cnum),
|
||||
found_drop_strategy.desc(),
|
||||
tcx.sess.opts.debugging_opts.panic_in_drop.desc()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,6 +160,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
has_panic_handler => { cdata.root.has_panic_handler }
|
||||
is_profiler_runtime => { cdata.root.profiler_runtime }
|
||||
panic_strategy => { cdata.root.panic_strategy }
|
||||
panic_in_drop_strategy => { cdata.root.panic_in_drop_strategy }
|
||||
extern_crate => {
|
||||
let r = *cdata.extern_crate.lock();
|
||||
r.map(|c| &*tcx.arena.alloc(c))
|
||||
|
|
|
@ -691,6 +691,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
hash: tcx.crate_hash(LOCAL_CRATE),
|
||||
stable_crate_id: tcx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(),
|
||||
panic_strategy: tcx.sess.panic_strategy(),
|
||||
panic_in_drop_strategy: tcx.sess.opts.debugging_opts.panic_in_drop,
|
||||
edition: tcx.sess.edition(),
|
||||
has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE),
|
||||
has_panic_handler: tcx.has_panic_handler(LOCAL_CRATE),
|
||||
|
|
|
@ -204,6 +204,7 @@ crate struct CrateRoot<'tcx> {
|
|||
hash: Svh,
|
||||
stable_crate_id: StableCrateId,
|
||||
panic_strategy: PanicStrategy,
|
||||
panic_in_drop_strategy: PanicStrategy,
|
||||
edition: Edition,
|
||||
has_global_allocator: bool,
|
||||
has_panic_handler: bool,
|
||||
|
|
|
@ -1159,6 +1159,10 @@ rustc_queries! {
|
|||
fatal_cycle
|
||||
desc { "query a crate's configured panic strategy" }
|
||||
}
|
||||
query panic_in_drop_strategy(_: CrateNum) -> PanicStrategy {
|
||||
fatal_cycle
|
||||
desc { "query a crate's configured panic-in-drop strategy" }
|
||||
}
|
||||
query is_no_builtins(_: CrateNum) -> bool {
|
||||
fatal_cycle
|
||||
desc { "test whether a crate has `#![no_builtins]`" }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue