Skip to content

Commit 16edaa5

Browse files
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. rust-lang#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

+3-1
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[..]),
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
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

-8
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

0 commit comments

Comments
 (0)