about summary refs log tree commit diff
path: root/src/test/ui/feature-gates
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-06 03:59:17 +0000
committerbors <bors@rust-lang.org>2021-06-06 03:59:17 +0000
commit9a576175cc9a0aecb85d0764a4f66ee29e26e155 (patch)
treea154cec601fdf15e22d503c1b62f8111782d1677 /src/test/ui/feature-gates
parentf434217aab9abf583ebc928b97ab4116921137aa (diff)
parent6aa45b71b11823a3140736536a93c5eac11ceecb (diff)
downloadrust-9a576175cc9a0aecb85d0764a4f66ee29e26e155.tar.gz
rust-9a576175cc9a0aecb85d0764a4f66ee29e26e155.zip
Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkov
Partial support for raw-dylib linkage

First cut of functionality for issue #58713: add support for `#[link(kind = "raw-dylib")]` on `extern` blocks in lib crates compiled to .rlib files.  Does not yet support `#[link_name]` attributes on functions, or the `#[link_ordinal]` attribute, or `#[link(kind = "raw-dylib")]` on `extern` blocks in bin crates; I intend to publish subsequent PRs to fill those gaps.  It's also not yet clear whether this works for functions in `extern "stdcall"` blocks; I also intend to investigate that shortly and make any necessary changes as a follow-on PR.

This implementation calls out to an LLVM function to construct the actual `.idata` sections as temporary `.lib` files on disk and then links those into the generated .rlib.
Diffstat (limited to 'src/test/ui/feature-gates')
-rw-r--r--src/test/ui/feature-gates/feature-gate-raw-dylib-2.rs8
-rw-r--r--src/test/ui/feature-gates/feature-gate-raw-dylib-2.stderr12
-rw-r--r--src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs8
-rw-r--r--src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr18
-rw-r--r--src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.rs7
-rw-r--r--src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.stderr12
6 files changed, 65 insertions, 0 deletions
diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-2.rs b/src/test/ui/feature-gates/feature-gate-raw-dylib-2.rs
new file mode 100644
index 00000000000..518aa20dd68
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-raw-dylib-2.rs
@@ -0,0 +1,8 @@
+#[link(name = "foo")]
+extern "C" {
+    #[link_ordinal(42)]
+    //~^ ERROR: the `#[link_ordinal]` attribute is an experimental feature
+    fn foo();
+}
+
+fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-2.stderr b/src/test/ui/feature-gates/feature-gate-raw-dylib-2.stderr
new file mode 100644
index 00000000000..dbee5f316b0
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-raw-dylib-2.stderr
@@ -0,0 +1,12 @@
+error[E0658]: the `#[link_ordinal]` attribute is an experimental feature
+  --> $DIR/feature-gate-raw-dylib-2.rs:3:5
+   |
+LL |     #[link_ordinal(42)]
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
+   = help: add `#![feature(raw_dylib)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs
new file mode 100644
index 00000000000..33f9c539313
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs
@@ -0,0 +1,8 @@
+// gate-test-raw_dylib
+// only-windows-gnu
+#[link(name = "foo", kind = "raw-dylib")]
+//~^ ERROR: kind="raw-dylib" is unstable
+//~| WARNING: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu
+extern "C" {}
+
+fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr
new file mode 100644
index 00000000000..14dfadf4126
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr
@@ -0,0 +1,18 @@
+warning: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu
+  --> $DIR/feature-gate-raw-dylib-windows-gnu.rs:3:1
+   |
+LL | #[link(name = "foo", kind = "raw-dylib")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0658]: kind="raw-dylib" is unstable
+  --> $DIR/feature-gate-raw-dylib-windows-gnu.rs:3:1
+   |
+LL | #[link(name = "foo", kind = "raw-dylib")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
+   = help: add `#![feature(raw_dylib)]` to the crate attributes to enable
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.rs b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.rs
new file mode 100644
index 00000000000..49de24ea9ab
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.rs
@@ -0,0 +1,7 @@
+// gate-test-raw_dylib
+// only-windows-msvc
+#[link(name = "foo", kind = "raw-dylib")]
+//~^ ERROR: kind="raw-dylib" is unstable
+extern "C" {}
+
+fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.stderr b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.stderr
new file mode 100644
index 00000000000..11988080812
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-raw-dylib-windows-msvc.stderr
@@ -0,0 +1,12 @@
+error[E0658]: kind="raw-dylib" is unstable
+  --> $DIR/feature-gate-raw-dylib-windows-msvc.rs:3:1
+   |
+LL | #[link(name = "foo", kind = "raw-dylib")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
+   = help: add `#![feature(raw_dylib)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.