Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 16edaa5

Browse files
committedNov 6, 2022
Limit efiapi calling convention to supported arches
Supported architectures in UEFI are described here: https://uefi.org/specs/UEFI/2.10/02_Overview.html#calling-conventions Changes to tests modeled on 8240e7a. #65815
1 parent 7eef946 commit 16edaa5

File tree

5 files changed

+130
-100
lines changed

5 files changed

+130
-100
lines changed
 

‎compiler/rustc_target/src/spec/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,8 +1941,10 @@ impl Target {
19411941
| PlatformIntrinsic
19421942
| Unadjusted
19431943
| Cdecl { .. }
1944-
| EfiApi
19451944
| RustCold => true,
1945+
EfiApi => {
1946+
["arm", "aarch64", "riscv32", "riscv64", "x86", "x86_64"].contains(&&self.arch[..])
1947+
}
19461948
X86Interrupt => ["x86", "x86_64"].contains(&&self.arch[..]),
19471949
Aapcs { .. } => "arm" == self.arch,
19481950
CCmseNonSecureCall => ["arm", "aarch64"].contains(&&self.arch[..]),
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// needs-llvm-components: x86
2+
// compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib
3+
#![no_core]
4+
#![feature(no_core, lang_items)]
5+
#[lang="sized"]
6+
trait Sized { }
7+
8+
// Functions
9+
extern "efiapi" fn f1() {} //~ ERROR efiapi ABI is experimental
10+
11+
// Methods in trait defintion
12+
trait Tr {
13+
extern "efiapi" fn f2(); //~ ERROR efiapi ABI is experimental
14+
extern "efiapi" fn f3() {} //~ ERROR efiapi ABI is experimental
15+
}
16+
17+
struct S;
18+
19+
// Methods in trait impl
20+
impl Tr for S {
21+
extern "efiapi" fn f2() {} //~ ERROR efiapi ABI is experimental
22+
}
23+
24+
// Methods in inherent impl
25+
impl S {
26+
extern "efiapi" fn f4() {} //~ ERROR efiapi ABI is experimental
27+
}
28+
29+
// Function pointer types
30+
type A = extern "efiapi" fn(); //~ ERROR efiapi ABI is experimental
31+
32+
// Foreign modules
33+
extern "efiapi" {} //~ ERROR efiapi ABI is experimental
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
error[E0658]: efiapi ABI is experimental and subject to change
2+
--> $DIR/feature-gate-abi-efiapi.rs:9:8
3+
|
4+
LL | extern "efiapi" fn f1() {}
5+
| ^^^^^^^^
6+
|
7+
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
8+
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
9+
10+
error[E0658]: efiapi ABI is experimental and subject to change
11+
--> $DIR/feature-gate-abi-efiapi.rs:13:12
12+
|
13+
LL | extern "efiapi" fn f2();
14+
| ^^^^^^^^
15+
|
16+
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
17+
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
18+
19+
error[E0658]: efiapi ABI is experimental and subject to change
20+
--> $DIR/feature-gate-abi-efiapi.rs:14:12
21+
|
22+
LL | extern "efiapi" fn f3() {}
23+
| ^^^^^^^^
24+
|
25+
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
26+
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
27+
28+
error[E0658]: efiapi ABI is experimental and subject to change
29+
--> $DIR/feature-gate-abi-efiapi.rs:21:12
30+
|
31+
LL | extern "efiapi" fn f2() {}
32+
| ^^^^^^^^
33+
|
34+
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
35+
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
36+
37+
error[E0658]: efiapi ABI is experimental and subject to change
38+
--> $DIR/feature-gate-abi-efiapi.rs:26:12
39+
|
40+
LL | extern "efiapi" fn f4() {}
41+
| ^^^^^^^^
42+
|
43+
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
44+
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
45+
46+
error[E0658]: efiapi ABI is experimental and subject to change
47+
--> $DIR/feature-gate-abi-efiapi.rs:30:17
48+
|
49+
LL | type A = extern "efiapi" fn();
50+
| ^^^^^^^^
51+
|
52+
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
53+
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
54+
55+
error[E0658]: efiapi ABI is experimental and subject to change
56+
--> $DIR/feature-gate-abi-efiapi.rs:33:8
57+
|
58+
LL | extern "efiapi" {}
59+
| ^^^^^^^^
60+
|
61+
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
62+
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
63+
64+
error: aborting due to 7 previous errors
65+
66+
For more information about this error, try `rustc --explain E0658`.

‎src/test/ui/feature-gates/feature-gate-abi.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// gate-test-intrinsics
22
// gate-test-platform_intrinsics
3-
// gate-test-abi_efiapi
43
// compile-flags: --crate-type=rlib
54

65
#![feature(no_core, lang_items)]
@@ -18,7 +17,6 @@ extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change
1817
extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental
1918
//~^ ERROR intrinsic must be in
2019
extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change
21-
extern "efiapi" fn f10() {} //~ ERROR efiapi ABI is experimental and subject to change
2220

2321
// Methods in trait definition
2422
trait Tr {
@@ -27,10 +25,8 @@ trait Tr {
2725
extern "platform-intrinsic" fn m2(); //~ ERROR platform intrinsics are experimental
2826
//~^ ERROR intrinsic must be in
2927
extern "rust-call" fn m4(_: ()); //~ ERROR rust-call ABI is subject to change
30-
extern "efiapi" fn m10(); //~ ERROR efiapi ABI is experimental and subject to change
3128

3229
extern "rust-call" fn dm4(_: ()) {} //~ ERROR rust-call ABI is subject to change
33-
extern "efiapi" fn dm10() {} //~ ERROR efiapi ABI is experimental and subject to change
3430
}
3531

3632
struct S;
@@ -42,7 +38,6 @@ impl Tr for S {
4238
extern "platform-intrinsic" fn m2() {} //~ ERROR platform intrinsics are experimental
4339
//~^ ERROR intrinsic must be in
4440
extern "rust-call" fn m4(_: ()) {} //~ ERROR rust-call ABI is subject to change
45-
extern "efiapi" fn m10() {} //~ ERROR efiapi ABI is experimental and subject to change
4641
}
4742

4843
// Methods in inherent impl
@@ -52,17 +47,14 @@ impl S {
5247
extern "platform-intrinsic" fn im2() {} //~ ERROR platform intrinsics are experimental
5348
//~^ ERROR intrinsic must be in
5449
extern "rust-call" fn im4(_: ()) {} //~ ERROR rust-call ABI is subject to change
55-
extern "efiapi" fn im10() {} //~ ERROR efiapi ABI is experimental and subject to change
5650
}
5751

5852
// Function pointer types
5953
type A1 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change
6054
type A2 = extern "platform-intrinsic" fn(); //~ ERROR platform intrinsics are experimental
6155
type A4 = extern "rust-call" fn(_: ()); //~ ERROR rust-call ABI is subject to change
62-
type A10 = extern "efiapi" fn(); //~ ERROR efiapi ABI is experimental and subject to change
6356

6457
// Foreign modules
6558
extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change
6659
extern "platform-intrinsic" {} //~ ERROR platform intrinsics are experimental
6760
extern "rust-call" {} //~ ERROR rust-call ABI is subject to change
68-
extern "efiapi" {} //~ ERROR efiapi ABI is experimental and subject to change
Lines changed: 28 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0658]: intrinsics are subject to change
2-
--> $DIR/feature-gate-abi.rs:16:8
2+
--> $DIR/feature-gate-abi.rs:15:8
33
|
44
LL | extern "rust-intrinsic" fn f1() {}
55
| ^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(intrinsics)]` to the crate attributes to enable
88

99
error[E0658]: platform intrinsics are experimental and possibly buggy
10-
--> $DIR/feature-gate-abi.rs:18:8
10+
--> $DIR/feature-gate-abi.rs:17:8
1111
|
1212
LL | extern "platform-intrinsic" fn f2() {}
1313
| ^^^^^^^^^^^^^^^^^^^^
@@ -16,33 +16,24 @@ LL | extern "platform-intrinsic" fn f2() {}
1616
= help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable
1717

1818
error[E0658]: rust-call ABI is subject to change
19-
--> $DIR/feature-gate-abi.rs:20:8
19+
--> $DIR/feature-gate-abi.rs:19:8
2020
|
2121
LL | extern "rust-call" fn f4(_: ()) {}
2222
| ^^^^^^^^^^^
2323
|
2424
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
2525
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
2626

27-
error[E0658]: efiapi ABI is experimental and subject to change
28-
--> $DIR/feature-gate-abi.rs:21:8
29-
|
30-
LL | extern "efiapi" fn f10() {}
31-
| ^^^^^^^^
32-
|
33-
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
34-
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
35-
3627
error[E0658]: intrinsics are subject to change
37-
--> $DIR/feature-gate-abi.rs:25:12
28+
--> $DIR/feature-gate-abi.rs:23:12
3829
|
3930
LL | extern "rust-intrinsic" fn m1();
4031
| ^^^^^^^^^^^^^^^^
4132
|
4233
= help: add `#![feature(intrinsics)]` to the crate attributes to enable
4334

4435
error[E0658]: platform intrinsics are experimental and possibly buggy
45-
--> $DIR/feature-gate-abi.rs:27:12
36+
--> $DIR/feature-gate-abi.rs:25:12
4637
|
4738
LL | extern "platform-intrinsic" fn m2();
4839
| ^^^^^^^^^^^^^^^^^^^^
@@ -51,51 +42,33 @@ LL | extern "platform-intrinsic" fn m2();
5142
= help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable
5243

5344
error[E0658]: rust-call ABI is subject to change
54-
--> $DIR/feature-gate-abi.rs:29:12
45+
--> $DIR/feature-gate-abi.rs:27:12
5546
|
5647
LL | extern "rust-call" fn m4(_: ());
5748
| ^^^^^^^^^^^
5849
|
5950
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
6051
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
6152

62-
error[E0658]: efiapi ABI is experimental and subject to change
63-
--> $DIR/feature-gate-abi.rs:30:12
64-
|
65-
LL | extern "efiapi" fn m10();
66-
| ^^^^^^^^
67-
|
68-
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
69-
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
70-
7153
error[E0658]: rust-call ABI is subject to change
72-
--> $DIR/feature-gate-abi.rs:32:12
54+
--> $DIR/feature-gate-abi.rs:29:12
7355
|
7456
LL | extern "rust-call" fn dm4(_: ()) {}
7557
| ^^^^^^^^^^^
7658
|
7759
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
7860
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
7961

80-
error[E0658]: efiapi ABI is experimental and subject to change
81-
--> $DIR/feature-gate-abi.rs:33:12
82-
|
83-
LL | extern "efiapi" fn dm10() {}
84-
| ^^^^^^^^
85-
|
86-
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
87-
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
88-
8962
error[E0658]: intrinsics are subject to change
90-
--> $DIR/feature-gate-abi.rs:40:12
63+
--> $DIR/feature-gate-abi.rs:36:12
9164
|
9265
LL | extern "rust-intrinsic" fn m1() {}
9366
| ^^^^^^^^^^^^^^^^
9467
|
9568
= help: add `#![feature(intrinsics)]` to the crate attributes to enable
9669

9770
error[E0658]: platform intrinsics are experimental and possibly buggy
98-
--> $DIR/feature-gate-abi.rs:42:12
71+
--> $DIR/feature-gate-abi.rs:38:12
9972
|
10073
LL | extern "platform-intrinsic" fn m2() {}
10174
| ^^^^^^^^^^^^^^^^^^^^
@@ -104,33 +77,24 @@ LL | extern "platform-intrinsic" fn m2() {}
10477
= help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable
10578

10679
error[E0658]: rust-call ABI is subject to change
107-
--> $DIR/feature-gate-abi.rs:44:12
80+
--> $DIR/feature-gate-abi.rs:40:12
10881
|
10982
LL | extern "rust-call" fn m4(_: ()) {}
11083
| ^^^^^^^^^^^
11184
|
11285
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
11386
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
11487

115-
error[E0658]: efiapi ABI is experimental and subject to change
116-
--> $DIR/feature-gate-abi.rs:45:12
117-
|
118-
LL | extern "efiapi" fn m10() {}
119-
| ^^^^^^^^
120-
|
121-
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
122-
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
123-
12488
error[E0658]: intrinsics are subject to change
125-
--> $DIR/feature-gate-abi.rs:50:12
89+
--> $DIR/feature-gate-abi.rs:45:12
12690
|
12791
LL | extern "rust-intrinsic" fn im1() {}
12892
| ^^^^^^^^^^^^^^^^
12993
|
13094
= help: add `#![feature(intrinsics)]` to the crate attributes to enable
13195

13296
error[E0658]: platform intrinsics are experimental and possibly buggy
133-
--> $DIR/feature-gate-abi.rs:52:12
97+
--> $DIR/feature-gate-abi.rs:47:12
13498
|
13599
LL | extern "platform-intrinsic" fn im2() {}
136100
| ^^^^^^^^^^^^^^^^^^^^
@@ -139,33 +103,24 @@ LL | extern "platform-intrinsic" fn im2() {}
139103
= help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable
140104

141105
error[E0658]: rust-call ABI is subject to change
142-
--> $DIR/feature-gate-abi.rs:54:12
106+
--> $DIR/feature-gate-abi.rs:49:12
143107
|
144108
LL | extern "rust-call" fn im4(_: ()) {}
145109
| ^^^^^^^^^^^
146110
|
147111
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
148112
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
149113

150-
error[E0658]: efiapi ABI is experimental and subject to change
151-
--> $DIR/feature-gate-abi.rs:55:12
152-
|
153-
LL | extern "efiapi" fn im10() {}
154-
| ^^^^^^^^
155-
|
156-
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
157-
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
158-
159114
error[E0658]: intrinsics are subject to change
160-
--> $DIR/feature-gate-abi.rs:59:18
115+
--> $DIR/feature-gate-abi.rs:53:18
161116
|
162117
LL | type A1 = extern "rust-intrinsic" fn();
163118
| ^^^^^^^^^^^^^^^^
164119
|
165120
= help: add `#![feature(intrinsics)]` to the crate attributes to enable
166121

167122
error[E0658]: platform intrinsics are experimental and possibly buggy
168-
--> $DIR/feature-gate-abi.rs:60:18
123+
--> $DIR/feature-gate-abi.rs:54:18
169124
|
170125
LL | type A2 = extern "platform-intrinsic" fn();
171126
| ^^^^^^^^^^^^^^^^^^^^
@@ -174,33 +129,24 @@ LL | type A2 = extern "platform-intrinsic" fn();
174129
= help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable
175130

176131
error[E0658]: rust-call ABI is subject to change
177-
--> $DIR/feature-gate-abi.rs:61:18
132+
--> $DIR/feature-gate-abi.rs:55:18
178133
|
179134
LL | type A4 = extern "rust-call" fn(_: ());
180135
| ^^^^^^^^^^^
181136
|
182137
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
183138
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
184139

185-
error[E0658]: efiapi ABI is experimental and subject to change
186-
--> $DIR/feature-gate-abi.rs:62:19
187-
|
188-
LL | type A10 = extern "efiapi" fn();
189-
| ^^^^^^^^
190-
|
191-
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
192-
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
193-
194140
error[E0658]: intrinsics are subject to change
195-
--> $DIR/feature-gate-abi.rs:65:8
141+
--> $DIR/feature-gate-abi.rs:58:8
196142
|
197143
LL | extern "rust-intrinsic" {}
198144
| ^^^^^^^^^^^^^^^^
199145
|
200146
= help: add `#![feature(intrinsics)]` to the crate attributes to enable
201147

202148
error[E0658]: platform intrinsics are experimental and possibly buggy
203-
--> $DIR/feature-gate-abi.rs:66:8
149+
--> $DIR/feature-gate-abi.rs:59:8
204150
|
205151
LL | extern "platform-intrinsic" {}
206152
| ^^^^^^^^^^^^^^^^^^^^
@@ -209,71 +155,62 @@ LL | extern "platform-intrinsic" {}
209155
= help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable
210156

211157
error[E0658]: rust-call ABI is subject to change
212-
--> $DIR/feature-gate-abi.rs:67:8
158+
--> $DIR/feature-gate-abi.rs:60:8
213159
|
214160
LL | extern "rust-call" {}
215161
| ^^^^^^^^^^^
216162
|
217163
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
218164
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
219165

220-
error[E0658]: efiapi ABI is experimental and subject to change
221-
--> $DIR/feature-gate-abi.rs:68:8
222-
|
223-
LL | extern "efiapi" {}
224-
| ^^^^^^^^
225-
|
226-
= note: see issue #65815 <https://github.com/rust-lang/rust/issues/65815> for more information
227-
= help: add `#![feature(abi_efiapi)]` to the crate attributes to enable
228-
229166
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
230-
--> $DIR/feature-gate-abi.rs:25:32
167+
--> $DIR/feature-gate-abi.rs:23:32
231168
|
232169
LL | extern "rust-intrinsic" fn m1();
233170
| ^^
234171

235172
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
236-
--> $DIR/feature-gate-abi.rs:27:36
173+
--> $DIR/feature-gate-abi.rs:25:36
237174
|
238175
LL | extern "platform-intrinsic" fn m2();
239176
| ^^
240177

241178
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
242-
--> $DIR/feature-gate-abi.rs:16:33
179+
--> $DIR/feature-gate-abi.rs:15:33
243180
|
244181
LL | extern "rust-intrinsic" fn f1() {}
245182
| ^^
246183

247184
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
248-
--> $DIR/feature-gate-abi.rs:18:37
185+
--> $DIR/feature-gate-abi.rs:17:37
249186
|
250187
LL | extern "platform-intrinsic" fn f2() {}
251188
| ^^
252189

253190
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
254-
--> $DIR/feature-gate-abi.rs:40:37
191+
--> $DIR/feature-gate-abi.rs:36:37
255192
|
256193
LL | extern "rust-intrinsic" fn m1() {}
257194
| ^^
258195

259196
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
260-
--> $DIR/feature-gate-abi.rs:42:41
197+
--> $DIR/feature-gate-abi.rs:38:41
261198
|
262199
LL | extern "platform-intrinsic" fn m2() {}
263200
| ^^
264201

265202
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
266-
--> $DIR/feature-gate-abi.rs:50:38
203+
--> $DIR/feature-gate-abi.rs:45:38
267204
|
268205
LL | extern "rust-intrinsic" fn im1() {}
269206
| ^^
270207

271208
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
272-
--> $DIR/feature-gate-abi.rs:52:42
209+
--> $DIR/feature-gate-abi.rs:47:42
273210
|
274211
LL | extern "platform-intrinsic" fn im2() {}
275212
| ^^
276213

277-
error: aborting due to 34 previous errors
214+
error: aborting due to 27 previous errors
278215

279216
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)
Please sign in to comment.