Skip to content

Commit

Permalink
rt: use naked_asm! to ensure the library builds under nightly 2024-…
Browse files Browse the repository at this point in the history
…10-07

This feature has been added recently in this pull request: rust-lang/rust#128651

After this pull, `core::arch::asm!` can no longer be used in #[naked] functions. We should use `core::arch::naked_asm!` instead.

Tested rustc version:

```
rustc -vV
rustc 1.83.0-nightly (3ae715c8c 2024-10-07)
binary: rustc
commit-hash: 3ae715c8c63f9aeac47cbf7d8d9dadb3fa32c638
commit-date: 2024-10-07
host: x86_64-pc-windows-msvc
release: 1.83.0-nightly
LLVM version: 19.1.1
```

Signed-off-by: Zhouqi Jiang <luojia@hust.edu.cn>
  • Loading branch information
luojia65 committed Oct 8, 2024
1 parent 26dbc93 commit 5a4b5d3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions allwinner-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! /* code */
//! }
//! ```
#![feature(naked_functions, asm_const)]
#![feature(naked_functions)]
#![no_std]

#[macro_use]
Expand All @@ -26,8 +26,6 @@ pub use mctl::init as dram_init;

pub use allwinner_rt_macros::entry;

use core::arch::asm;

pub mod soc {
pub mod d1;
}
Expand Down Expand Up @@ -61,7 +59,7 @@ unsafe extern "C" fn start() -> ! {
const STACK_SIZE: usize = 4 * 1024;
#[link_section = ".bss.uninit"]
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
asm!(
core::arch::naked_asm!(
// Enable T-Head ISA extension
"li t1, 1 << 22",
"csrs 0x7C0, t1",
Expand Down Expand Up @@ -102,7 +100,6 @@ unsafe extern "C" fn start() -> ! {
stack = sym STACK,
stack_size = const STACK_SIZE,
main = sym main,
options(noreturn)
)
}

Expand Down

0 comments on commit 5a4b5d3

Please sign in to comment.