Skip to content

Commit 9d04d69

Browse files
committed
remove #[cmse_nonsecure_entry]
1 parent b1dd190 commit 9d04d69

File tree

27 files changed

+46
-202
lines changed

27 files changed

+46
-202
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

-3
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,6 @@ pub fn from_fn_attrs<'ll, 'tcx>(
441441
let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx);
442442
attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]);
443443
}
444-
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) {
445-
to_add.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry"));
446-
}
447444
if let Some(align) = codegen_fn_attrs.alignment {
448445
llvm::set_alignment(llfn, align);
449446
}

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

-18
Original file line numberDiff line numberDiff line change
@@ -192,24 +192,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
192192
}
193193
}
194194
}
195-
sym::cmse_nonsecure_entry => {
196-
if let Some(fn_sig) = fn_sig()
197-
&& !matches!(fn_sig.skip_binder().abi(), abi::Abi::C { .. })
198-
{
199-
struct_span_code_err!(
200-
tcx.dcx(),
201-
attr.span,
202-
E0776,
203-
"`#[cmse_nonsecure_entry]` requires C ABI"
204-
)
205-
.emit();
206-
}
207-
if !tcx.sess.target.llvm_target.contains("thumbv8m") {
208-
struct_span_code_err!(tcx.dcx(), attr.span, E0775, "`#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension")
209-
.emit();
210-
}
211-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY
212-
}
213195
sym::thread_local => codegen_fn_attrs.flags |= CodegenFnAttrFlags::THREAD_LOCAL,
214196
sym::track_caller => {
215197
let is_closure = tcx.is_closure_like(did.to_def_id());

compiler/rustc_error_codes/src/error_codes/E0776.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
`#[cmse_nonsecure_entry]` functions require a C ABI
24

35
Erroneous code example:

compiler/rustc_error_codes/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -677,3 +677,4 @@ E0797: 0797,
677677
// E0723, // unstable feature in `const` context
678678
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
679679
// E0744, // merged into E0728
680+
// E0776, // Removed; cmse_nonsecure_entry is now `C-cmse-nonsecure-entry`

compiler/rustc_feature/src/builtin_attrs.rs

-4
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
550550
EncodeCrossCrate::No, experimental!(register_tool),
551551
),
552552

553-
gated!(
554-
cmse_nonsecure_entry, Normal, template!(Word), WarnFollowing,
555-
EncodeCrossCrate::No, experimental!(cmse_nonsecure_entry)
556-
),
557553
// RFC 2632
558554
gated!(
559555
const_trait, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, const_trait_impl,

compiler/rustc_feature/src/unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ declare_features! (
391391
(unstable, closure_lifetime_binder, "1.64.0", Some(97362)),
392392
/// Allows `#[track_caller]` on closures and coroutines.
393393
(unstable, closure_track_caller, "1.57.0", Some(87417)),
394-
/// Allows to use the `#[cmse_nonsecure_entry]` attribute.
394+
/// Allows `extern "C-cmse-nonsecure-entry" fn()`.
395395
(unstable, cmse_nonsecure_entry, "1.48.0", Some(75835)),
396396
/// Allows `async {}` expressions in const contexts.
397397
(unstable, const_async_blocks, "1.53.0", Some(85368)),

compiler/rustc_middle/src/middle/codegen_fn_attrs.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ bitflags::bitflags! {
110110
/// #[ffi_const]: applies clang's `const` attribute to a foreign function
111111
/// declaration.
112112
const FFI_CONST = 1 << 12;
113-
/// #[cmse_nonsecure_entry]: with a TrustZone-M extension, declare a
114-
/// function as an entry function from Non-Secure code.
115-
const CMSE_NONSECURE_ENTRY = 1 << 13;
113+
// (Bit 13 was used for `#[cmse_nonsecure_entry]`, but is now unused.)
116114
// (Bit 14 was used for `#[coverage(off)]`, but is now unused.)
117115
/// `#[used(linker)]`:
118116
/// indicates that neither LLVM nor the linker will eliminate this function.

compiler/rustc_target/src/spec/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1251,9 +1251,9 @@ impl StackProbeType {
12511251
.and_then(|o| o.as_array())
12521252
.ok_or_else(|| "expected `min-llvm-version-for-inline` to be an array")?;
12531253
let mut iter = min_version.into_iter().map(|v| {
1254-
let int = v.as_u64().ok_or_else(|| {
1255-
"expected `min-llvm-version-for-inline` values to be integers"
1256-
})?;
1254+
let int = v.as_u64().ok_or_else(
1255+
|| "expected `min-llvm-version-for-inline` values to be integers",
1256+
)?;
12571257
u32::try_from(int)
12581258
.map_err(|_| "`min-llvm-version-for-inline` values don't convert to u32")
12591259
});

src/doc/unstable-book/src/language-features/cmse-nonsecure-entry.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ LLVM, the Rust compiler and the linker are providing
1515
TrustZone-M feature.
1616

1717
One of the things provided, with this unstable feature, is the
18-
`cmse_nonsecure_entry` attribute. This attribute marks a Secure function as an
18+
`C-cmse-nonsecure-entry` ABI. This ABI marks a Secure function as an
1919
entry function (see [section
2020
5.4](https://developer.arm.com/documentation/ecm0359818/latest/) for details).
21-
With this attribute, the compiler will do the following:
21+
With this ABI, the compiler will do the following:
2222
* add a special symbol on the function which is the `__acle_se_` prefix and the
2323
standard function name
2424
* constrain the number of parameters to avoid using the Non-Secure stack
@@ -38,11 +38,11 @@ gateway veneer.
3838
<!-- NOTE(ignore) this example is specific to thumbv8m targets -->
3939

4040
``` rust,ignore
41+
#![no_std]
4142
#![feature(cmse_nonsecure_entry)]
4243
4344
#[no_mangle]
44-
#[cmse_nonsecure_entry]
45-
pub extern "C" fn entry_function(input: u32) -> u32 {
45+
pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
4646
input + 6
4747
}
4848
```

src/tools/tidy/src/issues.txt

-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ ui/closures/issue-87814-2.rs
467467
ui/closures/issue-90871.rs
468468
ui/closures/issue-97607.rs
469469
ui/closures/issue-99565.rs
470-
ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs
471470
ui/codegen/auxiliary/issue-97708-aux.rs
472471
ui/codegen/issue-101585-128bit-repeat.rs
473472
ui/codegen/issue-16602-1.rs

tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/gate_test.rs

-10
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/gate_test.stderr

-20
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/params-on-registers.rs

-15
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/params-on-stack.rs

-21
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/params-on-stack.stderr

-4
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/trustzone-only.rs

-10
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/trustzone-only.stderr

-9
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// gate-test-cmse_nonsecure_entry
22

33
#[no_mangle]
4-
#[cmse_nonsecure_entry]
5-
//~^ ERROR [E0775]
6-
//~| ERROR [E0658]
7-
pub extern "C" fn entry_function(input: u32) -> u32 {
4+
pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
5+
//~^ ERROR [E0570]
6+
//~| ERROR [E0658]
87
input + 6
98
}
109

Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
error[E0658]: the `#[cmse_nonsecure_entry]` attribute is an experimental feature
2-
--> $DIR/gate_test.rs:4:1
1+
error[E0658]: C-cmse-nonsecure-entry ABI is experimental and subject to change
2+
--> $DIR/gate_test.rs:4:12
33
|
4-
LL | #[cmse_nonsecure_entry]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: see issue #75835 <https://github.com/rust-lang/rust/issues/75835> for more information
88
= help: add `#![feature(cmse_nonsecure_entry)]` to the crate attributes to enable
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

11-
error[E0775]: `#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension
11+
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
1212
--> $DIR/gate_test.rs:4:1
1313
|
14-
LL | #[cmse_nonsecure_entry]
15-
| ^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

1717
error: aborting due to 2 previous errors
1818

19-
Some errors have detailed explanations: E0658, E0775.
20-
For more information about an error, try `rustc --explain E0658`.
19+
Some errors have detailed explanations: E0570, E0658.
20+
For more information about an error, try `rustc --explain E0570`.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs

-9
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.stderr

-11
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
//@ needs-llvm-components: arm
44
#![feature(cmse_nonsecure_entry, no_core, lang_items)]
55
#![no_core]
6-
#[lang="sized"]
7-
trait Sized { }
8-
#[lang="copy"]
9-
trait Copy { }
6+
#[lang = "sized"]
7+
trait Sized {}
8+
#[lang = "copy"]
9+
trait Copy {}
1010
impl Copy for u32 {}
1111

1212
#[no_mangle]
13-
#[cmse_nonsecure_entry]
14-
pub extern "C" fn entry_function(_: u32, _: u32, _: u32, d: u32) -> u32 {
13+
pub extern "C-cmse-nonsecure-entry" fn entry_function(_: u32, _: u32, _: u32, d: u32) -> u32 {
1514
d
1615
}

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
//@ needs-llvm-components: arm
44
#![feature(cmse_nonsecure_entry, no_core, lang_items)]
55
#![no_core]
6-
#[lang="sized"]
7-
trait Sized { }
8-
#[lang="copy"]
9-
trait Copy { }
6+
#[lang = "sized"]
7+
trait Sized {}
8+
#[lang = "copy"]
9+
trait Copy {}
1010
impl Copy for u32 {}
1111

1212
#[no_mangle]
13-
#[cmse_nonsecure_entry]
14-
pub extern "C" fn entry_function(_: u32, _: u32, _: u32, _: u32, e: u32) -> u32 {
13+
pub extern "C-cmse-nonsecure-entry" fn entry_function(
14+
_: u32,
15+
_: u32,
16+
_: u32,
17+
_: u32,
18+
e: u32,
19+
) -> u32 {
1520
e
1621
}

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#![feature(cmse_nonsecure_entry)]
33

44
#[no_mangle]
5-
#[cmse_nonsecure_entry] //~ ERROR [E0775]
6-
pub extern "C" fn entry_function(input: u32) -> u32 {
5+
pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
6+
//~^ ERROR [E0570]
77
input + 6
88
}
99

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
error[E0775]: `#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension
1+
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
22
--> $DIR/trustzone-only.rs:5:1
33
|
4-
LL | #[cmse_nonsecure_entry]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

9-
For more information about this error, try `rustc --explain E0775`.
9+
For more information about this error, try `rustc --explain E0570`.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.rs

-16
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.stderr

-9
This file was deleted.

0 commit comments

Comments
 (0)