]> git.proxmox.com Git - rustc.git/blob - tests/ui/lto/issue-105637.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / lto / issue-105637.rs
1 // Regression test for issue #105637: `-Zdylib-lto` with LTO duplicated symbols from other dylibs,
2 // in this case from libstd.
3 //
4 // That manifested as both `rustc_driver` and rustc's "main" (`compiler/rustc`) having their own
5 // `std::panicking::HOOK` static, and the hook in rustc's main (the default stdlib's) being executed
6 // when rustc ICEs, instead of the overriden hook from `rustc_driver` (which also displays the query
7 // stack and information on how to open a GH issue for the encountered ICE).
8 //
9 // In this test, we reproduce this setup by installing a panic hook in both the main and an LTOed
10 // dylib: the last hook set should be the one being executed, the dylib's.
11
12 // aux-build: thinlto-dylib.rs
13 // run-fail
14 // check-run-results
15
16 extern crate thinlto_dylib;
17
18 use std::panic;
19
20 fn main() {
21 // We don't want to see this panic hook executed
22 std::panic::set_hook(Box::new(|_| {
23 eprintln!("main crate panic hook");
24 }));
25
26 // Have the LTOed dylib install its own hook and panic, we want to see its hook executed.
27 thinlto_dylib::main();
28 }