about summary refs log tree commit diff
path: root/tests/ui/linkage-attr
diff options
context:
space:
mode:
authorMads Marquart <mads@marquart.dk>2024-05-27 15:17:18 +0200
committerMads Marquart <mads@marquart.dk>2024-05-28 12:31:33 +0200
commite6b9bb7b7200c69b82fd69572a7c0a03ead3d60f (patch)
tree3aaea213cf11a4b4a48ddde3e7385cc4bfe9f11d /tests/ui/linkage-attr
parent37ae2b68b1631a5f2cb7d2b2f6478acba654d651 (diff)
downloadrust-e6b9bb7b7200c69b82fd69572a7c0a03ead3d60f.tar.gz
rust-e6b9bb7b7200c69b82fd69572a7c0a03ead3d60f.zip
Make more of the test suite run on Mac Catalyst
This adds the `only-apple`/`ignore-apple` compiletest directive, and
uses that basically everywhere instead of `only-macos`/`ignore-macos`.

Some of the updates in `run-make` are a bit redundant, as they use
`ignore-cross-compile` and won't run on iOS - but using Apple in these
is still more correct, so I've made that change anyhow.
Diffstat (limited to 'tests/ui/linkage-attr')
-rw-r--r--tests/ui/linkage-attr/framework.rs2
-rw-r--r--tests/ui/linkage-attr/kind-framework.rs7
-rw-r--r--tests/ui/linkage-attr/kind-framework.stderr9
-rw-r--r--tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs29
-rw-r--r--tests/ui/linkage-attr/linkage1.rs2
-rw-r--r--tests/ui/linkage-attr/propagate-generic-issue-18804/auxiliary/lib.rs10
-rw-r--r--tests/ui/linkage-attr/propagate-generic-issue-18804/main.rs18
7 files changed, 75 insertions, 2 deletions
diff --git a/tests/ui/linkage-attr/framework.rs b/tests/ui/linkage-attr/framework.rs
index 824adf62206..08f4394db21 100644
--- a/tests/ui/linkage-attr/framework.rs
+++ b/tests/ui/linkage-attr/framework.rs
@@ -1,5 +1,5 @@
 // Check that linking frameworks on Apple platforms works.
-//@ only-macos
+//@ only-apple
 //@ revisions: omit link weak both
 //@ [omit]build-fail
 //@ [link]run-pass
diff --git a/tests/ui/linkage-attr/kind-framework.rs b/tests/ui/linkage-attr/kind-framework.rs
new file mode 100644
index 00000000000..c2f90809e03
--- /dev/null
+++ b/tests/ui/linkage-attr/kind-framework.rs
@@ -0,0 +1,7 @@
+//@ ignore-apple this is supposed to succeed on Apple platforms (though it won't necessarily link)
+
+#[link(name = "foo", kind = "framework")]
+extern "C" {}
+//~^^ ERROR: link kind `framework` is only supported on Apple targets
+
+fn main() {}
diff --git a/tests/ui/linkage-attr/kind-framework.stderr b/tests/ui/linkage-attr/kind-framework.stderr
new file mode 100644
index 00000000000..93dacd68e29
--- /dev/null
+++ b/tests/ui/linkage-attr/kind-framework.stderr
@@ -0,0 +1,9 @@
+error[E0455]: link kind `framework` is only supported on Apple targets
+  --> $DIR/kind-framework.rs:3:29
+   |
+LL | #[link(name = "foo", kind = "framework")]
+   |                             ^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0455`.
diff --git a/tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs b/tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs
new file mode 100644
index 00000000000..a169997927e
--- /dev/null
+++ b/tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs
@@ -0,0 +1,29 @@
+//@ run-pass
+//@ ignore-windows
+//@ ignore-apple
+//@ ignore-wasm32 common linkage not implemented right now
+
+#![feature(linkage)]
+
+#[linkage = "external"]
+pub static TEST2: bool = true;
+
+#[linkage = "internal"]
+pub static TEST3: bool = true;
+
+#[linkage = "linkonce"]
+pub static TEST4: bool = true;
+
+#[linkage = "linkonce_odr"]
+pub static TEST5: bool = true;
+
+#[linkage = "private"]
+pub static TEST6: bool = true;
+
+#[linkage = "weak"]
+pub static TEST7: bool = true;
+
+#[linkage = "weak_odr"]
+pub static TEST8: bool = true;
+
+fn main() {}
diff --git a/tests/ui/linkage-attr/linkage1.rs b/tests/ui/linkage-attr/linkage1.rs
index 2edb80bf1b0..19bf601d9d2 100644
--- a/tests/ui/linkage-attr/linkage1.rs
+++ b/tests/ui/linkage-attr/linkage1.rs
@@ -1,6 +1,6 @@
 //@ run-pass
 //@ ignore-windows
-//@ ignore-macos
+//@ ignore-apple
 //@ ignore-emscripten doesn't support this linkage
 //@ ignore-sgx weak linkage not permitted
 //@ aux-build:linkage1.rs
diff --git a/tests/ui/linkage-attr/propagate-generic-issue-18804/auxiliary/lib.rs b/tests/ui/linkage-attr/propagate-generic-issue-18804/auxiliary/lib.rs
new file mode 100644
index 00000000000..e29d48285d8
--- /dev/null
+++ b/tests/ui/linkage-attr/propagate-generic-issue-18804/auxiliary/lib.rs
@@ -0,0 +1,10 @@
+#![crate_type = "rlib"]
+#![feature(linkage)]
+
+pub fn foo<T>() -> *const () {
+    extern "C" {
+        #[linkage = "extern_weak"]
+        static FOO: *const ();
+    }
+    unsafe { FOO }
+}
diff --git a/tests/ui/linkage-attr/propagate-generic-issue-18804/main.rs b/tests/ui/linkage-attr/propagate-generic-issue-18804/main.rs
new file mode 100644
index 00000000000..56a9358cce3
--- /dev/null
+++ b/tests/ui/linkage-attr/propagate-generic-issue-18804/main.rs
@@ -0,0 +1,18 @@
+//@ run-pass
+// Test for issue #18804, #[linkage] does not propagate through generic
+// functions. Failure results in a linker error.
+
+//@ ignore-emscripten no weak symbol support
+//@ ignore-windows no extern_weak linkage
+//@ ignore-apple no extern_weak linkage
+
+//@ aux-build:lib.rs
+
+// rust-lang/rust#56772: nikic says we need this to be proper test.
+//@ compile-flags: -C no-prepopulate-passes -C passes=name-anon-globals
+
+extern crate lib;
+
+fn main() {
+    lib::foo::<i32>();
+}