Skip to content

Commit 5642f6b

Browse files
committed
Add a test for rust-lang#108030
Closes rust-lang#108030. This issue has been resolved in LLVM 17.
1 parent e39976f commit 5642f6b

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include ../tools.mk
2+
3+
# only-x86_64-unknown-linux-gnu
4+
5+
all:
6+
$(RUSTC) -Clinker-plugin-lto -Cdebuginfo=0 -Copt-level=2 lib.rs
7+
$(RUSTC) -Clto -Cdebuginfo=0 -Copt-level=2 main.rs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#![crate_type = "lib"]
2+
3+
#[macro_export]
4+
macro_rules! asm_func {
5+
($name:expr, $body:expr $(, $($args:tt)*)?) => {
6+
core::arch::global_asm!(
7+
concat!(
8+
".p2align 4\n",
9+
".hidden ", $name, "\n",
10+
".global ", $name, "\n",
11+
".type ", $name, ",@function\n",
12+
$name, ":\n",
13+
$body,
14+
".size ", $name, ",.-", $name,
15+
)
16+
$(, $($args)*)?
17+
);
18+
};
19+
}
20+
21+
macro_rules! libcall_trampoline {
22+
($libcall:ident ; $libcall_impl:ident) => {
23+
asm_func!(
24+
stringify!($libcall),
25+
concat!(
26+
"
27+
.cfi_startproc simple
28+
.cfi_def_cfa_offset 0
29+
jmp {}
30+
.cfi_endproc
31+
",
32+
),
33+
sym $libcall_impl
34+
);
35+
};
36+
}
37+
38+
pub mod trampolines {
39+
extern "C" {
40+
pub fn table_fill_funcref();
41+
pub fn table_fill_externref();
42+
}
43+
44+
unsafe extern "C" fn impl_table_fill_funcref() {}
45+
unsafe extern "C" fn impl_table_fill_externref() {}
46+
47+
libcall_trampoline!(table_fill_funcref ; impl_table_fill_funcref);
48+
libcall_trampoline!(table_fill_externref ; impl_table_fill_externref);
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extern crate lib;
2+
3+
use lib::trampolines::*;
4+
5+
fn main() {
6+
unsafe {
7+
table_fill_externref();
8+
table_fill_funcref();
9+
}
10+
}

0 commit comments

Comments
 (0)