Merge #206
206: Update the Rust toolchain to nightly-2020-06-10. r=jrvanwhy a=jrvanwhy
This toolchain update renamed `asm` to `llvm_asm`, and should have the new `asm` syntax. I simply renamed `asm` to `llvm_asm` in this commit. I will send PRs later that refactor the system call interface and entry point; those PRs will replace the uses of `llvm_asm` with the new `asm`.
Co-authored-by: Johnathan Van Why <jrvanwhy@google.com>
diff --git a/.github/workflows/size-diff.yml b/.github/workflows/size-diff.yml
index 4d14308..6f8c7d0 100644
--- a/.github/workflows/size-diff.yml
+++ b/.github/workflows/size-diff.yml
@@ -44,6 +44,7 @@
git remote set-branches "${UPSTREAM_REMOTE_NAME}" "${GITHUB_BASE_REF}"
git fetch --depth=1 "${UPSTREAM_REMOTE_NAME}" "${GITHUB_BASE_REF}"
git checkout "${UPSTREAM_REMOTE_NAME}/${GITHUB_BASE_REF}"
+ rustup target add riscv32imc-unknown-none-elf thumbv7em-none-eabi
make -j2 examples
cargo run --release -p print_sizes >'${{runner.temp}}/base-sizes'
diff --git a/core/src/debug/platform_arm.rs b/core/src/debug/platform_arm.rs
index 46211b3..a777334 100644
--- a/core/src/debug/platform_arm.rs
+++ b/core/src/debug/platform_arm.rs
@@ -1,5 +1,5 @@
pub fn get_stack_pointer() -> usize {
let stack_pointer;
- unsafe { asm!("mov $0, sp" : "=r"(stack_pointer) : : : "volatile") };
+ unsafe { llvm_asm!("mov $0, sp" : "=r"(stack_pointer) : : : "volatile") };
stack_pointer
}
diff --git a/core/src/debug/platform_riscv32.rs b/core/src/debug/platform_riscv32.rs
index 7f4a4e0..c276442 100644
--- a/core/src/debug/platform_riscv32.rs
+++ b/core/src/debug/platform_riscv32.rs
@@ -1,5 +1,5 @@
pub fn get_stack_pointer() -> usize {
let stack_pointer;
- unsafe { asm!("mv $0, sp" : "=r"(stack_pointer) : : : "volatile") };
+ unsafe { llvm_asm!("mv $0, sp" : "=r"(stack_pointer) : : : "volatile") };
stack_pointer
}
diff --git a/core/src/entry_point/start_item_arm.rs b/core/src/entry_point/start_item_arm.rs
index c9390f6..757e556 100644
--- a/core/src/entry_point/start_item_arm.rs
+++ b/core/src/entry_point/start_item_arm.rs
@@ -12,7 +12,7 @@
_memory_len: usize,
app_heap_break: usize,
) -> ! {
- asm!("
+ llvm_asm!("
// Because ROPI-RWPI support in LLVM/rustc is incomplete, Rust
// applications must be statically linked. An offset between the
// location the program is linked at and its actual location in flash
diff --git a/core/src/entry_point/start_item_riscv32.rs b/core/src/entry_point/start_item_riscv32.rs
index 347400c..f8a0e19 100644
--- a/core/src/entry_point/start_item_riscv32.rs
+++ b/core/src/entry_point/start_item_riscv32.rs
@@ -14,7 +14,7 @@
// Due to Rust issue: https://github.com/rust-lang/rust/issues/42779 we can't have
// args to the function
pub unsafe extern "C" fn _start() -> ! {
- asm!(
+ llvm_asm!(
// Compute the stack top.
//
// struct hdr* myhdr = (struct hdr*) app_start;
@@ -105,7 +105,7 @@
#[export_name = "abort"]
pub extern "C" fn abort() {
unsafe {
- asm! ("
+ llvm_asm! ("
// Simply go back to the start as if we had just booted.
j _start
"
diff --git a/core/src/lib.rs b/core/src/lib.rs
index e465f4d..f451950 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -1,4 +1,4 @@
-#![feature(asm, lang_items, naked_functions)]
+#![feature(lang_items, llvm_asm, naked_functions)]
#![cfg_attr(any(target_arch = "arm", target_arch = "riscv32"), no_std)]
#![cfg_attr(feature = "alloc", feature(alloc_error_handler))]
diff --git a/core/src/syscalls/platform_arm.rs b/core/src/syscalls/platform_arm.rs
index 4ff146a..066459e 100644
--- a/core/src/syscalls/platform_arm.rs
+++ b/core/src/syscalls/platform_arm.rs
@@ -22,7 +22,7 @@
// registers r4-r8, r10, r11 and SP (and r9 in PCS variants that designate
// r9 as v6) As our compilation flags mark r9 as the PIC base register, it
// does not need to be saved. Thus we must clobber r0-3, r12, and LR
- asm!(
+ llvm_asm!(
"svc 0"
:
:
@@ -40,7 +40,7 @@
ud: usize,
) -> isize {
let res;
- asm!("svc 1" : "={r0}"(res)
+ llvm_asm!("svc 1" : "={r0}"(res)
: "{r0}"(major) "{r1}"(minor) "{r2}"(cb) "{r3}"(ud)
: "memory"
: "volatile");
@@ -52,7 +52,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn command(major: usize, minor: usize, arg1: usize, arg2: usize) -> isize {
let res;
- asm!("svc 2" : "={r0}"(res)
+ llvm_asm!("svc 2" : "={r0}"(res)
: "{r0}"(major) "{r1}"(minor) "{r2}"(arg1) "{r3}"(arg2)
: "memory"
: "volatile");
@@ -64,7 +64,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn command1(major: usize, minor: usize, arg: usize) -> isize {
let res;
- asm!("svc 2" : "={r0}"(res)
+ llvm_asm!("svc 2" : "={r0}"(res)
: "{r0}"(major) "{r1}"(minor) "{r2}"(arg)
: "memory"
: "volatile");
@@ -76,7 +76,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn allow(major: usize, minor: usize, slice: *mut u8, len: usize) -> isize {
let res;
- asm!("svc 3" : "={r0}"(res)
+ llvm_asm!("svc 3" : "={r0}"(res)
: "{r0}"(major) "{r1}"(minor) "{r2}"(slice) "{r3}"(len)
: "memory"
: "volatile");
@@ -88,7 +88,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn memop(major: u32, arg1: usize) -> isize {
let res;
- asm!("svc 4" : "={r0}"(res)
+ llvm_asm!("svc 4" : "={r0}"(res)
: "{r0}"(major) "{r1}"(arg1)
: "memory"
: "volatile");
diff --git a/core/src/syscalls/platform_riscv32.rs b/core/src/syscalls/platform_riscv32.rs
index f7d1858..f2c49fe 100644
--- a/core/src/syscalls/platform_riscv32.rs
+++ b/core/src/syscalls/platform_riscv32.rs
@@ -3,7 +3,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn yieldk() {
/* TODO: Stop yielding */
- asm! (
+ llvm_asm! (
"li a0, 0
ecall"
:
@@ -23,7 +23,7 @@
ud: usize,
) -> isize {
let res;
- asm!("li a0, 1
+ llvm_asm!("li a0, 1
ecall"
: "={x10}" (res)
: "{x11}" (major), "{x12}" (minor), "{x13}" (cb), "{x14}" (ud)
@@ -37,7 +37,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn command(major: usize, minor: usize, arg1: usize, arg2: usize) -> isize {
let res;
- asm!("li a0, 2
+ llvm_asm!("li a0, 2
ecall"
: "={x10}" (res)
: "{x11}" (major), "{x12}" (minor), "{x13}" (arg1), "{x14}" (arg2)
@@ -51,7 +51,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn command1(major: usize, minor: usize, arg: usize) -> isize {
let res;
- asm!("li a0, 2
+ llvm_asm!("li a0, 2
ecall"
: "={x10}" (res)
: "{x11}" (major), "{x12}" (minor), "{x13}" (arg)
@@ -65,7 +65,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn allow(major: usize, minor: usize, slice: *mut u8, len: usize) -> isize {
let res;
- asm!("li a0, 3
+ llvm_asm!("li a0, 3
ecall"
: "={x10}" (res)
: "{x11}" (major), "{x12}" (minor), "{x13}" (slice), "{x14}" (len)
@@ -79,7 +79,7 @@
#[allow(clippy::missing_safety_doc)]
pub unsafe fn memop(major: u32, arg1: usize) -> isize {
let res;
- asm!("li a0, 4
+ llvm_asm!("li a0, 4
ecall"
: "={x10}" (res)
: "{x11}" (major), "{x12}" (arg1)
diff --git a/rust-toolchain b/rust-toolchain
index 8bd4ff0..4aec5c6 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1 +1 @@
-nightly-2020-04-06
+nightly-2020-06-10
diff --git a/src/hmac.rs b/src/hmac.rs
index e5475cc..5185128 100644
--- a/src/hmac.rs
+++ b/src/hmac.rs
@@ -99,7 +99,7 @@
syscalls::allow(DRIVER_NUMBER, allow_nr::DEST, &mut buffer.buffer).map_err(Into::into)
}
- pub fn subscribe<CB: FnMut(usize, usize) -> () + FnMut(usize, usize)>(
+ pub fn subscribe<CB: FnMut(usize, usize)>(
&self,
callback: &'a mut CB,
) -> TockResult<CallbackSubscription> {