Skip to content

Commit a83ff0a

Browse files
committed
remove #[cmse_nonsecure_entry]
1 parent 762cb47 commit a83ff0a

File tree

30 files changed

+46
-267
lines changed

30 files changed

+46
-267
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 0 additions & 3 deletions
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

Lines changed: 0 additions & 18 deletions
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

Lines changed: 2 additions & 0 deletions
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

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 3 deletions
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_passes/src/check_attr.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
180180
| [sym::rustc_must_implement_one_of]
181181
| [sym::rustc_deny_explicit_impl]
182182
| [sym::const_trait] => self.check_must_be_applied_to_trait(attr, span, target),
183-
[sym::cmse_nonsecure_entry] => {
184-
self.check_cmse_nonsecure_entry(hir_id, attr, span, target)
185-
}
186183
[sym::collapse_debuginfo] => self.check_collapse_debuginfo(attr, span, target),
187184
[sym::must_not_suspend] => self.check_must_not_suspend(attr, span, target),
188185
[sym::must_use] => self.check_must_use(hir_id, attr, target),
@@ -433,28 +430,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
433430
}
434431
}
435432

436-
/// Checks if `#[cmse_nonsecure_entry]` is applied to a function definition.
437-
fn check_cmse_nonsecure_entry(
438-
&self,
439-
hir_id: HirId,
440-
attr: &Attribute,
441-
span: Span,
442-
target: Target,
443-
) -> bool {
444-
match target {
445-
Target::Fn
446-
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true,
447-
_ => {
448-
self.dcx().emit_err(errors::AttrShouldBeAppliedToFn {
449-
attr_span: attr.span,
450-
defn_span: span,
451-
on_crate: hir_id == CRATE_HIR_ID,
452-
});
453-
false
454-
}
455-
}
456-
}
457-
458433
/// Debugging aid for `object_lifetime_default` query.
459434
fn check_object_lifetime_default(&self, hir_id: HirId) {
460435
let tcx = self.tcx;

compiler/rustc_target/src/spec/mod.rs

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

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)