@@ -55,7 +55,13 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
55
55
// provided by libstd.
56
56
#[lang = "eh_personality"]
57
57
#[no_mangle]
58
- pub extern fn eh_personality() {
58
+ pub extern fn rust_eh_personality() {
59
+ }
60
+
61
+ // This function may be needed based on the compilation target.
62
+ #[lang = "eh_unwind_resume"]
63
+ #[no_mangle]
64
+ pub extern fn rust_eh_unwind_resume() {
59
65
}
60
66
61
67
#[lang = "panic_fmt"]
@@ -87,12 +93,18 @@ pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
87
93
0
88
94
}
89
95
90
- // These functions and traits are used by the compiler, but not
96
+ // These functions are used by the compiler, but not
91
97
// for a bare-bones hello world. These are normally
92
98
// provided by libstd.
93
99
#[lang = "eh_personality"]
94
100
#[no_mangle]
95
- pub extern fn eh_personality() {
101
+ pub extern fn rust_eh_personality() {
102
+ }
103
+
104
+ // This function may be needed based on the compilation target.
105
+ #[lang = "eh_unwind_resume"]
106
+ #[no_mangle]
107
+ pub extern fn rust_eh_unwind_resume() {
96
108
}
97
109
98
110
#[lang = "panic_fmt"]
@@ -104,23 +116,28 @@ pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
104
116
}
105
117
```
106
118
107
- ## More about the langauge items
119
+ ## More about the language items
108
120
109
121
The compiler currently makes a few assumptions about symbols which are
110
122
available in the executable to call. Normally these functions are provided by
111
123
the standard library, but without it you must define your own. These symbols
112
124
are called "language items", and they each have an internal name, and then a
113
125
signature that an implementation must conform to.
114
126
115
- The first of these two functions, ` eh_personality ` , is used by the failure
127
+ The first of these functions, ` rust_eh_personality ` , is used by the failure
116
128
mechanisms of the compiler. This is often mapped to GCC's personality function
117
129
(see the [ libstd implementation] [ unwind ] for more information), but crates
118
130
which do not trigger a panic can be assured that this function is never
119
- called. Both the language item and the symbol name are ` eh_personality ` .
120
-
131
+ called. The language item's name is ` eh_personality ` .
132
+
121
133
[ unwind ] : https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs
122
134
123
- The second function, ` panic_fmt ` , is also used by the failure mechanisms of the
135
+ The second function, ` rust_begin_panic ` , is also used by the failure mechanisms of the
124
136
compiler. When a panic happens, this controls the message that's displayed on
125
137
the screen. While the language item's name is ` panic_fmt ` , the symbol name is
126
138
` rust_begin_panic ` .
139
+
140
+ A third function, ` rust_eh_unwind_resume ` , is also needed if the ` custom_unwind_resume `
141
+ flag is set in the options of the compilation target. It allows customizing the
142
+ process of resuming unwind at the end of the landing pads. The language item's name
143
+ is ` eh_unwind_resume ` .
0 commit comments