Skip to content

Commit

Permalink
Rollup merge of rust-lang#115757 - DianQK:lto-linkage-used-attr, r=we…
Browse files Browse the repository at this point in the history
…sleywiser

Add a test for rust-lang#108030

Closes rust-lang#108030.

This issue has been resolved in LLVM 17. I can verify that this test fails on 63a81b0.

r? compiler
  • Loading branch information
matthiaskrgr authored Sep 11, 2023
2 parents 2a087be + b99ace4 commit 48a1033
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/run-make/lto-linkage-used-attr/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include ../tools.mk

# Verify that the impl_* symbols are preserved. #108030
# only-x86_64-unknown-linux-gnu
# min-llvm-version: 17

all:
$(RUSTC) -Cdebuginfo=0 -Copt-level=3 lib.rs
$(RUSTC) -Clto=fat -Cdebuginfo=0 -Copt-level=3 main.rs
50 changes: 50 additions & 0 deletions tests/run-make/lto-linkage-used-attr/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#![crate_type = "rlib"]
#![crate_type = "cdylib"]

#[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);
}
10 changes: 10 additions & 0 deletions tests/run-make/lto-linkage-used-attr/main.rs
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();
}
}

0 comments on commit 48a1033

Please sign in to comment.