1
- #![ feature( rustc_private) ]
1
+ #![ feature( rustc_private, once_cell ) ]
2
2
3
3
extern crate rustc_data_structures;
4
4
extern crate rustc_driver;
5
5
extern crate rustc_interface;
6
6
extern crate rustc_session;
7
7
extern crate rustc_target;
8
8
9
+ use std:: panic;
10
+ use std:: lazy:: SyncLazy ;
11
+
9
12
use rustc_data_structures:: profiling:: { get_resident_set_size, print_time_passes_entry} ;
10
13
use rustc_interface:: interface;
11
14
use rustc_session:: config:: ErrorOutputType ;
12
15
use rustc_session:: early_error;
13
16
use rustc_target:: spec:: PanicStrategy ;
14
17
18
+ const BUG_REPORT_URL : & str = "https://github.com/bjorn3/rustc_codegen_cranelift/issues/new" ;
19
+
20
+ static DEFAULT_HOOK : SyncLazy < Box < dyn Fn ( & panic:: PanicInfo < ' _ > ) + Sync + Send + ' static > > =
21
+ SyncLazy :: new ( || {
22
+ let hook = panic:: take_hook ( ) ;
23
+ panic:: set_hook ( Box :: new ( |info| {
24
+ // Invoke the default handler, which prints the actual panic message and optionally a backtrace
25
+ ( * DEFAULT_HOOK ) ( info) ;
26
+
27
+ // Separate the output with an empty line
28
+ eprintln ! ( ) ;
29
+
30
+ // Print the ICE message
31
+ rustc_driver:: report_ice ( info, BUG_REPORT_URL ) ;
32
+ } ) ) ;
33
+ hook
34
+ } ) ;
35
+
15
36
#[ derive( Default ) ]
16
37
pub struct CraneliftPassesCallbacks {
17
38
time_passes : bool ,
@@ -37,7 +58,7 @@ fn main() {
37
58
let start_rss = get_resident_set_size ( ) ;
38
59
rustc_driver:: init_rustc_env_logger ( ) ;
39
60
let mut callbacks = CraneliftPassesCallbacks :: default ( ) ;
40
- rustc_driver :: install_ice_hook ( ) ;
61
+ SyncLazy :: force ( & DEFAULT_HOOK ) ; // Install ice hook
41
62
let exit_code = rustc_driver:: catch_with_exit_code ( || {
42
63
let args = std:: env:: args_os ( )
43
64
. enumerate ( )
0 commit comments