forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes rust-lang#108030. This issue has been resolved in LLVM 17.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include ../tools.mk | ||
|
||
# only-x86_64-unknown-linux-gnu | ||
|
||
all: | ||
$(RUSTC) -Clinker-plugin-lto -Cdebuginfo=0 -Copt-level=2 lib.rs | ||
$(RUSTC) -Clto -Cdebuginfo=0 -Copt-level=2 main.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#![crate_type = "lib"] | ||
|
||
#[macro_export] | ||
macro_rules! asm_func { | ||
($name:expr, $body:expr $(, $($args:tt)*)?) => { | ||
core::arch::global_asm!( | ||
concat!( | ||
".p2align 4\n", | ||
".hidden ", $name, "\n", | ||
".global ", $name, "\n", | ||
".type ", $name, ",@function\n", | ||
$name, ":\n", | ||
$body, | ||
".size ", $name, ",.-", $name, | ||
) | ||
$(, $($args)*)? | ||
); | ||
}; | ||
} | ||
|
||
macro_rules! libcall_trampoline { | ||
($libcall:ident ; $libcall_impl:ident) => { | ||
asm_func!( | ||
stringify!($libcall), | ||
concat!( | ||
" | ||
.cfi_startproc simple | ||
.cfi_def_cfa_offset 0 | ||
jmp {} | ||
.cfi_endproc | ||
", | ||
), | ||
sym $libcall_impl | ||
); | ||
}; | ||
} | ||
|
||
pub mod trampolines { | ||
extern "C" { | ||
pub fn table_fill_funcref(); | ||
pub fn table_fill_externref(); | ||
} | ||
|
||
unsafe extern "C" fn impl_table_fill_funcref() {} | ||
unsafe extern "C" fn impl_table_fill_externref() {} | ||
|
||
libcall_trampoline!(table_fill_funcref ; impl_table_fill_funcref); | ||
libcall_trampoline!(table_fill_externref ; impl_table_fill_externref); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extern crate lib; | ||
|
||
use lib::trampolines::*; | ||
|
||
fn main() { | ||
unsafe { | ||
table_fill_externref(); | ||
table_fill_funcref(); | ||
} | ||
} |