Skip to content

Commit c952e80

Browse files
committed
remove #[cmse_nonsecure_entry]
1 parent 29bee13 commit c952e80

File tree

30 files changed

+50
-251
lines changed

30 files changed

+50
-251
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@ pub fn from_fn_attrs<'ll, 'tcx>(
475475
let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx);
476476
attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]);
477477
}
478-
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) {
479-
to_add.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry"));
480-
}
481478
if let Some(align) = codegen_fn_attrs.alignment {
482479
llvm::set_alignment(llfn, align);
483480
}

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

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

compiler/rustc_error_codes/src/error_codes/E0775.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ extension.
33

44
Erroneous code example:
55

6-
```compile_fail,E0775
6+
```ignore (no longer emitted)
77
#![feature(cmse_nonsecure_entry)]
88
9-
#[cmse_nonsecure_entry]
10-
pub extern "C" fn entry_function() {}
9+
pub extern "C-cmse-nonsecure-entry" fn entry_function() {}
1110
```
1211

1312
To fix this error, compile your code for a Rust target that supports the

compiler/rustc_error_codes/src/error_codes/E0776.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
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:
46

5-
```compile_fail,E0776
7+
```ignore (no longer emitted)
68
#![feature(cmse_nonsecure_entry)]
79
810
#[no_mangle]

compiler/rustc_error_codes/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,3 +678,4 @@ E0798: 0798,
678678
// E0723, // unstable feature in `const` context
679679
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
680680
// E0744, // merged into E0728
681+
// E0776, // Removed; cmse_nonsecure_entry is now `C-cmse-nonsecure-entry`

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
549549
EncodeCrossCrate::No, experimental!(register_tool),
550550
),
551551

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

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ declare_features! (
394394
(unstable, closure_lifetime_binder, "1.64.0", Some(97362)),
395395
/// Allows `#[track_caller]` on closures and coroutines.
396396
(unstable, closure_track_caller, "1.57.0", Some(87417)),
397-
/// Allows to use the `#[cmse_nonsecure_entry]` attribute.
397+
/// Allows `extern "C-cmse-nonsecure-entry" fn()`.
398398
(unstable, cmse_nonsecure_entry, "1.48.0", Some(75835)),
399399
/// Allows `async {}` expressions in const contexts.
400400
(unstable, const_async_blocks, "1.53.0", Some(85368)),

compiler/rustc_middle/src/middle/codegen_fn_attrs.rs

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

compiler/rustc_passes/src/check_attr.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
182182
| [sym::rustc_must_implement_one_of, ..]
183183
| [sym::rustc_deny_explicit_impl, ..]
184184
| [sym::const_trait, ..] => self.check_must_be_applied_to_trait(attr, span, target),
185-
[sym::cmse_nonsecure_entry, ..] => {
186-
self.check_cmse_nonsecure_entry(hir_id, attr, span, target)
187-
}
188185
[sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
189186
[sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),
190187
[sym::must_use, ..] => self.check_must_use(hir_id, attr, target),
@@ -555,27 +552,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
555552
}
556553
}
557554

558-
/// Checks if `#[cmse_nonsecure_entry]` is applied to a function definition.
559-
fn check_cmse_nonsecure_entry(
560-
&self,
561-
hir_id: HirId,
562-
attr: &Attribute,
563-
span: Span,
564-
target: Target,
565-
) {
566-
match target {
567-
Target::Fn
568-
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => {}
569-
_ => {
570-
self.dcx().emit_err(errors::AttrShouldBeAppliedToFn {
571-
attr_span: attr.span,
572-
defn_span: span,
573-
on_crate: hir_id == CRATE_HIR_ID,
574-
});
575-
}
576-
}
577-
}
578-
579555
/// Debugging aid for `object_lifetime_default` query.
580556
fn check_object_lifetime_default(&self, hir_id: HirId) {
581557
let tcx = self.tcx;

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

Lines changed: 4 additions & 4 deletions
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
```

0 commit comments

Comments
 (0)