diff options
| author | WANG Rui <wangrui@loongson.cn> | 2023-12-14 22:07:53 +0800 |
|---|---|---|
| committer | WANG Rui <wangrui@loongson.cn> | 2024-01-16 19:15:06 +0800 |
| commit | 06a41687b160cbb4cbf8fce0b3ad3a2e352e8338 (patch) | |
| tree | bdc2ea95832dbff1c740b08d7510048df8536fb8 /tests/codegen | |
| parent | 94807670a6a3834cc9b71b0b803d49d307c9ba5d (diff) | |
| download | rust-06a41687b160cbb4cbf8fce0b3ad3a2e352e8338.tar.gz rust-06a41687b160cbb4cbf8fce0b3ad3a2e352e8338.zip | |
Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/direct-access-external-data.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/codegen/direct-access-external-data.rs b/tests/codegen/direct-access-external-data.rs new file mode 100644 index 00000000000..ec4bfc33518 --- /dev/null +++ b/tests/codegen/direct-access-external-data.rs @@ -0,0 +1,21 @@ +// only-loongarch64-unknown-linux-gnu + +// revisions: DEFAULT DIRECT INDIRECT +// [DEFAULT] compile-flags: -C relocation-model=static +// [DIRECT] compile-flags: -C relocation-model=static -Z direct-access-external-data=yes +// [INDIRECT] compile-flags: -C relocation-model=static -Z direct-access-external-data=no + +#![crate_type = "rlib"] + +// DEFAULT: @VAR = external {{.*}} global i32 +// DIRECT: @VAR = external dso_local {{.*}} global i32 +// INDIRECT: @VAR = external {{.*}} global i32 + +extern "C" { + static VAR: i32; +} + +#[no_mangle] +pub fn get() -> i32 { + unsafe { VAR } +} |
