Skip to content

Commit 3e85195

Browse files
authored
Mark panic_fmt as no_mangle to work around rust-lang/rust#38281 (#262)
1 parent 61d1f57 commit 3e85195

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

โ€Žblog/post/03-set-up-rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Now we place our root source file in `src/lib.rs`:
5757
pub extern fn rust_main() {}
5858

5959
#[lang = "eh_personality"] extern fn eh_personality() {}
60-
#[lang = "panic_fmt"] extern fn panic_fmt() -> ! {loop{}}
60+
#[lang = "panic_fmt"] #[no_mangle] extern fn panic_fmt() -> ! {loop{}}
6161
```
6262
Let's break it down:
6363

โ€Žblog/post/05-allocating-frames.md

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ We used `expect` in the code above, which will panic if there is no memory map t
103103

104104
```rust
105105
#[lang = "panic_fmt"]
106+
#[no_mangle]
106107
extern fn panic_fmt() -> ! {
107108
println!("PANIC");
108109
loop{}
@@ -112,6 +113,7 @@ Now we get a `PANIC` message. But we can do even better. The `panic_fmt` functio
112113

113114
```rust
114115
#[lang = "panic_fmt"]
116+
#[no_mangle]
115117
extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str,
116118
line: u32) -> !
117119
{

โ€Žsrc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ extern "C" fn eh_personality() {}
8686

8787
#[cfg(not(test))]
8888
#[lang = "panic_fmt"]
89+
#[no_mangle]
8990
extern "C" fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
9091
println!("\n\nPANIC in {} at line {}:", file, line);
9192
println!(" {}", fmt);

0 commit comments

Comments
ย (0)