Skip to content

Commit ad7add5

Browse files
committed
remove #[cmse_nonsecure_entry]
1 parent 5d76fb9 commit ad7add5

File tree

23 files changed

+50
-162
lines changed

23 files changed

+50
-162
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

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

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
@@ -392,7 +392,7 @@ declare_features! (
392392
(unstable, closure_lifetime_binder, "1.64.0", Some(97362)),
393393
/// Allows `#[track_caller]` on closures and coroutines.
394394
(unstable, closure_track_caller, "1.57.0", Some(87417)),
395-
/// Allows to use the `#[cmse_nonsecure_entry]` attribute.
395+
/// Allows `extern "C-cmse-nonsecure-entry" fn()`.
396396
(unstable, cmse_nonsecure_entry, "1.48.0", Some(75835)),
397397
/// Allows `async {}` expressions in const contexts.
398398
(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
@@ -120,9 +120,7 @@ bitflags::bitflags! {
120120
/// #[ffi_const]: applies clang's `const` attribute to a foreign function
121121
/// declaration.
122122
const FFI_CONST = 1 << 12;
123-
/// #[cmse_nonsecure_entry]: with a TrustZone-M extension, declare a
124-
/// function as an entry function from Non-Secure code.
125-
const CMSE_NONSECURE_ENTRY = 1 << 13;
123+
// (Bit 13 was used for `#[cmse_nonsecure_entry]`, but is now unused.)
126124
// (Bit 14 was used for `#[coverage(off)]`, but is now unused.)
127125
/// `#[used(linker)]`:
128126
/// 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
@@ -183,9 +183,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
183183
| [sym::rustc_must_implement_one_of, ..]
184184
| [sym::rustc_deny_explicit_impl, ..]
185185
| [sym::const_trait, ..] => self.check_must_be_applied_to_trait(attr, span, target),
186-
[sym::cmse_nonsecure_entry, ..] => {
187-
self.check_cmse_nonsecure_entry(hir_id, attr, span, target)
188-
}
189186
[sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
190187
[sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),
191188
[sym::must_use, ..] => self.check_must_use(hir_id, attr, target),
@@ -561,27 +558,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
561558
}
562559
}
563560

564-
/// Checks if `#[cmse_nonsecure_entry]` is applied to a function definition.
565-
fn check_cmse_nonsecure_entry(
566-
&self,
567-
hir_id: HirId,
568-
attr: &Attribute,
569-
span: Span,
570-
target: Target,
571-
) {
572-
match target {
573-
Target::Fn
574-
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => {}
575-
_ => {
576-
self.dcx().emit_err(errors::AttrShouldBeAppliedToFn {
577-
attr_span: attr.span,
578-
defn_span: span,
579-
on_crate: hir_id == CRATE_HIR_ID,
580-
});
581-
}
582-
}
583-
}
584-
585561
/// Debugging aid for `object_lifetime_default` query.
586562
fn check_object_lifetime_default(&self, hir_id: HirId) {
587563
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)