Skip to content

Commit 4e9f23f

Browse files
authored
Add no_mangle to lang items. (#46)
1 parent 4cfd38a commit 4e9f23f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
6565
// This translates into an `unreachable` instruction that will
6666
// raise a `trap` the WebAssembly execution if we panic at runtime.
6767
#[panic_implementation]
68-
fn panic(_info: &::core::panic::PanicInfo) -> ! {
68+
#[no_mangle]
69+
pub fn panic(_info: &::core::panic::PanicInfo) -> ! {
6970
unsafe {
7071
::core::intrinsics::abort();
7172
}
@@ -74,7 +75,8 @@ fn panic(_info: &::core::panic::PanicInfo) -> ! {
7475
// Need to provide a tiny `oom` lang-item implementation for
7576
// `#![no_std]`.
7677
#[lang = "oom"]
77-
extern "C" fn oom() -> ! {
78+
#[no_mangle]
79+
pub extern "C" fn oom() -> ! {
7880
unsafe {
7981
::core::intrinsics::abort();
8082
}

example/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
1919
// This translates into an `unreachable` instruction that will
2020
// raise a `trap` the WebAssembly execution if we panic at runtime.
2121
#[panic_implementation]
22-
fn panic(_info: &::core::panic::PanicInfo) -> ! {
22+
#[no_mangle]
23+
pub fn panic(_info: &::core::panic::PanicInfo) -> ! {
2324
unsafe {
2425
::core::intrinsics::abort();
2526
}
@@ -28,14 +29,16 @@ fn panic(_info: &::core::panic::PanicInfo) -> ! {
2829
// Need to provide a tiny `oom` lang-item implementation for
2930
// `#![no_std]`.
3031
#[lang = "oom"]
31-
extern "C" fn oom() -> ! {
32+
#[no_mangle]
33+
pub extern "C" fn oom() -> ! {
3234
unsafe {
3335
::core::intrinsics::abort();
3436
}
3537
}
3638

3739
// Needed for non-wasm targets.
3840
#[lang = "eh_personality"]
41+
#[no_mangle]
3942
pub extern "C" fn eh_personality() {}
4043

4144
// Now, use the allocator via `alloc` types! ///////////////////////////////////

wee_alloc/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
6565
// This translates into an `unreachable` instruction that will
6666
// raise a `trap` the WebAssembly execution if we panic at runtime.
6767
#[panic_implementation]
68-
fn panic(_info: &::core::panic::PanicInfo) -> ! {
68+
#[no_mangle]
69+
pub fn panic(_info: &::core::panic::PanicInfo) -> ! {
6970
unsafe {
7071
::core::intrinsics::abort();
7172
}
@@ -74,7 +75,8 @@ fn panic(_info: &::core::panic::PanicInfo) -> ! {
7475
// Need to provide a tiny `oom` lang-item implementation for
7576
// `#![no_std]`.
7677
#[lang = "oom"]
77-
extern "C" fn oom() -> ! {
78+
#[no_mangle]
79+
pub extern "C" fn oom() -> ! {
7880
unsafe {
7981
::core::intrinsics::abort();
8082
}

0 commit comments

Comments
 (0)