about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorGuillaume Boisseau <Nadrieril@users.noreply.github.com>2024-02-07 18:24:41 +0100
committerGitHub <noreply@github.com>2024-02-07 18:24:41 +0100
commit7954c28cf932c00cd331598f189145861bf42b7c (patch)
treedf496eace289812572b543e7263dd971237b5a53 /tests/codegen
parent6931780f40c92291eaceec42f09069515390bb17 (diff)
parent06a41687b160cbb4cbf8fce0b3ad3a2e352e8338 (diff)
downloadrust-7954c28cf932c00cd331598f189145861bf42b7c.tar.gz
rust-7954c28cf932c00cd331598f189145861bf42b7c.zip
Rollup merge of #119162 - heiher:direct-access-external-data, r=petrochenkov
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

Fixes #118053
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/direct-access-external-data.rs21
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 }
+}