LoongArch: Fix direct-access-external-data test
On LoongArch targets, `-Cdirect-access-external-data` defaults to `no`. Since copy relocations are not supported, `dso_local` is not emitted under `-Crelocation-model=static`, unlike on other targets.
This commit is contained in:
parent
63f4513795
commit
e3f198ec05
2 changed files with 48 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
//@ ignore-loongarch64 (handles dso_local differently)
|
||||
//@ ignore-powerpc64 (handles dso_local differently)
|
||||
//@ ignore-apple (handles dso_local differently)
|
||||
|
||||
|
|
|
|||
47
tests/codegen-llvm/loongarch/direct-access-external-data.rs
Normal file
47
tests/codegen-llvm/loongarch/direct-access-external-data.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//@ only-loongarch64
|
||||
|
||||
//@ revisions: DEFAULT PIE DIRECT INDIRECT
|
||||
//@ [DEFAULT] compile-flags: -C relocation-model=static
|
||||
//@ [PIE] compile-flags: -C relocation-model=pie
|
||||
//@ [DIRECT] compile-flags: -C relocation-model=pie -Z direct-access-external-data=yes
|
||||
//@ [INDIRECT] compile-flags: -C relocation-model=static -Z direct-access-external-data=no
|
||||
|
||||
#![crate_type = "rlib"]
|
||||
#![feature(linkage)]
|
||||
|
||||
unsafe extern "C" {
|
||||
// CHECK: @VAR = external
|
||||
// DEFAULT-NOT: dso_local
|
||||
// PIE-NOT: dso_local
|
||||
// DIRECT-SAME: dso_local
|
||||
// INDIRECT-NOT: dso_local
|
||||
// CHECK-SAME: global i32
|
||||
safe static VAR: i32;
|
||||
|
||||
// When "linkage" is used, we generate an indirection global.
|
||||
// Check dso_local is still applied to the actual global.
|
||||
// CHECK: @EXTERNAL = external
|
||||
// DEFAULT-NOT: dso_local
|
||||
// PIE-NOT: dso_local
|
||||
// DIRECT-SAME: dso_local
|
||||
// INDIRECT-NOT: dso_local
|
||||
// CHECK-SAME: global i8
|
||||
#[linkage = "external"]
|
||||
safe static EXTERNAL: *const u32;
|
||||
|
||||
// CHECK: @WEAK = extern_weak
|
||||
// DEFAULT-NOT: dso_local
|
||||
// PIE-NOT: dso_local
|
||||
// DIRECT-SAME: dso_local
|
||||
// INDIRECT-NOT: dso_local
|
||||
// CHECK-SAME: global i8
|
||||
#[linkage = "extern_weak"]
|
||||
safe static WEAK: *const u32;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn refer() {
|
||||
core::hint::black_box(VAR);
|
||||
core::hint::black_box(EXTERNAL);
|
||||
core::hint::black_box(WEAK);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue