Skip to content

Commit c747501

Browse files
committed
Stabilze raw-dylib for non-x86
1 parent 3c72788 commit c747501

File tree

46 files changed

+86
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+86
-231
lines changed

compiler/rustc_feature/src/active.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ declare_features! (
478478
/// Allows macro attributes on expressions, statements and non-inline modules.
479479
(active, proc_macro_hygiene, "1.30.0", Some(54727), None),
480480
/// Allows the use of raw-dylibs (RFC 2627).
481-
(incomplete, raw_dylib, "1.40.0", Some(58713), None),
481+
(active, raw_dylib, "CURRENT_RUSTC_VERSION", Some(58713), None),
482482
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.
483483
(active, raw_ref_op, "1.41.0", Some(64490), None),
484484
/// Allows using the `#[register_tool]` attribute.

compiler/rustc_feature/src/builtin_attrs.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
345345
ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
346346
ungated!(no_mangle, Normal, template!(Word), WarnFollowing, @only_local: true),
347347
ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, @only_local: true),
348+
ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding),
348349

349350
// Limits:
350351
ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
@@ -406,10 +407,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
406407

407408
// Linking:
408409
gated!(naked, Normal, template!(Word), WarnFollowing, @only_local: true, naked_functions, experimental!(naked)),
409-
gated!(
410-
link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding, raw_dylib,
411-
experimental!(link_ordinal)
412-
),
413410

414411
// Plugins:
415412
BuiltinAttribute {

compiler/rustc_metadata/src/native_libs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ impl<'tcx> Collector<'tcx> {
113113
"raw-dylib" => {
114114
if !sess.target.is_like_windows {
115115
sess.emit_err(FrameworkOnlyWindows { span });
116-
} else if !features.raw_dylib {
116+
} else if !features.raw_dylib && sess.target.arch == "x86" {
117117
feature_err(
118118
&sess.parse_sess,
119119
sym::raw_dylib,
120120
span,
121-
"link kind `raw-dylib` is unstable",
121+
"link kind `raw-dylib` is unstable on x86",
122122
)
123123
.emit();
124124
}

compiler/rustc_typeck/src/collect.rs

+9
Original file line numberDiff line numberDiff line change
@@ -3276,6 +3276,15 @@ fn should_inherit_track_caller(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
32763276

32773277
fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
32783278
use rustc_ast::{Lit, LitIntType, LitKind};
3279+
if !tcx.features().raw_dylib && tcx.sess.target.arch == "x86" {
3280+
feature_err(
3281+
&tcx.sess.parse_sess,
3282+
sym::raw_dylib,
3283+
attr.span,
3284+
"`#[link_ordinal]` is unstable on x86",
3285+
)
3286+
.emit();
3287+
}
32793288
let meta_item_list = attr.meta_item_list();
32803289
let meta_item_list: Option<&[ast::NestedMetaItem]> = meta_item_list.as_ref().map(Vec::as_ref);
32813290
let sole_meta_list = match meta_item_list {

src/doc/unstable-book/src/language-features/raw-dylib.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ fn main() {
2626

2727
## Limitations
2828

29-
Currently, this feature is only supported on `-windows-msvc` targets. Non-Windows platforms don't have import
30-
libraries, and an incompatibility between LLVM and the BFD linker means that it is not currently supported on
31-
`-windows-gnu` targets.
29+
This feature is unstable for the `x86` architecture, and stable for all other architectures.
3230

33-
On the `i686-pc-windows-msvc` target, this feature supports only the `cdecl`, `stdcall`, `system`, and `fastcall`
34-
calling conventions.
31+
This feature is only supported on Windows.
32+
33+
On the `x86` architecture, this feature supports only the `cdecl`, `stdcall`, `system`, `fastcall`, and
34+
`vectorcall` calling conventions.

src/test/run-make/raw-dylib-alt-calling-convention/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#![feature(raw_dylib)]
21
#![feature(abi_vectorcall)]
2+
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
33

44
#[repr(C)]
55
#[derive(Clone)]

src/test/run-make/raw-dylib-link-ordinal/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(raw_dylib)]
1+
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
22

33
#[link(name = "exporter", kind = "raw-dylib")]
44
extern {

src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(raw_dylib)]
1+
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
22

33
#[link(name = "exporter", kind = "raw-dylib")]
44
extern "stdcall" {

src/test/ui/feature-gates/feature-gate-raw-dylib-2.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
// only-x86
12
#[link(name = "foo")]
23
extern "C" {
34
#[link_ordinal(42)]
4-
//~^ ERROR: the `#[link_ordinal]` attribute is an experimental feature
5+
//~^ ERROR: `#[link_ordinal]` is unstable on x86
56
fn foo();
67
#[link_ordinal(5)]
7-
//~^ ERROR: the `#[link_ordinal]` attribute is an experimental feature
8+
//~^ ERROR: `#[link_ordinal]` is unstable on x86
89
static mut imported_variable: i32;
910
}
1011

src/test/ui/feature-gates/feature-gate-raw-dylib-2.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
error[E0658]: the `#[link_ordinal]` attribute is an experimental feature
2-
--> $DIR/feature-gate-raw-dylib-2.rs:3:5
1+
error[E0658]: `#[link_ordinal]` is unstable on x86
2+
--> $DIR/feature-gate-raw-dylib-2.rs:4:5
33
|
44
LL | #[link_ordinal(42)]
55
| ^^^^^^^^^^^^^^^^^^^
66
|
77
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
88
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable
99

10-
error[E0658]: the `#[link_ordinal]` attribute is an experimental feature
11-
--> $DIR/feature-gate-raw-dylib-2.rs:6:5
10+
error[E0658]: `#[link_ordinal]` is unstable on x86
11+
--> $DIR/feature-gate-raw-dylib-2.rs:7:5
1212
|
1313
LL | #[link_ordinal(5)]
1414
| ^^^^^^^^^^^^^^^^^^

src/test/ui/feature-gates/feature-gate-raw-dylib-import-name-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// only-windows
22
// only-x86
33
#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
4-
//~^ ERROR link kind `raw-dylib` is unstable
4+
//~^ ERROR link kind `raw-dylib` is unstable on x86
55
//~| ERROR import name type is unstable
66
extern "C" {}
77

src/test/ui/feature-gates/feature-gate-raw-dylib-import-name-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0658]: link kind `raw-dylib` is unstable
1+
error[E0658]: link kind `raw-dylib` is unstable on x86
22
--> $DIR/feature-gate-raw-dylib-import-name-type.rs:3:29
33
|
44
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// only-windows
2+
// only-x86
23
#[link(name = "foo", kind = "raw-dylib")]
3-
//~^ ERROR: link kind `raw-dylib` is unstable
4+
//~^ ERROR: link kind `raw-dylib` is unstable on x86
45
extern "C" {}
56

67
fn main() {}

src/test/ui/feature-gates/feature-gate-raw-dylib.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error[E0658]: link kind `raw-dylib` is unstable
2-
--> $DIR/feature-gate-raw-dylib.rs:2:29
1+
error[E0658]: link kind `raw-dylib` is unstable on x86
2+
--> $DIR/feature-gate-raw-dylib.rs:3:29
33
|
44
LL | #[link(name = "foo", kind = "raw-dylib")]
55
| ^^^^^^^^^^^

src/test/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// only-windows
22
// only-x86
33
#![feature(raw_dylib)]
4-
//~^ WARN the feature `raw_dylib` is incomplete
54

65
#[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
76
//~^ ERROR import name type must be of the form `import_name_type = "string"`
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/import-name-type-invalid-format.rs:3:12
3-
|
4-
LL | #![feature(raw_dylib)]
5-
| ^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
9-
101
error: import name type must be of the form `import_name_type = "string"`
11-
--> $DIR/import-name-type-invalid-format.rs:6:42
2+
--> $DIR/import-name-type-invalid-format.rs:5:42
123
|
134
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
145
| ^^^^^^^^^^^^^^^^^^^^
156

16-
error: aborting due to previous error; 1 warning emitted
7+
error: aborting due to previous error
178

src/test/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// only-windows
33
// only-x86
44
#![feature(raw_dylib)]
5-
//~^ WARN the feature `raw_dylib` is incomplete
65

76
#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
87
//~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/import-name-type-multiple.rs:4:12
3-
|
4-
LL | #![feature(raw_dylib)]
5-
| ^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
9-
101
error: multiple `import_name_type` arguments in a single `#[link]` attribute
11-
--> $DIR/import-name-type-multiple.rs:7:74
2+
--> $DIR/import-name-type-multiple.rs:6:74
123
|
134
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
145
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156

16-
error: aborting due to previous error; 1 warning emitted
7+
error: aborting due to previous error
178

src/test/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// only-windows
22
// only-x86
33
#![feature(raw_dylib)]
4-
//~^ WARN the feature `raw_dylib` is incomplete
54

65
#[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
76
//~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/import-name-type-unknown-value.rs:3:12
3-
|
4-
LL | #![feature(raw_dylib)]
5-
| ^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
9-
101
error: unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated
11-
--> $DIR/import-name-type-unknown-value.rs:6:42
2+
--> $DIR/import-name-type-unknown-value.rs:5:42
123
|
134
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
145
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156

16-
error: aborting due to previous error; 1 warning emitted
7+
error: aborting due to previous error
178

src/test/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// only-windows
22
// only-x86
33
#![feature(raw_dylib)]
4-
//~^ WARN the feature `raw_dylib` is incomplete
54

65
#[link(name = "foo", import_name_type = "decorated")]
76
//~^ ERROR import name type can only be used with link kind `raw-dylib`
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/import-name-type-unsupported-link-kind.rs:3:12
3-
|
4-
LL | #![feature(raw_dylib)]
5-
| ^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
9-
101
error: import name type can only be used with link kind `raw-dylib`
11-
--> $DIR/import-name-type-unsupported-link-kind.rs:6:22
2+
--> $DIR/import-name-type-unsupported-link-kind.rs:5:22
123
|
134
LL | #[link(name = "foo", import_name_type = "decorated")]
145
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156

167
error: import name type can only be used with link kind `raw-dylib`
17-
--> $DIR/import-name-type-unsupported-link-kind.rs:10:39
8+
--> $DIR/import-name-type-unsupported-link-kind.rs:9:39
189
|
1910
LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")]
2011
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2112

22-
error: aborting due to 2 previous errors; 1 warning emitted
13+
error: aborting due to 2 previous errors
2314

src/test/ui/rfc-2627-raw-dylib/import-name-type-x86-only.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// only-windows
22
// ignore-x86
3-
#![feature(raw_dylib)]
4-
//~^ WARN the feature `raw_dylib` is incomplete
53
#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
64
//~^ ERROR import name type is only supported on x86
75
extern "C" { }
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/import-name-type-x86-only.rs:3:12
3-
|
4-
LL | #![feature(raw_dylib)]
5-
| ^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
9-
101
error: import name type is only supported on x86
11-
--> $DIR/import-name-type-x86-only.rs:5:42
2+
--> $DIR/import-name-type-x86-only.rs:3:42
123
|
134
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
145
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156

16-
error: aborting due to previous error; 1 warning emitted
7+
error: aborting due to previous error
178

src/test/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![feature(raw_dylib)]
2-
//~^ WARN the feature `raw_dylib` is incomplete
1+
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
32

43
#[link(name="foo")]
54
extern "C" {
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/link-ordinal-and-name.rs:1:12
3-
|
4-
LL | #![feature(raw_dylib)]
5-
| ^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
9-
101
error: cannot use `#[link_name]` with `#[link_ordinal]`
11-
--> $DIR/link-ordinal-and-name.rs:7:5
2+
--> $DIR/link-ordinal-and-name.rs:6:5
123
|
134
LL | #[link_ordinal(42)]
145
| ^^^^^^^^^^^^^^^^^^^
156

167
error: cannot use `#[link_name]` with `#[link_ordinal]`
17-
--> $DIR/link-ordinal-and-name.rs:11:5
8+
--> $DIR/link-ordinal-and-name.rs:10:5
189
|
1910
LL | #[link_ordinal(5)]
2011
| ^^^^^^^^^^^^^^^^^^
2112

22-
error: aborting due to 2 previous errors; 1 warning emitted
13+
error: aborting due to 2 previous errors
2314

src/test/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![feature(raw_dylib)]
2-
//~^ WARN the feature `raw_dylib` is incomplete
1+
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
32

43
#[link(name = "foo")]
54
extern "C" {
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/link-ordinal-invalid-format.rs:1:12
3-
|
4-
LL | #![feature(raw_dylib)]
5-
| ^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
9-
101
error: illegal ordinal format in `link_ordinal`
11-
--> $DIR/link-ordinal-invalid-format.rs:6:5
2+
--> $DIR/link-ordinal-invalid-format.rs:5:5
123
|
134
LL | #[link_ordinal("JustMonika")]
145
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156
|
167
= note: an unsuffixed integer value, e.g., `1`, is expected
178

189
error: illegal ordinal format in `link_ordinal`
19-
--> $DIR/link-ordinal-invalid-format.rs:9:5
10+
--> $DIR/link-ordinal-invalid-format.rs:8:5
2011
|
2112
LL | #[link_ordinal("JustMonika")]
2213
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2314
|
2415
= note: an unsuffixed integer value, e.g., `1`, is expected
2516

26-
error: aborting due to 2 previous errors; 1 warning emitted
17+
error: aborting due to 2 previous errors
2718

src/test/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![feature(raw_dylib)]
2-
//~^ WARN the feature `raw_dylib` is incomplete
1+
#![cfg_attr(target_arch = "x86", feature(raw_dylib))]
32

43
#[link(name = "foo")]
54
extern "C" {

0 commit comments

Comments
 (0)