Skip to content

Commit 5722a80

Browse files
committed
remove #[cmse_nonsecure_entry]
1 parent 1ddd67a commit 5722a80

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
@@ -483,9 +483,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
483483
let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx);
484484
attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]);
485485
}
486-
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) {
487-
to_add.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry"));
488-
}
489486
if let Some(align) = codegen_fn_attrs.alignment {
490487
llvm::set_alignment(llfn, align);
491488
}

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
@@ -681,4 +681,5 @@ E0800: 0800,
681681
// E0723, // unstable feature in `const` context
682682
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
683683
// E0744, // merged into E0728
684+
// E0776, // Removed; cmse_nonsecure_entry is now `C-cmse-nonsecure-entry`
684685
// E0796, // unused error code. We use `static_mut_refs` lint instead.

compiler/rustc_feature/src/builtin_attrs.rs

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

554-
gated!(
555-
cmse_nonsecure_entry, Normal, template!(Word), WarnFollowing,
556-
EncodeCrossCrate::No, experimental!(cmse_nonsecure_entry)
557-
),
558554
// RFC 2632
559555
gated!(
560556
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
@@ -395,7 +395,7 @@ declare_features! (
395395
(unstable, closure_lifetime_binder, "1.64.0", Some(97362)),
396396
/// Allows `#[track_caller]` on closures and coroutines.
397397
(unstable, closure_track_caller, "1.57.0", Some(87417)),
398-
/// Allows to use the `#[cmse_nonsecure_entry]` attribute.
398+
/// Allows `extern "C-cmse-nonsecure-entry" fn()`.
399399
(unstable, cmse_nonsecure_entry, "1.48.0", Some(75835)),
400400
/// Allows `async {}` expressions in const contexts.
401401
(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
@@ -188,9 +188,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
188188
| [sym::rustc_must_implement_one_of, ..]
189189
| [sym::rustc_deny_explicit_impl, ..]
190190
| [sym::const_trait, ..] => self.check_must_be_applied_to_trait(attr, span, target),
191-
[sym::cmse_nonsecure_entry, ..] => {
192-
self.check_cmse_nonsecure_entry(hir_id, attr, span, target)
193-
}
194191
[sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
195192
[sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),
196193
[sym::must_use, ..] => self.check_must_use(hir_id, attr, target),
@@ -563,27 +560,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
563560
}
564561
}
565562

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

src/tools/tidy/src/issues.txt

Lines changed: 0 additions & 1 deletion
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
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
// This checks that the attribute validation ICE in issue #105594 doesn't
22
// recur.
3-
//
4-
//@ ignore-thumbv8m.base-none-eabi
5-
#![feature(cmse_nonsecure_entry)]
63

74
fn main() {}
85

96
#[track_caller] //~ ERROR attribute should be applied to a function
107
static _A: () = ();
11-
12-
#[cmse_nonsecure_entry] //~ ERROR attribute should be applied to a function
13-
static _B: () = (); //~| ERROR #[cmse_nonsecure_entry]` is only valid for targets
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
error[E0739]: attribute should be applied to a function definition
2-
--> $DIR/issue-105594-invalid-attr-validation.rs:9:1
2+
--> $DIR/issue-105594-invalid-attr-validation.rs:6:1
33
|
44
LL | #[track_caller]
55
| ^^^^^^^^^^^^^^^
66
LL | static _A: () = ();
77
| ------------------- not a function definition
88

9-
error: attribute should be applied to a function definition
10-
--> $DIR/issue-105594-invalid-attr-validation.rs:12:1
11-
|
12-
LL | #[cmse_nonsecure_entry]
13-
| ^^^^^^^^^^^^^^^^^^^^^^^
14-
LL | static _B: () = ();
15-
| ------------------- not a function definition
16-
17-
error[E0775]: `#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension
18-
--> $DIR/issue-105594-invalid-attr-validation.rs:12:1
19-
|
20-
LL | #[cmse_nonsecure_entry]
21-
| ^^^^^^^^^^^^^^^^^^^^^^^
22-
23-
error: aborting due to 3 previous errors
9+
error: aborting due to 1 previous error
2410

25-
Some errors have detailed explanations: E0739, E0775.
26-
For more information about an error, try `rustc --explain E0739`.
11+
For more information about this error, try `rustc --explain E0739`.

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

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

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

Lines changed: 0 additions & 9 deletions
This file was deleted.

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
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+
#![crate_type = "lib"]
7+
#[lang = "sized"]
8+
trait Sized {}
9+
#[lang = "copy"]
10+
trait Copy {}
1011
impl Copy for u32 {}
1112

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

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

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

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

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

Lines changed: 0 additions & 16 deletions
This file was deleted.

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

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)