Merge #272
272: Add the RISC-V entry point assembly to libtock_runtime r=hudson-ayers a=jrvanwhy
To support the entry point assembly, I rewrote the linker script ([link to the new version](https://github.com/jrvanwhy/libtock-rs/blob/riscv-asm/core/runtime/layout_generic.ld) in case you don't want to see the diff).
The rust toolchain is unable to compile raw assembly files on its own. I don't want a separate toolchain to be a build requirement of `libtock-rs`, so instead I committed the compiled library into the repository. To keep the compiled library and source code in sync, I added an actions workflow that verifies the compiled library matches the provided sources.
There is one part of this PR I am unhappy with. I have to manually `strip` local symbols from the compiled library -- i.e., removing the `riscv64-linux-gnu-strip` invocation from `assemble.sh` gives the following:
```
Disassembly of section .start:
00000000 <start>:
0: 00000417 auipc s0,0x0
4: 87aa mv a5,a0
6: 4384 lw s1,0(a5)
8: 00940c63 beq s0,s1,20 <.Lset_brk>
c: 4521 li a0,8
e: 4585 li a1,1
10: 4609 li a2,2
12: 4709 li a4,2
14: 00000073 ecall
18: 4501 li a0,0
1a: 4719 li a4,6
1c: 00000073 ecall
00000020 <.Lset_brk>:
20: 4501 li a0,0
22: 43cc lw a1,4(a5)
24: 4715 li a4,5
26: 00000073 ecall
2a: 0087a103 lw sp,8(a5)
2e: 47c8 lw a0,12(a5)
30: c909 beqz a0,42 <.Lzero_bss>
32: 4b8c lw a1,16(a5)
34: 4bd0 lw a2,20(a5)
00000036 <.Ldata_loop_body>:
36: 4194 lw a3,0(a1)
38: c214 sw a3,0(a2)
3a: 1571 addi a0,a0,-4
3c: 0591 addi a1,a1,4
3e: 0611 addi a2,a2,4
40: f97d bnez a0,36 <.Ldata_loop_body>
00000042 <.Lzero_bss>:
42: 4f88 lw a0,24(a5)
44: c519 beqz a0,52 <.Lcall_rust_start>
46: 4fcc lw a1,28(a5)
00000048 <.Lbss_loop_body>:
48: 00058023 sb zero,0(a1)
4c: 157d addi a0,a0,-1
4e: 0585 addi a1,a1,1
50: fd65 bnez a0,48 <.Lbss_loop_body>
00000052 <.Lcall_rust_start>:
52: fafff0ef jal ra,0 <start>
```
I'd appreciate advice on how to prevent `riscv64-linux-gnu-as` from including the local symbols in its output.
Co-authored-by: Johnathan Van Why <jrvanwhy@google.com>
diff --git a/.cargo/config b/.cargo/config
index 96fe275..8292c1c 100644
--- a/.cargo/config
+++ b/.cargo/config
@@ -6,10 +6,6 @@
rthumbv7em = "run --release --target=thumbv7em-none-eabi --example"
rtv7em = "rthumbv7em"
-# Deny warnings on all architectures. build.rustflags cannot be used here as the lower section would override its effect.
-[target.'cfg(all())']
-rustflags = ["-D", "warnings"]
-
# Common settings for all embedded targets
[target.'cfg(any(target_arch = "arm", target_arch = "riscv32"))']
rustflags = [
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f62bca8..e9b448b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -35,9 +35,16 @@
# makefile can be tested locally. We experimentally determined that -j2 is
# optimal for the Azure Standard_DS2_v2 VM, which is the VM type used by
# GitHub Actions at the time of this writing.
+ #
+ # We have to append the "-D warnings" flag to .cargo/config rather than
+ # using the RUSTFLAGS environment variable because if we set RUSTFLAGS
+ # cargo will ignore the rustflags config in .cargo/config, breaking
+ # relocation.
- name: Build and Test
run: |
sudo apt-get install binutils-riscv64-unknown-elf
cd "${GITHUB_WORKSPACE}"
+ echo "[target.'cfg(all())']" >> .cargo/config
+ echo 'rustflags = ["-D", "warnings"]' >> .cargo/config
make -j2 setup
make -j2 test