File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ // Auxiliary crate for test issue-105637: the LTOed dylib which had duplicate symbols from libstd,
2+ // breaking the panic hook feature.
3+ //
4+ // This simulates the `rustc_driver` crate, and the main crate simulates rustc's main binary hooking
5+ // into this driver.
6+
7+ // compile-flags: -Zdylib-lto -C lto=thin
8+
9+ use std:: panic;
10+
11+ pub fn main ( ) {
12+ // Install the hook we want to see executed
13+ panic:: set_hook ( Box :: new ( |_| {
14+ eprintln ! ( "LTOed auxiliary crate panic hook" ) ;
15+ } ) ) ;
16+
17+ // Trigger the panic hook with an ICE
18+ run_compiler ( ) ;
19+ }
20+
21+ fn run_compiler ( ) {
22+ panic ! ( "ICEing" ) ;
23+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ LTOed auxiliary crate panic hook
You can’t perform that action at this time.
0 commit comments