From bf9e88a28be9eb3793d8a65a15dacd5e165c541b Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Sun, 16 Jun 2024 11:09:55 -0400 Subject: [PATCH 01/33] Start compile via .cargo/config.toml --- .cargo/config.toml | 13 +++++++++++++ boards/build.rs | 2 ++ boards/nordic/nrf52840dk/.cargo/config.toml | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 boards/nordic/nrf52840dk/.cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000..210997184e --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,13 @@ +[build] +rustflags = [ + "-C", "linker=rust-lld", + "-C", "linker-flavor=ld.lld", + "-C", "relocation-model=static", + "-C", "link-arg=-nmagic", + "-C", "link-arg=-icf=all", + "-C", "symbol-mangling-version=v0", +] + +[unstable] +unstable-options = true +build-std = ["core", "alloc", "compiler_builtins" ] diff --git a/boards/build.rs b/boards/build.rs index fa0978410d..a74d4b20b7 100644 --- a/boards/build.rs +++ b/boards/build.rs @@ -24,6 +24,8 @@ fn main() { panic!("Boards must provide a `layout.ld` link script file"); } + println!("cargo:rustc-link-arg=-L{}", std::env!("CARGO_MANIFEST_DIR")); + track_linker_script(LINKER_SCRIPT); } diff --git a/boards/nordic/nrf52840dk/.cargo/config.toml b/boards/nordic/nrf52840dk/.cargo/config.toml new file mode 100644 index 0000000000..5c677cd5bf --- /dev/null +++ b/boards/nordic/nrf52840dk/.cargo/config.toml @@ -0,0 +1,7 @@ +[build] +target = "thumbv7em-none-eabi" +rustflags = [ + "-C", "link-arg=-Tlayout.ld", + "-C", "lto", +] + From 76b58dedff616de59dfa942e3835d024d884d1f2 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Mon, 17 Jun 2024 18:14:15 -0400 Subject: [PATCH 02/33] Rebase with 4382e5572340d1b0486fa1df3e05f696e4fafa4b --- .cargo/config.toml | 17 +++++++++++++++++ boards/build.rs | 1 + boards/nordic/.cargo/config.toml | 3 +++ boards/nordic/nrf52840dk/.cargo/config.toml | 7 ------- 4 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 boards/nordic/.cargo/config.toml delete mode 100644 boards/nordic/nrf52840dk/.cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml index 210997184e..f0e8123c90 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,11 +1,28 @@ [build] rustflags = [ + # Tell rustc to use the LLVM linker. This avoids needing GCC as a dependency + # to build the kernel. "-C", "linker=rust-lld", + # Use the LLVM lld executable with the `-flavor gnu` flag. "-C", "linker-flavor=ld.lld", + # Use static relocation model. See https://github.com/tock/tock/pull/2853 "-C", "relocation-model=static", + # lld by default uses a default page size to align program sections. Tock + # expects that program sections are set back-to-back. `-nmagic` instructs the + # linker to not page-align sections. "-C", "link-arg=-nmagic", + # Identical Code Folding (ICF) set to all. This tells the linker to be more + # aggressive about removing duplicate code. The default is `safe`, and the + # downside to `all` is that different functions in the code can end up with + # the same address in the binary. However, it can save a fair bit of code + # size. "-C", "link-arg=-icf=all", + # Opt-in to Rust v0 symbol mangling scheme. See + # https://github.com/rust-lang/rust/issues/60705 and + # https://github.com/tock/tock/issues/3529. "-C", "symbol-mangling-version=v0", + # Enable link-time-optimization + "-C", "lto", ] [unstable] diff --git a/boards/build.rs b/boards/build.rs index a74d4b20b7..823782b491 100644 --- a/boards/build.rs +++ b/boards/build.rs @@ -25,6 +25,7 @@ fn main() { } println!("cargo:rustc-link-arg=-L{}", std::env!("CARGO_MANIFEST_DIR")); + println!("cargo:rustc-link-arg=-T{}", LINKER_SCRIPT); track_linker_script(LINKER_SCRIPT); } diff --git a/boards/nordic/.cargo/config.toml b/boards/nordic/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/nordic/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/nordic/nrf52840dk/.cargo/config.toml b/boards/nordic/nrf52840dk/.cargo/config.toml deleted file mode 100644 index 5c677cd5bf..0000000000 --- a/boards/nordic/nrf52840dk/.cargo/config.toml +++ /dev/null @@ -1,7 +0,0 @@ -[build] -target = "thumbv7em-none-eabi" -rustflags = [ - "-C", "link-arg=-Tlayout.ld", - "-C", "lto", -] - From 26c6fbf2f056d430f6540573a216fe250757a0b3 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Mon, 17 Jun 2024 18:14:42 -0400 Subject: [PATCH 03/33] sma_q3 cargo config and probe-rs --- boards/sma_q3/.cargo/config.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 boards/sma_q3/.cargo/config.toml diff --git a/boards/sma_q3/.cargo/config.toml b/boards/sma_q3/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/sma_q3/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + From 838275317cdbc88f67a0abf3af1b00087014ed70 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Mon, 17 Jun 2024 18:24:06 -0400 Subject: [PATCH 04/33] .cargo/ for all boards --- boards/acd52832/.cargo/config.toml | 3 +++ boards/apollo3/.cargo/config.toml | 3 +++ boards/arty_e21/.cargo/config.toml | 3 +++ boards/clue_nrf52840/.cargo/config.toml | 3 +++ boards/configurations/nrf52840dk/.cargo/config.toml | 3 +++ boards/esp32-c3-devkitM-1/.cargo/config.toml | 5 ++--- boards/hail/.cargo/config.toml | 3 +++ boards/hifive1/.cargo/config.toml | 3 +++ boards/hifive_inventor/.cargo/config.toml | 3 +++ boards/imix/.cargo/config.toml | 3 +++ boards/imxrt1050-evkb/.cargo/config.toml | 3 +++ boards/litex/.cargo/config.toml | 3 +++ boards/makepython-nrf52840/.cargo/config.toml | 3 +++ boards/microbit_v2/.cargo/config.toml | 3 +++ boards/msp_exp432p401r/.cargo/config.toml | 3 +++ boards/nano33ble/.cargo/config.toml | 3 +++ boards/nano33ble_rev2/.cargo/config.toml | 3 +++ boards/nano_rp2040_connect/.cargo/config.toml | 3 +++ boards/nucleo_f429zi/.cargo/config.toml | 3 +++ boards/nucleo_f446re/.cargo/config.toml | 3 +++ boards/opentitan/.cargo/config.toml | 3 +++ boards/particle_boron/.cargo/config.toml | 3 +++ boards/pico_explorer_base/.cargo/config.toml | 3 +++ boards/qemu_rv32_virt/.cargo/config.toml | 3 +++ boards/raspberry_pi_pico/.cargo/config.toml | 3 +++ boards/redboard_redv/.cargo/config.toml | 3 +++ boards/stm32f3discovery/.cargo/config.toml | 3 +++ boards/stm32f412gdiscovery/.cargo/config.toml | 3 +++ boards/stm32f429idiscovery/.cargo/config.toml | 3 +++ boards/swervolf/.cargo/config.toml | 3 +++ boards/teensy40/.cargo/config.toml | 3 +++ boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml | 3 +++ .../tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml | 3 +++ boards/weact_f401ccu6/.cargo/config.toml | 3 +++ boards/wm1110dev/.cargo/config.toml | 3 +++ 35 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 boards/acd52832/.cargo/config.toml create mode 100644 boards/apollo3/.cargo/config.toml create mode 100644 boards/arty_e21/.cargo/config.toml create mode 100644 boards/clue_nrf52840/.cargo/config.toml create mode 100644 boards/configurations/nrf52840dk/.cargo/config.toml create mode 100644 boards/hail/.cargo/config.toml create mode 100644 boards/hifive1/.cargo/config.toml create mode 100644 boards/hifive_inventor/.cargo/config.toml create mode 100644 boards/imix/.cargo/config.toml create mode 100644 boards/imxrt1050-evkb/.cargo/config.toml create mode 100644 boards/litex/.cargo/config.toml create mode 100644 boards/makepython-nrf52840/.cargo/config.toml create mode 100644 boards/microbit_v2/.cargo/config.toml create mode 100644 boards/msp_exp432p401r/.cargo/config.toml create mode 100644 boards/nano33ble/.cargo/config.toml create mode 100644 boards/nano33ble_rev2/.cargo/config.toml create mode 100644 boards/nano_rp2040_connect/.cargo/config.toml create mode 100644 boards/nucleo_f429zi/.cargo/config.toml create mode 100644 boards/nucleo_f446re/.cargo/config.toml create mode 100644 boards/opentitan/.cargo/config.toml create mode 100644 boards/particle_boron/.cargo/config.toml create mode 100644 boards/pico_explorer_base/.cargo/config.toml create mode 100644 boards/qemu_rv32_virt/.cargo/config.toml create mode 100644 boards/raspberry_pi_pico/.cargo/config.toml create mode 100644 boards/redboard_redv/.cargo/config.toml create mode 100644 boards/stm32f3discovery/.cargo/config.toml create mode 100644 boards/stm32f412gdiscovery/.cargo/config.toml create mode 100644 boards/stm32f429idiscovery/.cargo/config.toml create mode 100644 boards/swervolf/.cargo/config.toml create mode 100644 boards/teensy40/.cargo/config.toml create mode 100644 boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml create mode 100644 boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml create mode 100644 boards/weact_f401ccu6/.cargo/config.toml create mode 100644 boards/wm1110dev/.cargo/config.toml diff --git a/boards/acd52832/.cargo/config.toml b/boards/acd52832/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/acd52832/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/apollo3/.cargo/config.toml b/boards/apollo3/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/apollo3/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/arty_e21/.cargo/config.toml b/boards/arty_e21/.cargo/config.toml new file mode 100644 index 0000000000..5ffa170df1 --- /dev/null +++ b/boards/arty_e21/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "riscv32imac-unknown-none-elf" + diff --git a/boards/clue_nrf52840/.cargo/config.toml b/boards/clue_nrf52840/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/clue_nrf52840/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/configurations/nrf52840dk/.cargo/config.toml b/boards/configurations/nrf52840dk/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/configurations/nrf52840dk/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/esp32-c3-devkitM-1/.cargo/config.toml b/boards/esp32-c3-devkitM-1/.cargo/config.toml index 7efa9d922a..83b1634f71 100644 --- a/boards/esp32-c3-devkitM-1/.cargo/config.toml +++ b/boards/esp32-c3-devkitM-1/.cargo/config.toml @@ -1,6 +1,5 @@ -# Licensed under the Apache License, Version 2.0 or the MIT License. -# SPDX-License-Identifier: Apache-2.0 OR MIT -# Copyright Tock Contributors 2022. +[build] +target = "riscv32imc-unknown-none-elf" [target.'cfg(target_arch = "riscv32")'] runner = "./run.sh" diff --git a/boards/hail/.cargo/config.toml b/boards/hail/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/hail/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/hifive1/.cargo/config.toml b/boards/hifive1/.cargo/config.toml new file mode 100644 index 0000000000..5ffa170df1 --- /dev/null +++ b/boards/hifive1/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "riscv32imac-unknown-none-elf" + diff --git a/boards/hifive_inventor/.cargo/config.toml b/boards/hifive_inventor/.cargo/config.toml new file mode 100644 index 0000000000..5ffa170df1 --- /dev/null +++ b/boards/hifive_inventor/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "riscv32imac-unknown-none-elf" + diff --git a/boards/imix/.cargo/config.toml b/boards/imix/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/imix/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/imxrt1050-evkb/.cargo/config.toml b/boards/imxrt1050-evkb/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/imxrt1050-evkb/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/litex/.cargo/config.toml b/boards/litex/.cargo/config.toml new file mode 100644 index 0000000000..83fdf3f2fc --- /dev/null +++ b/boards/litex/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "riscv32imc-unknown-none-elf" + diff --git a/boards/makepython-nrf52840/.cargo/config.toml b/boards/makepython-nrf52840/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/makepython-nrf52840/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/microbit_v2/.cargo/config.toml b/boards/microbit_v2/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/microbit_v2/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/msp_exp432p401r/.cargo/config.toml b/boards/msp_exp432p401r/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/msp_exp432p401r/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/nano33ble/.cargo/config.toml b/boards/nano33ble/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/nano33ble/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/nano33ble_rev2/.cargo/config.toml b/boards/nano33ble_rev2/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/nano33ble_rev2/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/nano_rp2040_connect/.cargo/config.toml b/boards/nano_rp2040_connect/.cargo/config.toml new file mode 100644 index 0000000000..1eb8b79555 --- /dev/null +++ b/boards/nano_rp2040_connect/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv6m-none-eabi" + diff --git a/boards/nucleo_f429zi/.cargo/config.toml b/boards/nucleo_f429zi/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/nucleo_f429zi/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/nucleo_f446re/.cargo/config.toml b/boards/nucleo_f446re/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/nucleo_f446re/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/opentitan/.cargo/config.toml b/boards/opentitan/.cargo/config.toml new file mode 100644 index 0000000000..83fdf3f2fc --- /dev/null +++ b/boards/opentitan/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "riscv32imc-unknown-none-elf" + diff --git a/boards/particle_boron/.cargo/config.toml b/boards/particle_boron/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/particle_boron/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/pico_explorer_base/.cargo/config.toml b/boards/pico_explorer_base/.cargo/config.toml new file mode 100644 index 0000000000..1eb8b79555 --- /dev/null +++ b/boards/pico_explorer_base/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv6m-none-eabi" + diff --git a/boards/qemu_rv32_virt/.cargo/config.toml b/boards/qemu_rv32_virt/.cargo/config.toml new file mode 100644 index 0000000000..5ffa170df1 --- /dev/null +++ b/boards/qemu_rv32_virt/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "riscv32imac-unknown-none-elf" + diff --git a/boards/raspberry_pi_pico/.cargo/config.toml b/boards/raspberry_pi_pico/.cargo/config.toml new file mode 100644 index 0000000000..1eb8b79555 --- /dev/null +++ b/boards/raspberry_pi_pico/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv6m-none-eabi" + diff --git a/boards/redboard_redv/.cargo/config.toml b/boards/redboard_redv/.cargo/config.toml new file mode 100644 index 0000000000..5ffa170df1 --- /dev/null +++ b/boards/redboard_redv/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "riscv32imac-unknown-none-elf" + diff --git a/boards/stm32f3discovery/.cargo/config.toml b/boards/stm32f3discovery/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/stm32f3discovery/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/stm32f412gdiscovery/.cargo/config.toml b/boards/stm32f412gdiscovery/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/stm32f412gdiscovery/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/stm32f429idiscovery/.cargo/config.toml b/boards/stm32f429idiscovery/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/stm32f429idiscovery/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/swervolf/.cargo/config.toml b/boards/swervolf/.cargo/config.toml new file mode 100644 index 0000000000..83fdf3f2fc --- /dev/null +++ b/boards/swervolf/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "riscv32imc-unknown-none-elf" + diff --git a/boards/teensy40/.cargo/config.toml b/boards/teensy40/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/teensy40/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml b/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml b/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + diff --git a/boards/weact_f401ccu6/.cargo/config.toml b/boards/weact_f401ccu6/.cargo/config.toml new file mode 100644 index 0000000000..c3307020cd --- /dev/null +++ b/boards/weact_f401ccu6/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabihf" + diff --git a/boards/wm1110dev/.cargo/config.toml b/boards/wm1110dev/.cargo/config.toml new file mode 100644 index 0000000000..48cfc7ff33 --- /dev/null +++ b/boards/wm1110dev/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "thumbv7em-none-eabi" + From a75c5d28a9740824b3dd55d378797f410156d1e0 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Fri, 28 Jun 2024 19:45:19 -0400 Subject: [PATCH 05/33] Merge .cargo/config.toml from top-level and boards --- {.cargo => boards/.cargo}/config.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename {.cargo => boards/.cargo}/config.toml (95%) diff --git a/.cargo/config.toml b/boards/.cargo/config.toml similarity index 95% rename from .cargo/config.toml rename to boards/.cargo/config.toml index f0e8123c90..a45bc3fe96 100644 --- a/.cargo/config.toml +++ b/boards/.cargo/config.toml @@ -27,4 +27,5 @@ rustflags = [ [unstable] unstable-options = true -build-std = ["core", "alloc", "compiler_builtins" ] +build-std = ["core", "compiler_builtins" ] + From 02ec372fe8fc5b2824ed4c0d889a4a2567304c59 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Fri, 28 Jun 2024 20:57:24 -0400 Subject: [PATCH 06/33] Add licenses to .cargo/config.toml files --- boards/.cargo/config.toml | 4 ++++ boards/acd52832/.cargo/config.toml | 4 ++++ boards/apollo3/.cargo/config.toml | 4 ++++ boards/arty_e21/.cargo/config.toml | 4 ++++ boards/clue_nrf52840/.cargo/config.toml | 4 ++++ boards/configurations/nrf52840dk/.cargo/config.toml | 4 ++++ boards/esp32-c3-devkitM-1/.cargo/config.toml | 4 ++++ boards/hail/.cargo/config.toml | 4 ++++ boards/hifive1/.cargo/config.toml | 4 ++++ boards/hifive_inventor/.cargo/config.toml | 4 ++++ boards/imix/.cargo/config.toml | 4 ++++ boards/imxrt1050-evkb/.cargo/config.toml | 4 ++++ boards/litex/.cargo/config.toml | 4 ++++ boards/makepython-nrf52840/.cargo/config.toml | 4 ++++ boards/microbit_v2/.cargo/config.toml | 4 ++++ boards/msp_exp432p401r/.cargo/config.toml | 4 ++++ boards/nano33ble/.cargo/config.toml | 4 ++++ boards/nano33ble_rev2/.cargo/config.toml | 4 ++++ boards/nano_rp2040_connect/.cargo/config.toml | 4 ++++ boards/nordic/.cargo/config.toml | 4 ++++ boards/nucleo_f429zi/.cargo/config.toml | 4 ++++ boards/nucleo_f446re/.cargo/config.toml | 4 ++++ boards/opentitan/.cargo/config.toml | 4 ++++ boards/opentitan/earlgrey-cw310/.cargo/config.toml | 4 ++++ boards/particle_boron/.cargo/config.toml | 4 ++++ boards/pico_explorer_base/.cargo/config.toml | 4 ++++ boards/qemu_rv32_virt/.cargo/config.toml | 4 ++++ boards/raspberry_pi_pico/.cargo/config.toml | 4 ++++ boards/redboard_redv/.cargo/config.toml | 4 ++++ boards/sma_q3/.cargo/config.toml | 4 ++++ boards/stm32f3discovery/.cargo/config.toml | 4 ++++ boards/stm32f412gdiscovery/.cargo/config.toml | 4 ++++ boards/stm32f429idiscovery/.cargo/config.toml | 4 ++++ boards/swervolf/.cargo/config.toml | 4 ++++ boards/teensy40/.cargo/config.toml | 4 ++++ boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml | 4 ++++ .../tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml | 4 ++++ boards/weact_f401ccu6/.cargo/config.toml | 4 ++++ boards/wm1110dev/.cargo/config.toml | 4 ++++ 39 files changed, 156 insertions(+) diff --git a/boards/.cargo/config.toml b/boards/.cargo/config.toml index a45bc3fe96..29bddceb63 100644 --- a/boards/.cargo/config.toml +++ b/boards/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] rustflags = [ # Tell rustc to use the LLVM linker. This avoids needing GCC as a dependency diff --git a/boards/acd52832/.cargo/config.toml b/boards/acd52832/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/acd52832/.cargo/config.toml +++ b/boards/acd52832/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/apollo3/.cargo/config.toml b/boards/apollo3/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/apollo3/.cargo/config.toml +++ b/boards/apollo3/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/arty_e21/.cargo/config.toml b/boards/arty_e21/.cargo/config.toml index 5ffa170df1..fd20ef793c 100644 --- a/boards/arty_e21/.cargo/config.toml +++ b/boards/arty_e21/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "riscv32imac-unknown-none-elf" diff --git a/boards/clue_nrf52840/.cargo/config.toml b/boards/clue_nrf52840/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/clue_nrf52840/.cargo/config.toml +++ b/boards/clue_nrf52840/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/configurations/nrf52840dk/.cargo/config.toml b/boards/configurations/nrf52840dk/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/configurations/nrf52840dk/.cargo/config.toml +++ b/boards/configurations/nrf52840dk/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/esp32-c3-devkitM-1/.cargo/config.toml b/boards/esp32-c3-devkitM-1/.cargo/config.toml index 83b1634f71..b81f9115ca 100644 --- a/boards/esp32-c3-devkitM-1/.cargo/config.toml +++ b/boards/esp32-c3-devkitM-1/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2022. + [build] target = "riscv32imc-unknown-none-elf" diff --git a/boards/hail/.cargo/config.toml b/boards/hail/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/hail/.cargo/config.toml +++ b/boards/hail/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/hifive1/.cargo/config.toml b/boards/hifive1/.cargo/config.toml index 5ffa170df1..fd20ef793c 100644 --- a/boards/hifive1/.cargo/config.toml +++ b/boards/hifive1/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "riscv32imac-unknown-none-elf" diff --git a/boards/hifive_inventor/.cargo/config.toml b/boards/hifive_inventor/.cargo/config.toml index 5ffa170df1..fd20ef793c 100644 --- a/boards/hifive_inventor/.cargo/config.toml +++ b/boards/hifive_inventor/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "riscv32imac-unknown-none-elf" diff --git a/boards/imix/.cargo/config.toml b/boards/imix/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/imix/.cargo/config.toml +++ b/boards/imix/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/imxrt1050-evkb/.cargo/config.toml b/boards/imxrt1050-evkb/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/imxrt1050-evkb/.cargo/config.toml +++ b/boards/imxrt1050-evkb/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/litex/.cargo/config.toml b/boards/litex/.cargo/config.toml index 83fdf3f2fc..0d75137dac 100644 --- a/boards/litex/.cargo/config.toml +++ b/boards/litex/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "riscv32imc-unknown-none-elf" diff --git a/boards/makepython-nrf52840/.cargo/config.toml b/boards/makepython-nrf52840/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/makepython-nrf52840/.cargo/config.toml +++ b/boards/makepython-nrf52840/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/microbit_v2/.cargo/config.toml b/boards/microbit_v2/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/microbit_v2/.cargo/config.toml +++ b/boards/microbit_v2/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/msp_exp432p401r/.cargo/config.toml b/boards/msp_exp432p401r/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/msp_exp432p401r/.cargo/config.toml +++ b/boards/msp_exp432p401r/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/nano33ble/.cargo/config.toml b/boards/nano33ble/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/nano33ble/.cargo/config.toml +++ b/boards/nano33ble/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/nano33ble_rev2/.cargo/config.toml b/boards/nano33ble_rev2/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/nano33ble_rev2/.cargo/config.toml +++ b/boards/nano33ble_rev2/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/nano_rp2040_connect/.cargo/config.toml b/boards/nano_rp2040_connect/.cargo/config.toml index 1eb8b79555..584262f585 100644 --- a/boards/nano_rp2040_connect/.cargo/config.toml +++ b/boards/nano_rp2040_connect/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv6m-none-eabi" diff --git a/boards/nordic/.cargo/config.toml b/boards/nordic/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/nordic/.cargo/config.toml +++ b/boards/nordic/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/nucleo_f429zi/.cargo/config.toml b/boards/nucleo_f429zi/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/nucleo_f429zi/.cargo/config.toml +++ b/boards/nucleo_f429zi/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/nucleo_f446re/.cargo/config.toml b/boards/nucleo_f446re/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/nucleo_f446re/.cargo/config.toml +++ b/boards/nucleo_f446re/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/opentitan/.cargo/config.toml b/boards/opentitan/.cargo/config.toml index 83fdf3f2fc..0d75137dac 100644 --- a/boards/opentitan/.cargo/config.toml +++ b/boards/opentitan/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "riscv32imc-unknown-none-elf" diff --git a/boards/opentitan/earlgrey-cw310/.cargo/config.toml b/boards/opentitan/earlgrey-cw310/.cargo/config.toml index 7efa9d922a..2797b152ae 100644 --- a/boards/opentitan/earlgrey-cw310/.cargo/config.toml +++ b/boards/opentitan/earlgrey-cw310/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + # Licensed under the Apache License, Version 2.0 or the MIT License. # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2022. diff --git a/boards/particle_boron/.cargo/config.toml b/boards/particle_boron/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/particle_boron/.cargo/config.toml +++ b/boards/particle_boron/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/pico_explorer_base/.cargo/config.toml b/boards/pico_explorer_base/.cargo/config.toml index 1eb8b79555..584262f585 100644 --- a/boards/pico_explorer_base/.cargo/config.toml +++ b/boards/pico_explorer_base/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv6m-none-eabi" diff --git a/boards/qemu_rv32_virt/.cargo/config.toml b/boards/qemu_rv32_virt/.cargo/config.toml index 5ffa170df1..fd20ef793c 100644 --- a/boards/qemu_rv32_virt/.cargo/config.toml +++ b/boards/qemu_rv32_virt/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "riscv32imac-unknown-none-elf" diff --git a/boards/raspberry_pi_pico/.cargo/config.toml b/boards/raspberry_pi_pico/.cargo/config.toml index 1eb8b79555..584262f585 100644 --- a/boards/raspberry_pi_pico/.cargo/config.toml +++ b/boards/raspberry_pi_pico/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv6m-none-eabi" diff --git a/boards/redboard_redv/.cargo/config.toml b/boards/redboard_redv/.cargo/config.toml index 5ffa170df1..fd20ef793c 100644 --- a/boards/redboard_redv/.cargo/config.toml +++ b/boards/redboard_redv/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "riscv32imac-unknown-none-elf" diff --git a/boards/sma_q3/.cargo/config.toml b/boards/sma_q3/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/sma_q3/.cargo/config.toml +++ b/boards/sma_q3/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/stm32f3discovery/.cargo/config.toml b/boards/stm32f3discovery/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/stm32f3discovery/.cargo/config.toml +++ b/boards/stm32f3discovery/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/stm32f412gdiscovery/.cargo/config.toml b/boards/stm32f412gdiscovery/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/stm32f412gdiscovery/.cargo/config.toml +++ b/boards/stm32f412gdiscovery/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/stm32f429idiscovery/.cargo/config.toml b/boards/stm32f429idiscovery/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/stm32f429idiscovery/.cargo/config.toml +++ b/boards/stm32f429idiscovery/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/swervolf/.cargo/config.toml b/boards/swervolf/.cargo/config.toml index 83fdf3f2fc..0d75137dac 100644 --- a/boards/swervolf/.cargo/config.toml +++ b/boards/swervolf/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "riscv32imc-unknown-none-elf" diff --git a/boards/teensy40/.cargo/config.toml b/boards/teensy40/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/teensy40/.cargo/config.toml +++ b/boards/teensy40/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml b/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml +++ b/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml b/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml +++ b/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" diff --git a/boards/weact_f401ccu6/.cargo/config.toml b/boards/weact_f401ccu6/.cargo/config.toml index c3307020cd..0085b97012 100644 --- a/boards/weact_f401ccu6/.cargo/config.toml +++ b/boards/weact_f401ccu6/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabihf" diff --git a/boards/wm1110dev/.cargo/config.toml b/boards/wm1110dev/.cargo/config.toml index 48cfc7ff33..14ecd93f5c 100644 --- a/boards/wm1110dev/.cargo/config.toml +++ b/boards/wm1110dev/.cargo/config.toml @@ -1,3 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + [build] target = "thumbv7em-none-eabi" From aaa25f7ae9120c3d750f9b7727a5dfe5342f570d Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Sat, 29 Jun 2024 00:09:01 -0400 Subject: [PATCH 07/33] Remove extraneous RUSTFLAGS from Makefile.common --- boards/Makefile.common | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index dff3d8281a..2fd7558da0 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -43,35 +43,6 @@ endif # cargo `--target_dir`. TARGET_DIRECTORY ?= $(TOCK_ROOT_DIRECTORY)target/ -# RUSTC_FLAGS allows boards to define board-specific options. -# This will hopefully move into Cargo.toml (or Cargo.toml.local) eventually. -# -# - `-Tlayout.ld`: Use the linker script `layout.ld` all boards must provide. -# - `linker=rust-lld`: Tell rustc to use the LLVM linker. This avoids needing -# GCC as a dependency to build the kernel. -# - `linker-flavor=ld.lld`: Use the LLVM lld executable with the `-flavor gnu` -# flag. -# - `relocation-model=static`: See https://github.com/tock/tock/pull/2853 -# - `-nmagic`: lld by default uses a default page size to align program -# sections. Tock expects that program sections are set back-to-back. `-nmagic` -# instructs the linker to not page-align sections. -# - `-icf=all`: Identical Code Folding (ICF) set to all. This tells the linker -# to be more aggressive about removing duplicate code. The default is `safe`, -# and the downside to `all` is that different functions in the code can end up -# with the same address in the binary. However, it can save a fair bit of code -# size. -# - `-C symbol-mangling-version=v0`: Opt-in to Rust v0 symbol mangling scheme. -# See https://github.com/rust-lang/rust/issues/60705 and -# https://github.com/tock/tock/issues/3529. -RUSTC_FLAGS ?= \ - -C link-arg=-Tlayout.ld \ - -C linker=rust-lld \ - -C linker-flavor=ld.lld \ - -C relocation-model=static \ - -C link-arg=-nmagic \ - -C link-arg=-icf=all \ - -C symbol-mangling-version=v0 \ - # RISC-V-specific flags. ifneq ($(findstring riscv32i, $(TARGET)),) # NOTE: This flag causes kernel panics on some ARM cores. Since the size From 8877c4d6dbc59dddabd92e8e1dbb5a2e912e653f Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Sat, 29 Jun 2024 00:40:28 -0400 Subject: [PATCH 08/33] Dedup opentitan .cargo/config.toml --- boards/opentitan/.cargo/config.toml | 7 ------- boards/opentitan/earlgrey-cw310/.cargo/config.toml | 11 +++++++---- 2 files changed, 7 insertions(+), 11 deletions(-) delete mode 100644 boards/opentitan/.cargo/config.toml diff --git a/boards/opentitan/.cargo/config.toml b/boards/opentitan/.cargo/config.toml deleted file mode 100644 index 0d75137dac..0000000000 --- a/boards/opentitan/.cargo/config.toml +++ /dev/null @@ -1,7 +0,0 @@ -# Licensed under the Apache License, Version 2.0 or the MIT License. -# SPDX-License-Identifier: Apache-2.0 OR MIT -# Copyright Tock Contributors 2024. - -[build] -target = "riscv32imc-unknown-none-elf" - diff --git a/boards/opentitan/earlgrey-cw310/.cargo/config.toml b/boards/opentitan/earlgrey-cw310/.cargo/config.toml index 2797b152ae..830a6226f2 100644 --- a/boards/opentitan/earlgrey-cw310/.cargo/config.toml +++ b/boards/opentitan/earlgrey-cw310/.cargo/config.toml @@ -1,10 +1,13 @@ -# Licensed under the Apache License, Version 2.0 or the MIT License. -# SPDX-License-Identifier: Apache-2.0 OR MIT -# Copyright Tock Contributors 2024. - # Licensed under the Apache License, Version 2.0 or the MIT License. # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2022. +[build] +target = "riscv32imc-unknown-none-elf" +rustflags = [ + "-Z", "virtual-function-elimination" +] + [target.'cfg(target_arch = "riscv32")'] runner = "./run.sh" + From 786bfb509db0dca9f23644665b9cf0071e4c6845 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Sat, 29 Jun 2024 00:41:09 -0400 Subject: [PATCH 09/33] LTO in debug mode too! --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1f681d02f2..ed668fd384 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,7 +109,7 @@ edition = "2021" [profile.dev] panic = "abort" -lto = false +lto = true opt-level = "z" debug = true From 6d314b810f66dd34b4f7108704e89b33d4866324 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 12:33:57 -0400 Subject: [PATCH 10/33] boards: cargo config: add cargo config folder --- boards/cargo/README.md | 27 +++++++++++++++++++ .../config.toml => cargo/tock_flags.toml} | 5 ---- boards/cargo/unstable_flags.toml | 7 +++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 boards/cargo/README.md rename boards/{.cargo/config.toml => cargo/tock_flags.toml} (94%) create mode 100644 boards/cargo/unstable_flags.toml diff --git a/boards/cargo/README.md b/boards/cargo/README.md new file mode 100644 index 0000000000..edea63c349 --- /dev/null +++ b/boards/cargo/README.md @@ -0,0 +1,27 @@ +Cargo Configuration Files +========================= + +This folder contains [cargo configuration +files](https://doc.rust-lang.org/cargo/reference/config.html) that Tock uses for +building the kernel for different boards. As different platforms use different +flags, each board can individually include these configuration files as needed. + + +Using a Cargo Configuration File +-------------------------------- + +To use one of these configurations in a board build file, the board's +`.cargo/config.toml` file must use the `include` key. This currently (as of July +2024) requires the `config-include` nightly feature. + +Example: + +```toml +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + +[unstable] +config-include = true +``` diff --git a/boards/.cargo/config.toml b/boards/cargo/tock_flags.toml similarity index 94% rename from boards/.cargo/config.toml rename to boards/cargo/tock_flags.toml index 29bddceb63..a96a401b3e 100644 --- a/boards/.cargo/config.toml +++ b/boards/cargo/tock_flags.toml @@ -28,8 +28,3 @@ rustflags = [ # Enable link-time-optimization "-C", "lto", ] - -[unstable] -unstable-options = true -build-std = ["core", "compiler_builtins" ] - diff --git a/boards/cargo/unstable_flags.toml b/boards/cargo/unstable_flags.toml new file mode 100644 index 0000000000..f1a19156cd --- /dev/null +++ b/boards/cargo/unstable_flags.toml @@ -0,0 +1,7 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + +[unstable] +unstable-options = true +build-std = ["core", "compiler_builtins" ] From 14b3d39b7b146420af33b813fbb8bbbc317b89fb Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 12:41:48 -0400 Subject: [PATCH 11/33] boards: add includes in cargo/config.toml --- boards/acd52832/.cargo/config.toml | 7 +++++++ boards/apollo3/.cargo/config.toml | 7 +++++++ boards/arty_e21/.cargo/config.toml | 7 +++++++ boards/clue_nrf52840/.cargo/config.toml | 7 +++++++ boards/configurations/nrf52840dk/.cargo/config.toml | 7 +++++++ boards/esp32-c3-devkitM-1/.cargo/config.toml | 8 ++++++++ boards/hifive1/.cargo/config.toml | 7 +++++++ boards/hifive_inventor/.cargo/config.toml | 7 +++++++ boards/imix/.cargo/config.toml | 7 +++++++ boards/imxrt1050-evkb/.cargo/config.toml | 7 +++++++ boards/litex/.cargo/config.toml | 7 +++++++ boards/makepython-nrf52840/.cargo/config.toml | 7 +++++++ boards/microbit_v2/.cargo/config.toml | 7 +++++++ boards/msp_exp432p401r/.cargo/config.toml | 7 +++++++ boards/nano33ble/.cargo/config.toml | 7 +++++++ boards/nano33ble_rev2/.cargo/config.toml | 7 +++++++ boards/nano_rp2040_connect/.cargo/config.toml | 7 +++++++ boards/nordic/.cargo/config.toml | 7 +++++++ boards/nucleo_f429zi/.cargo/config.toml | 7 +++++++ boards/nucleo_f446re/.cargo/config.toml | 7 +++++++ boards/opentitan/earlgrey-cw310/.cargo/config.toml | 8 ++++++++ boards/particle_boron/.cargo/config.toml | 7 +++++++ boards/pico_explorer_base/.cargo/config.toml | 7 +++++++ boards/qemu_rv32_virt/.cargo/config.toml | 7 +++++++ boards/raspberry_pi_pico/.cargo/config.toml | 7 +++++++ boards/redboard_redv/.cargo/config.toml | 7 +++++++ boards/sma_q3/.cargo/config.toml | 7 +++++++ boards/stm32f3discovery/.cargo/config.toml | 7 +++++++ boards/stm32f412gdiscovery/.cargo/config.toml | 7 +++++++ boards/stm32f429idiscovery/.cargo/config.toml | 7 +++++++ boards/swervolf/.cargo/config.toml | 7 +++++++ boards/teensy40/.cargo/config.toml | 7 +++++++ .../tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml | 7 +++++++ .../nrf52840dk-thread-tutorial/.cargo/config.toml | 7 +++++++ boards/weact_f401ccu6/.cargo/config.toml | 7 +++++++ boards/wm1110dev/.cargo/config.toml | 7 +++++++ 36 files changed, 254 insertions(+) diff --git a/boards/acd52832/.cargo/config.toml b/boards/acd52832/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/acd52832/.cargo/config.toml +++ b/boards/acd52832/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/apollo3/.cargo/config.toml b/boards/apollo3/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/apollo3/.cargo/config.toml +++ b/boards/apollo3/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/arty_e21/.cargo/config.toml b/boards/arty_e21/.cargo/config.toml index fd20ef793c..b285ad3744 100644 --- a/boards/arty_e21/.cargo/config.toml +++ b/boards/arty_e21/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "riscv32imac-unknown-none-elf" +[unstable] +config-include = true diff --git a/boards/clue_nrf52840/.cargo/config.toml b/boards/clue_nrf52840/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/clue_nrf52840/.cargo/config.toml +++ b/boards/clue_nrf52840/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/configurations/nrf52840dk/.cargo/config.toml b/boards/configurations/nrf52840dk/.cargo/config.toml index 14ecd93f5c..1d8a988dc4 100644 --- a/boards/configurations/nrf52840dk/.cargo/config.toml +++ b/boards/configurations/nrf52840dk/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/esp32-c3-devkitM-1/.cargo/config.toml b/boards/esp32-c3-devkitM-1/.cargo/config.toml index b81f9115ca..d42a278849 100644 --- a/boards/esp32-c3-devkitM-1/.cargo/config.toml +++ b/boards/esp32-c3-devkitM-1/.cargo/config.toml @@ -2,8 +2,16 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2022. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "riscv32imc-unknown-none-elf" [target.'cfg(target_arch = "riscv32")'] runner = "./run.sh" + +[unstable] +config-include = true diff --git a/boards/hifive1/.cargo/config.toml b/boards/hifive1/.cargo/config.toml index fd20ef793c..b285ad3744 100644 --- a/boards/hifive1/.cargo/config.toml +++ b/boards/hifive1/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "riscv32imac-unknown-none-elf" +[unstable] +config-include = true diff --git a/boards/hifive_inventor/.cargo/config.toml b/boards/hifive_inventor/.cargo/config.toml index fd20ef793c..b285ad3744 100644 --- a/boards/hifive_inventor/.cargo/config.toml +++ b/boards/hifive_inventor/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "riscv32imac-unknown-none-elf" +[unstable] +config-include = true diff --git a/boards/imix/.cargo/config.toml b/boards/imix/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/imix/.cargo/config.toml +++ b/boards/imix/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/imxrt1050-evkb/.cargo/config.toml b/boards/imxrt1050-evkb/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/imxrt1050-evkb/.cargo/config.toml +++ b/boards/imxrt1050-evkb/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/litex/.cargo/config.toml b/boards/litex/.cargo/config.toml index 0d75137dac..dd0e19cb45 100644 --- a/boards/litex/.cargo/config.toml +++ b/boards/litex/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "riscv32imc-unknown-none-elf" +[unstable] +config-include = true diff --git a/boards/makepython-nrf52840/.cargo/config.toml b/boards/makepython-nrf52840/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/makepython-nrf52840/.cargo/config.toml +++ b/boards/makepython-nrf52840/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/microbit_v2/.cargo/config.toml b/boards/microbit_v2/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/microbit_v2/.cargo/config.toml +++ b/boards/microbit_v2/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/msp_exp432p401r/.cargo/config.toml b/boards/msp_exp432p401r/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/msp_exp432p401r/.cargo/config.toml +++ b/boards/msp_exp432p401r/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/nano33ble/.cargo/config.toml b/boards/nano33ble/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/nano33ble/.cargo/config.toml +++ b/boards/nano33ble/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/nano33ble_rev2/.cargo/config.toml b/boards/nano33ble_rev2/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/nano33ble_rev2/.cargo/config.toml +++ b/boards/nano33ble_rev2/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/nano_rp2040_connect/.cargo/config.toml b/boards/nano_rp2040_connect/.cargo/config.toml index 584262f585..4d568ece43 100644 --- a/boards/nano_rp2040_connect/.cargo/config.toml +++ b/boards/nano_rp2040_connect/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv6m-none-eabi" +[unstable] +config-include = true diff --git a/boards/nordic/.cargo/config.toml b/boards/nordic/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/nordic/.cargo/config.toml +++ b/boards/nordic/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/nucleo_f429zi/.cargo/config.toml b/boards/nucleo_f429zi/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/nucleo_f429zi/.cargo/config.toml +++ b/boards/nucleo_f429zi/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/nucleo_f446re/.cargo/config.toml b/boards/nucleo_f446re/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/nucleo_f446re/.cargo/config.toml +++ b/boards/nucleo_f446re/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/opentitan/earlgrey-cw310/.cargo/config.toml b/boards/opentitan/earlgrey-cw310/.cargo/config.toml index 830a6226f2..8d706cf3af 100644 --- a/boards/opentitan/earlgrey-cw310/.cargo/config.toml +++ b/boards/opentitan/earlgrey-cw310/.cargo/config.toml @@ -2,6 +2,12 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2022. +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", +] + [build] target = "riscv32imc-unknown-none-elf" rustflags = [ @@ -11,3 +17,5 @@ rustflags = [ [target.'cfg(target_arch = "riscv32")'] runner = "./run.sh" +[unstable] +config-include = true diff --git a/boards/particle_boron/.cargo/config.toml b/boards/particle_boron/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/particle_boron/.cargo/config.toml +++ b/boards/particle_boron/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/pico_explorer_base/.cargo/config.toml b/boards/pico_explorer_base/.cargo/config.toml index 584262f585..4d568ece43 100644 --- a/boards/pico_explorer_base/.cargo/config.toml +++ b/boards/pico_explorer_base/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv6m-none-eabi" +[unstable] +config-include = true diff --git a/boards/qemu_rv32_virt/.cargo/config.toml b/boards/qemu_rv32_virt/.cargo/config.toml index fd20ef793c..b285ad3744 100644 --- a/boards/qemu_rv32_virt/.cargo/config.toml +++ b/boards/qemu_rv32_virt/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "riscv32imac-unknown-none-elf" +[unstable] +config-include = true diff --git a/boards/raspberry_pi_pico/.cargo/config.toml b/boards/raspberry_pi_pico/.cargo/config.toml index 584262f585..4d568ece43 100644 --- a/boards/raspberry_pi_pico/.cargo/config.toml +++ b/boards/raspberry_pi_pico/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv6m-none-eabi" +[unstable] +config-include = true diff --git a/boards/redboard_redv/.cargo/config.toml b/boards/redboard_redv/.cargo/config.toml index fd20ef793c..b285ad3744 100644 --- a/boards/redboard_redv/.cargo/config.toml +++ b/boards/redboard_redv/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "riscv32imac-unknown-none-elf" +[unstable] +config-include = true diff --git a/boards/sma_q3/.cargo/config.toml b/boards/sma_q3/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/sma_q3/.cargo/config.toml +++ b/boards/sma_q3/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/stm32f3discovery/.cargo/config.toml b/boards/stm32f3discovery/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/stm32f3discovery/.cargo/config.toml +++ b/boards/stm32f3discovery/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/stm32f412gdiscovery/.cargo/config.toml b/boards/stm32f412gdiscovery/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/stm32f412gdiscovery/.cargo/config.toml +++ b/boards/stm32f412gdiscovery/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/stm32f429idiscovery/.cargo/config.toml b/boards/stm32f429idiscovery/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/stm32f429idiscovery/.cargo/config.toml +++ b/boards/stm32f429idiscovery/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/swervolf/.cargo/config.toml b/boards/swervolf/.cargo/config.toml index 0d75137dac..dd0e19cb45 100644 --- a/boards/swervolf/.cargo/config.toml +++ b/boards/swervolf/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "riscv32imc-unknown-none-elf" +[unstable] +config-include = true diff --git a/boards/teensy40/.cargo/config.toml b/boards/teensy40/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/teensy40/.cargo/config.toml +++ b/boards/teensy40/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml b/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml index 14ecd93f5c..1d8a988dc4 100644 --- a/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml +++ b/boards/tutorials/nrf52840dk-hotp-tutorial/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml b/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml index 14ecd93f5c..1d8a988dc4 100644 --- a/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml +++ b/boards/tutorials/nrf52840dk-thread-tutorial/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true diff --git a/boards/weact_f401ccu6/.cargo/config.toml b/boards/weact_f401ccu6/.cargo/config.toml index 0085b97012..a1cd23bff5 100644 --- a/boards/weact_f401ccu6/.cargo/config.toml +++ b/boards/weact_f401ccu6/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabihf" +[unstable] +config-include = true diff --git a/boards/wm1110dev/.cargo/config.toml b/boards/wm1110dev/.cargo/config.toml index 14ecd93f5c..e47df29899 100644 --- a/boards/wm1110dev/.cargo/config.toml +++ b/boards/wm1110dev/.cargo/config.toml @@ -2,6 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +include = [ + "../../cargo/tock_flags.toml", + "../../cargo/unstable_flags.toml", +] + [build] target = "thumbv7em-none-eabi" +[unstable] +config-include = true From 9b61d88a6dce8f692d41e74a7acaa74729594145 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 12:47:37 -0400 Subject: [PATCH 12/33] boards: config.toml: include optimize_for_size --- boards/Makefile.common | 19 ------------------- boards/cargo/unstable_flags.toml | 9 +++++++++ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index 2fd7558da0..0e1debfb6b 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -210,25 +210,6 @@ CARGO_FLAGS_TOCK ?= \ # Add default flags to rustdoc. RUSTDOC_FLAGS_TOCK ?= -D warnings --document-private-items -# Add flags if we are compiling on nightly. If we are on stable, disallow -# features. -# -# - `-Z build-std=core,compiler_builtins`: Build the std library from source -# using our optimization settings. This leads to significantly smaller binary -# sizes, and makes debugging easier since debug information for the core -# library is included in the resulting .elf file. See -# https://github.com/tock/tock/pull/2847 for more details. -# - `optimize_for_size`: Sets a feature flag in the core library that aims to -# produce smaller implementations for certain algorithms. See -# https://github.com/rust-lang/rust/pull/125011 for more details. -# - `--document-hidden-items`: Document internal interfaces when building -# rustdoc API documentation. -ifneq ($(USE_STABLE_RUST),1) - CARGO_FLAGS_TOCK += \ - -Z build-std=core,compiler_builtins \ - -Z build-std-features="core/optimize_for_size" -endif - # Set the default flags we need for objdump to get a .lst file. OBJDUMP_FLAGS ?= --disassemble-all --source --section-headers --demangle diff --git a/boards/cargo/unstable_flags.toml b/boards/cargo/unstable_flags.toml index f1a19156cd..5aada10b8f 100644 --- a/boards/cargo/unstable_flags.toml +++ b/boards/cargo/unstable_flags.toml @@ -4,4 +4,13 @@ [unstable] unstable-options = true +# - `-Z build-std=core,compiler_builtins`: Build the std library from source +# using our optimization settings. This leads to significantly smaller binary +# sizes, and makes debugging easier since debug information for the core +# library is included in the resulting .elf file. See +# https://github.com/tock/tock/pull/2847 for more details. build-std = ["core", "compiler_builtins" ] +# - `optimize_for_size`: Sets a feature flag in the core library that aims to +# produce smaller implementations for certain algorithms. See +# https://github.com/rust-lang/rust/pull/125011 for more details. +build-std-features = ["core/optimize_for_size"] From 19c5e9e1977ecb1e03b2261a147b488dd51f4834 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 12:51:21 -0400 Subject: [PATCH 13/33] boards: config: include riscv include --- boards/Makefile.common | 11 ----------- boards/arty_e21/.cargo/config.toml | 1 + boards/cargo/riscv_flags.toml | 16 ++++++++++++++++ boards/esp32-c3-devkitM-1/.cargo/config.toml | 1 + boards/hifive1/.cargo/config.toml | 1 + boards/hifive_inventor/.cargo/config.toml | 1 + boards/litex/.cargo/config.toml | 1 + .../opentitan/earlgrey-cw310/.cargo/config.toml | 2 +- boards/qemu_rv32_virt/.cargo/config.toml | 1 + boards/redboard_redv/.cargo/config.toml | 1 + boards/swervolf/.cargo/config.toml | 1 + 11 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 boards/cargo/riscv_flags.toml diff --git a/boards/Makefile.common b/boards/Makefile.common index 0e1debfb6b..f5081b505b 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -43,17 +43,6 @@ endif # cargo `--target_dir`. TARGET_DIRECTORY ?= $(TOCK_ROOT_DIRECTORY)target/ -# RISC-V-specific flags. -ifneq ($(findstring riscv32i, $(TARGET)),) - # NOTE: This flag causes kernel panics on some ARM cores. Since the size - # benefit is almost exclusively for RISC-V, we only apply it for those - # targets. - RUSTC_FLAGS += -C force-frame-pointers=no - # Ensure relocations generated is eligible for linker relaxation. - # This provide huge space savings. - RUSTC_FLAGS += -C target-feature=+relax -endif - # RUSTC_FLAGS_TOCK by default extends RUSTC_FLAGS with options that are global # to all Tock boards. # diff --git a/boards/arty_e21/.cargo/config.toml b/boards/arty_e21/.cargo/config.toml index b285ad3744..7313404384 100644 --- a/boards/arty_e21/.cargo/config.toml +++ b/boards/arty_e21/.cargo/config.toml @@ -5,6 +5,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/cargo/riscv_flags.toml b/boards/cargo/riscv_flags.toml new file mode 100644 index 0000000000..588dfc92ae --- /dev/null +++ b/boards/cargo/riscv_flags.toml @@ -0,0 +1,16 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + +# RISC-V-specific flags. + +[build] +rustflags = [ + # NOTE: This flag causes kernel panics on some ARM cores. Since the size + # benefit is almost exclusively for RISC-V, we only apply it for those + # targets. + "-C", "force-frame-pointers=no", + # Ensure relocations generated is eligible for linker relaxation. + # This provides huge space savings. + "-C", "target-feature=+relax", +] diff --git a/boards/esp32-c3-devkitM-1/.cargo/config.toml b/boards/esp32-c3-devkitM-1/.cargo/config.toml index d42a278849..6bd2345167 100644 --- a/boards/esp32-c3-devkitM-1/.cargo/config.toml +++ b/boards/esp32-c3-devkitM-1/.cargo/config.toml @@ -5,6 +5,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/hifive1/.cargo/config.toml b/boards/hifive1/.cargo/config.toml index b285ad3744..7313404384 100644 --- a/boards/hifive1/.cargo/config.toml +++ b/boards/hifive1/.cargo/config.toml @@ -5,6 +5,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/hifive_inventor/.cargo/config.toml b/boards/hifive_inventor/.cargo/config.toml index b285ad3744..7313404384 100644 --- a/boards/hifive_inventor/.cargo/config.toml +++ b/boards/hifive_inventor/.cargo/config.toml @@ -5,6 +5,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/litex/.cargo/config.toml b/boards/litex/.cargo/config.toml index dd0e19cb45..1dce153239 100644 --- a/boards/litex/.cargo/config.toml +++ b/boards/litex/.cargo/config.toml @@ -5,6 +5,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/opentitan/earlgrey-cw310/.cargo/config.toml b/boards/opentitan/earlgrey-cw310/.cargo/config.toml index 8d706cf3af..66c2ae1f2d 100644 --- a/boards/opentitan/earlgrey-cw310/.cargo/config.toml +++ b/boards/opentitan/earlgrey-cw310/.cargo/config.toml @@ -5,7 +5,7 @@ include = [ "../../../cargo/tock_flags.toml", "../../../cargo/unstable_flags.toml", - "../../cargo/riscv_flags.toml", + "../../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/qemu_rv32_virt/.cargo/config.toml b/boards/qemu_rv32_virt/.cargo/config.toml index b285ad3744..7313404384 100644 --- a/boards/qemu_rv32_virt/.cargo/config.toml +++ b/boards/qemu_rv32_virt/.cargo/config.toml @@ -5,6 +5,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/redboard_redv/.cargo/config.toml b/boards/redboard_redv/.cargo/config.toml index b285ad3744..7313404384 100644 --- a/boards/redboard_redv/.cargo/config.toml +++ b/boards/redboard_redv/.cargo/config.toml @@ -5,6 +5,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/swervolf/.cargo/config.toml b/boards/swervolf/.cargo/config.toml index dd0e19cb45..1dce153239 100644 --- a/boards/swervolf/.cargo/config.toml +++ b/boards/swervolf/.cargo/config.toml @@ -5,6 +5,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", + "../../cargo/riscv_flags.toml", ] [build] From 190d4fb90888a737bcc713428c1515dfc653bb10 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 13:04:32 -0400 Subject: [PATCH 14/33] boards: hail: manually include flags due to stable Can't use the cargo include feature. --- boards/hail/.cargo/config.toml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/boards/hail/.cargo/config.toml b/boards/hail/.cargo/config.toml index 14ecd93f5c..37f605c7b0 100644 --- a/boards/hail/.cargo/config.toml +++ b/boards/hail/.cargo/config.toml @@ -4,4 +4,28 @@ [build] target = "thumbv7em-none-eabi" - +rustflags = [ + # Tell rustc to use the LLVM linker. This avoids needing GCC as a dependency + # to build the kernel. + "-C", "linker=rust-lld", + # Use the LLVM lld executable with the `-flavor gnu` flag. + "-C", "linker-flavor=ld.lld", + # Use static relocation model. See https://github.com/tock/tock/pull/2853 + "-C", "relocation-model=static", + # lld by default uses a default page size to align program sections. Tock + # expects that program sections are set back-to-back. `-nmagic` instructs the + # linker to not page-align sections. + "-C", "link-arg=-nmagic", + # Identical Code Folding (ICF) set to all. This tells the linker to be more + # aggressive about removing duplicate code. The default is `safe`, and the + # downside to `all` is that different functions in the code can end up with + # the same address in the binary. However, it can save a fair bit of code + # size. + "-C", "link-arg=-icf=all", + # Opt-in to Rust v0 symbol mangling scheme. See + # https://github.com/rust-lang/rust/issues/60705 and + # https://github.com/tock/tock/issues/3529. + "-C", "symbol-mangling-version=v0", + # Enable link-time-optimization + "-C", "lto", +] From e2f372c7e42033566c43f99443c3287db0f6b677 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 19:41:11 -0400 Subject: [PATCH 15/33] boards: build.rs: comment on -T flag Co-authored-by: Pat Pannuto --- boards/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/boards/build.rs b/boards/build.rs index 823782b491..5176b661c2 100644 --- a/boards/build.rs +++ b/boards/build.rs @@ -25,6 +25,7 @@ fn main() { } println!("cargo:rustc-link-arg=-L{}", std::env!("CARGO_MANIFEST_DIR")); + // `-Tlayout.ld`: Use the linker script `layout.ld` all boards must provide. println!("cargo:rustc-link-arg=-T{}", LINKER_SCRIPT); track_linker_script(LINKER_SCRIPT); From 5ecb199e3c8f8606c00006ebb8a3a0ef49f38872 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 19:42:25 -0400 Subject: [PATCH 16/33] boards: tock_flags.toml: add link to mangling default Co-authored-by: Pat Pannuto --- boards/cargo/tock_flags.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/boards/cargo/tock_flags.toml b/boards/cargo/tock_flags.toml index a96a401b3e..1251c72a70 100644 --- a/boards/cargo/tock_flags.toml +++ b/boards/cargo/tock_flags.toml @@ -24,6 +24,7 @@ rustflags = [ # Opt-in to Rust v0 symbol mangling scheme. See # https://github.com/rust-lang/rust/issues/60705 and # https://github.com/tock/tock/issues/3529. + # https://github.com/rust-lang/rust/pull/89917 tracks this becoming the default, then we can remove this. "-C", "symbol-mangling-version=v0", # Enable link-time-optimization "-C", "lto", From 8e711f3097a631565820dac8532a4c67acb10d29 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 21:34:25 -0400 Subject: [PATCH 17/33] boards: hail: config comment --- boards/hail/.cargo/config.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boards/hail/.cargo/config.toml b/boards/hail/.cargo/config.toml index 37f605c7b0..489163269a 100644 --- a/boards/hail/.cargo/config.toml +++ b/boards/hail/.cargo/config.toml @@ -2,6 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. +# Because we compile hail with stable rust we cannot use the `include =` key in +# this config file. Therefore we have to copy the relevant flags here. + [build] target = "thumbv7em-none-eabi" rustflags = [ From f0de849d03cac8733f795cc63e17a8dfd051465a Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 21:49:40 -0400 Subject: [PATCH 18/33] boards: cargo: create virtual-function-elimination --- boards/Makefile.common | 10 ---------- boards/cargo/virtual_function_elimination.toml | 14 ++++++++++++++ boards/opentitan/earlgrey-cw310/.cargo/config.toml | 4 +--- boards/opentitan/earlgrey-cw310/Makefile | 2 -- 4 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 boards/cargo/virtual_function_elimination.toml diff --git a/boards/Makefile.common b/boards/Makefile.common index f5081b505b..119ea75b0c 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -241,16 +241,6 @@ else SHA256SUM := sha256sum endif -# virtual-function-elimination reduces the size of binaries, but is still -# experimental and has some possible miscompilation issues. This is only enabled -# for some boards by default, but is exposed via the `VFUNC_ELIM=1` option. -# -# For details on virtual-function-elimination see: https://github.com/rust-lang/rust/pull/96285 -# See https://github.com/rust-lang/rust/issues/68262 for general tracking -ifneq ($(VFUNC_ELIM),) - RUSTC_FLAGS += -C lto -Z virtual-function-elimination -endif - # Dump configuration for verbose builds ifeq ($(VERBOSE_MODE),1) $(info ) diff --git a/boards/cargo/virtual_function_elimination.toml b/boards/cargo/virtual_function_elimination.toml new file mode 100644 index 0000000000..62cee48af3 --- /dev/null +++ b/boards/cargo/virtual_function_elimination.toml @@ -0,0 +1,14 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + +[build] +rustflags = [ + # `virtual-function-elimination` reduces the size of binaries, but is still + # experimental and has some possible miscompilation issues. + # + # For details on virtual-function-elimination see: + # https://github.com/rust-lang/rust/pull/96285 and + # https://github.com/rust-lang/rust/issues/68262 for general tracking + "-Z", "virtual-function-elimination", +] diff --git a/boards/opentitan/earlgrey-cw310/.cargo/config.toml b/boards/opentitan/earlgrey-cw310/.cargo/config.toml index 66c2ae1f2d..b6d605d4d9 100644 --- a/boards/opentitan/earlgrey-cw310/.cargo/config.toml +++ b/boards/opentitan/earlgrey-cw310/.cargo/config.toml @@ -6,13 +6,11 @@ include = [ "../../../cargo/tock_flags.toml", "../../../cargo/unstable_flags.toml", "../../../cargo/riscv_flags.toml", + "../../../cargo/virtual_function_elimination.toml", ] [build] target = "riscv32imc-unknown-none-elf" -rustflags = [ - "-Z", "virtual-function-elimination" -] [target.'cfg(target_arch = "riscv32")'] runner = "./run.sh" diff --git a/boards/opentitan/earlgrey-cw310/Makefile b/boards/opentitan/earlgrey-cw310/Makefile index 2a45f305b9..8d436825d2 100644 --- a/boards/opentitan/earlgrey-cw310/Makefile +++ b/boards/opentitan/earlgrey-cw310/Makefile @@ -17,8 +17,6 @@ QEMU_ENTRY_POINT=0x20000400 # earlgrey_es branch. earlgrey_es is what is being taped out in the first # Earlgrey chip. OPENTITAN_SUPPORTED_SHA := edf5e35f5d50a5377641c90a315109a351de7635 -# Enable virtual function elimination -VFUNC_ELIM=1 include ../../Makefile.common From 2c5321ba8123fcc9196d233a92fe6a8ddc0c8f43 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 21:50:53 -0400 Subject: [PATCH 19/33] boards: cargo: add panic-abort-tests --- boards/cargo/panic_abort_tests.toml | 9 +++++++++ boards/esp32-c3-devkitM-1/.cargo/config.toml | 1 + boards/opentitan/earlgrey-cw310/.cargo/config.toml | 1 + boards/opentitan/earlgrey-cw310/Makefile | 4 ---- 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 boards/cargo/panic_abort_tests.toml diff --git a/boards/cargo/panic_abort_tests.toml b/boards/cargo/panic_abort_tests.toml new file mode 100644 index 0000000000..8492d1a352 --- /dev/null +++ b/boards/cargo/panic_abort_tests.toml @@ -0,0 +1,9 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + +[unstable] +# Build test crates with the `panic = "abort"` strategy. Tests use `unwind` by +# default which causes incompatibility with `core` built via `-Zbuild-std`. +# This should be included on platforms that have tests defined. +panic-abort-tests = true diff --git a/boards/esp32-c3-devkitM-1/.cargo/config.toml b/boards/esp32-c3-devkitM-1/.cargo/config.toml index 6bd2345167..f68422a87e 100644 --- a/boards/esp32-c3-devkitM-1/.cargo/config.toml +++ b/boards/esp32-c3-devkitM-1/.cargo/config.toml @@ -6,6 +6,7 @@ include = [ "../../cargo/tock_flags.toml", "../../cargo/unstable_flags.toml", "../../cargo/riscv_flags.toml", + "../../cargo/panic_abort_tests.toml", ] [build] diff --git a/boards/opentitan/earlgrey-cw310/.cargo/config.toml b/boards/opentitan/earlgrey-cw310/.cargo/config.toml index b6d605d4d9..7b1fa7be07 100644 --- a/boards/opentitan/earlgrey-cw310/.cargo/config.toml +++ b/boards/opentitan/earlgrey-cw310/.cargo/config.toml @@ -7,6 +7,7 @@ include = [ "../../../cargo/unstable_flags.toml", "../../../cargo/riscv_flags.toml", "../../../cargo/virtual_function_elimination.toml", + "../../../cargo/panic_abort_tests.toml", ] [build] diff --git a/boards/opentitan/earlgrey-cw310/Makefile b/boards/opentitan/earlgrey-cw310/Makefile index 8d436825d2..261664924f 100644 --- a/boards/opentitan/earlgrey-cw310/Makefile +++ b/boards/opentitan/earlgrey-cw310/Makefile @@ -27,10 +27,6 @@ ifneq ($(BOARD_CONFIGURATION),) CARGO_FLAGS += --no-default-features --features=$(BOARD_CONFIGURATION) endif -# Build test crates with the `panic = "abort"` strategy. Tests use `unwind` by -# default which causes incompatability with `core` built via `-Zbuild-std`. -CARGO_FLAGS += -Zpanic-abort-tests - .PHONY: ot-check ifneq ($(OPENTITAN_TREE),) OPENTITAN_ACTUAL_SHA := $(shell cd $(OPENTITAN_TREE); git show --pretty=format:"%H" --no-patch) From 24a511a917e0926fdf1775366d1e3791fdee3795 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 21:56:52 -0400 Subject: [PATCH 20/33] boards: build.rs: comment the -L flag --- boards/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boards/build.rs b/boards/build.rs index 5176b661c2..dd5ffb0405 100644 --- a/boards/build.rs +++ b/boards/build.rs @@ -24,6 +24,8 @@ fn main() { panic!("Boards must provide a `layout.ld` link script file"); } + // Include the folder where the board's Cargo.toml is in the linker file + // search path. println!("cargo:rustc-link-arg=-L{}", std::env!("CARGO_MANIFEST_DIR")); // `-Tlayout.ld`: Use the linker script `layout.ld` all boards must provide. println!("cargo:rustc-link-arg=-T{}", LINKER_SCRIPT); From 83e2084a76c9a3f90b8f2e8cee3d532344809f10 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Fri, 12 Jul 2024 10:14:59 -0700 Subject: [PATCH 21/33] Move rustdoc flags to cargo config --- boards/cargo/tock_flags.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/boards/cargo/tock_flags.toml b/boards/cargo/tock_flags.toml index 1251c72a70..960252320d 100644 --- a/boards/cargo/tock_flags.toml +++ b/boards/cargo/tock_flags.toml @@ -29,3 +29,9 @@ rustflags = [ # Enable link-time-optimization "-C", "lto", ] + +[target.test] +rustdocflags = [ + "-D", "warnings", + "--document-private-items" +] From 60fdc34b96c2757d4a9c3ff88d012070b767bf64 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Fri, 12 Jul 2024 14:44:09 -0700 Subject: [PATCH 22/33] Move nordic .cargo/ to each board --- .../{ => nrf52840_dongle}/.cargo/config.toml | 4 ++-- boards/nordic/nrf52840dk/.cargo/config.toml | 14 ++++++++++++++ boards/nordic/nrf52dk/.cargo/config.toml | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) rename boards/nordic/{ => nrf52840_dongle}/.cargo/config.toml (75%) create mode 100644 boards/nordic/nrf52840dk/.cargo/config.toml create mode 100644 boards/nordic/nrf52dk/.cargo/config.toml diff --git a/boards/nordic/.cargo/config.toml b/boards/nordic/nrf52840_dongle/.cargo/config.toml similarity index 75% rename from boards/nordic/.cargo/config.toml rename to boards/nordic/nrf52840_dongle/.cargo/config.toml index e47df29899..1d8a988dc4 100644 --- a/boards/nordic/.cargo/config.toml +++ b/boards/nordic/nrf52840_dongle/.cargo/config.toml @@ -3,8 +3,8 @@ # Copyright Tock Contributors 2024. include = [ - "../../cargo/tock_flags.toml", - "../../cargo/unstable_flags.toml", + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", ] [build] diff --git a/boards/nordic/nrf52840dk/.cargo/config.toml b/boards/nordic/nrf52840dk/.cargo/config.toml new file mode 100644 index 0000000000..1d8a988dc4 --- /dev/null +++ b/boards/nordic/nrf52840dk/.cargo/config.toml @@ -0,0 +1,14 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", +] + +[build] +target = "thumbv7em-none-eabi" + +[unstable] +config-include = true diff --git a/boards/nordic/nrf52dk/.cargo/config.toml b/boards/nordic/nrf52dk/.cargo/config.toml new file mode 100644 index 0000000000..1d8a988dc4 --- /dev/null +++ b/boards/nordic/nrf52dk/.cargo/config.toml @@ -0,0 +1,14 @@ +# Licensed under the Apache License, Version 2.0 or the MIT License. +# SPDX-License-Identifier: Apache-2.0 OR MIT +# Copyright Tock Contributors 2024. + +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", +] + +[build] +target = "thumbv7em-none-eabi" + +[unstable] +config-include = true From 4366e0648ce575bc1bbaa681f805ebb080a834b2 Mon Sep 17 00:00:00 2001 From: Amit Levy Date: Mon, 15 Jul 2024 09:46:49 -0700 Subject: [PATCH 23/33] Update boards/cargo/tock_flags.toml Co-authored-by: Brad Campbell --- boards/cargo/tock_flags.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/boards/cargo/tock_flags.toml b/boards/cargo/tock_flags.toml index 960252320d..fb9f83635a 100644 --- a/boards/cargo/tock_flags.toml +++ b/boards/cargo/tock_flags.toml @@ -30,7 +30,6 @@ rustflags = [ "-C", "lto", ] -[target.test] rustdocflags = [ "-D", "warnings", "--document-private-items" From ec9c4d3122a0247cad7d27553e0b380986a260aa Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Mon, 15 Jul 2024 10:37:40 -0700 Subject: [PATCH 24/33] Move cargo/.configs to board folders --- boards/apollo3/lora_things_plus/.cargo/config.toml | 13 ++++++++++++- .../apollo3/redboard_artemis_atp/.cargo/config.toml | 13 ++++++++++++- .../redboard_artemis_nano/.cargo/config.toml | 13 ++++++++++++- boards/litex/{ => arty}/.cargo/config.toml | 6 +++--- boards/{apollo3 => litex/sim}/.cargo/config.toml | 7 ++++--- 5 files changed, 43 insertions(+), 9 deletions(-) rename boards/litex/{ => arty}/.cargo/config.toml (68%) rename boards/{apollo3 => litex/sim}/.cargo/config.toml (57%) diff --git a/boards/apollo3/lora_things_plus/.cargo/config.toml b/boards/apollo3/lora_things_plus/.cargo/config.toml index e06b76bd9b..5b20a910df 100644 --- a/boards/apollo3/lora_things_plus/.cargo/config.toml +++ b/boards/apollo3/lora_things_plus/.cargo/config.toml @@ -1,6 +1,17 @@ # Licensed under the Apache License, Version 2.0 or the MIT License. # SPDX-License-Identifier: Apache-2.0 OR MIT -# Copyright Tock Contributors 2022. +# Copyright Tock Contributors 2024. + +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", +] + +[build] +target = "thumbv7em-none-eabi" [target.'cfg(target_arch = "arm")'] runner = "./run.sh" + +[unstable] +config-include = true diff --git a/boards/apollo3/redboard_artemis_atp/.cargo/config.toml b/boards/apollo3/redboard_artemis_atp/.cargo/config.toml index e06b76bd9b..5b20a910df 100644 --- a/boards/apollo3/redboard_artemis_atp/.cargo/config.toml +++ b/boards/apollo3/redboard_artemis_atp/.cargo/config.toml @@ -1,6 +1,17 @@ # Licensed under the Apache License, Version 2.0 or the MIT License. # SPDX-License-Identifier: Apache-2.0 OR MIT -# Copyright Tock Contributors 2022. +# Copyright Tock Contributors 2024. + +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", +] + +[build] +target = "thumbv7em-none-eabi" [target.'cfg(target_arch = "arm")'] runner = "./run.sh" + +[unstable] +config-include = true diff --git a/boards/apollo3/redboard_artemis_nano/.cargo/config.toml b/boards/apollo3/redboard_artemis_nano/.cargo/config.toml index e06b76bd9b..5b20a910df 100644 --- a/boards/apollo3/redboard_artemis_nano/.cargo/config.toml +++ b/boards/apollo3/redboard_artemis_nano/.cargo/config.toml @@ -1,6 +1,17 @@ # Licensed under the Apache License, Version 2.0 or the MIT License. # SPDX-License-Identifier: Apache-2.0 OR MIT -# Copyright Tock Contributors 2022. +# Copyright Tock Contributors 2024. + +include = [ + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", +] + +[build] +target = "thumbv7em-none-eabi" [target.'cfg(target_arch = "arm")'] runner = "./run.sh" + +[unstable] +config-include = true diff --git a/boards/litex/.cargo/config.toml b/boards/litex/arty/.cargo/config.toml similarity index 68% rename from boards/litex/.cargo/config.toml rename to boards/litex/arty/.cargo/config.toml index 1dce153239..8661d87fdf 100644 --- a/boards/litex/.cargo/config.toml +++ b/boards/litex/arty/.cargo/config.toml @@ -3,9 +3,9 @@ # Copyright Tock Contributors 2024. include = [ - "../../cargo/tock_flags.toml", - "../../cargo/unstable_flags.toml", - "../../cargo/riscv_flags.toml", + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", + "../../../cargo/riscv_flags.toml", ] [build] diff --git a/boards/apollo3/.cargo/config.toml b/boards/litex/sim/.cargo/config.toml similarity index 57% rename from boards/apollo3/.cargo/config.toml rename to boards/litex/sim/.cargo/config.toml index e47df29899..8661d87fdf 100644 --- a/boards/apollo3/.cargo/config.toml +++ b/boards/litex/sim/.cargo/config.toml @@ -3,12 +3,13 @@ # Copyright Tock Contributors 2024. include = [ - "../../cargo/tock_flags.toml", - "../../cargo/unstable_flags.toml", + "../../../cargo/tock_flags.toml", + "../../../cargo/unstable_flags.toml", + "../../../cargo/riscv_flags.toml", ] [build] -target = "thumbv7em-none-eabi" +target = "riscv32imc-unknown-none-elf" [unstable] config-include = true From 01b36bb0f7082c0400d6903f7ad2224faa1c2831 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Mon, 15 Jul 2024 10:50:55 -0700 Subject: [PATCH 25/33] Remove RUSTFLAGS et al from Makefile.common rules RUSTFLAGS have now moved to .cargo/config.toml file. Setting the RUSTFLAGS environment variable at all overrides anything set in .cargo/config.toml. This also makes redundant flags for `rustdoc`, CARGO_FLAGS_TOCK_NO_BUILD_STD, RUSTC_FLAGS_TOCK and CARGO_FLAGS_TOCK --- boards/Makefile.common | 91 ++----------------- boards/apollo3/lora_things_plus/Makefile | 2 +- boards/apollo3/redboard_artemis_atp/Makefile | 2 +- boards/apollo3/redboard_artemis_nano/Makefile | 2 +- boards/cargo/tock_flags.toml | 9 +- boards/esp32-c3-devkitM-1/Makefile | 2 +- boards/opentitan/earlgrey-cw310/Makefile | 6 +- 7 files changed, 23 insertions(+), 91 deletions(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index 119ea75b0c..64b862bdb6 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -43,47 +43,6 @@ endif # cargo `--target_dir`. TARGET_DIRECTORY ?= $(TOCK_ROOT_DIRECTORY)target/ -# RUSTC_FLAGS_TOCK by default extends RUSTC_FLAGS with options that are global -# to all Tock boards. -# -# We use `remap-path-prefix` to remove user-specific filepath strings for error -# reporting from appearing in the generated binary. The first line is used for -# remapping the tock directory, and the second line is for remapping paths to -# the source code of the core library, which end up in the binary as a result of -# our use of `-Zbuild-std=core`. -RUSTC_FLAGS_TOCK ?= \ - $(RUSTC_FLAGS) \ - --remap-path-prefix=$(TOCK_ROOT_DIRECTORY)= \ - --remap-path-prefix=$(RUSTC_SYSROOT)/lib/rustlib/src/rust/library/core=/core/ - -# Disallow warnings only for continuous integration builds. Disallowing them -# here using the `RUSTC_FLAGS_TOCK` variable ensures that warnings during -# testing won't prevent compilation from succeeding. -ifeq ($(NOWARNINGS),true) - RUSTC_FLAGS_TOCK += -D warnings -endif - -# The following flags should only be passed to the board's binary crate, but -# not to any of its dependencies (the kernel, capsules, chips, etc.). The -# dependencies wouldn't use it, but because the link path is different for each -# board, Cargo wouldn't be able to cache builds of the dependencies. -# -# Indeed, as far as Cargo is concerned, building the kernel with -# `-C link-arg=-L/tock/boards/imix` is different than building the kernel with -# `-C link-arg=-L/tock/boards/hail`, so Cargo would have to rebuild the kernel -# for each board instead of caching it per board (even if in reality the same -# kernel is built because the link-arg isn't used by the kernel). -# -# Ultimately, this should move to the Cargo.toml, for example when -# https://github.com/rust-lang/cargo/pull/7811 is merged into Cargo. -# -# The difference between `RUSTC_FLAGS_TOCK` and `RUSTC_FLAGS_FOR_BIN` is that -# the former is forwarded to all the dependencies (being passed to cargo via -# the `RUSTFLAGS` environment variable), whereas the latter is only applied to -# the final binary crate (being passed as parameter to `cargo rustc`). -RUSTC_FLAGS_FOR_BIN ?= \ - -C link-arg=-L$(abspath .) \ - # http://stackoverflow.com/questions/10858261/abort-makefile-if-variable-not-set # Check that given variables are set and all have non-empty values, print an # error otherwise. @@ -188,17 +147,6 @@ OBJCOPY_FLAGS ?= --strip-sections --strip-all --remove-section .apps # Cargo.toml. CARGO_FLAGS ?= -# Add default flags to cargo. Boards can add additional options in -# `CARGO_FLAGS`. -CARGO_FLAGS_TOCK ?= \ - $(VERBOSE_FLAGS) \ - --target=$(TARGET) \ - --package $(PLATFORM) \ - --target-dir=$(TARGET_DIRECTORY) $(CARGO_FLAGS) - -# Add default flags to rustdoc. -RUSTDOC_FLAGS_TOCK ?= -D warnings --document-private-items - # Set the default flags we need for objdump to get a .lst file. OBJDUMP_FLAGS ?= --disassemble-all --source --section-headers --demangle @@ -219,13 +167,6 @@ CARGO_BLOAT_FLAGS ?= # environment variable. By default, pass an empty string. PTMU_ARGS ?= -# `cargo bloat` does not support `-Z build-std`, so we must remove it from cargo -# flags. See https://github.com/RazrFalcon/cargo-bloat/issues/62. -# As we aren't building the library we also remove the -# `-Z build-std-features="core/optimize_for_size"` argument. -CARGO_FLAGS_TOCK_NO_BUILD_STD := $(filter-out -Z build-std=core,$(CARGO_FLAGS_TOCK)) -CARGO_FLAGS_TOCK_NO_BUILD_STD := $(filter-out -Z build-std-features="core/optimize_for_size",$(CARGO_FLAGS_TOCK)) - # Check whether the system already has a sha256sum or shasum application # present. If not, use the custom shipped one. ifeq (, $(shell sha256sum --version 2>/dev/null)) @@ -254,14 +195,10 @@ ifeq ($(VERBOSE_MODE),1) $(info PLATFORM = $(PLATFORM)) $(info TARGET = $(TARGET)) $(info TOCK_KERNEL_VERSION = $(TOCK_KERNEL_VERSION)) - $(info RUSTC_FLAGS = $(RUSTC_FLAGS)) - $(info RUSTC_FLAGS_TOCK = $(RUSTC_FLAGS_TOCK)) $(info MAKEFLAGS = $(MAKEFLAGS)) $(info OBJDUMP_FLAGS = $(OBJDUMP_FLAGS)) $(info OBJCOPY_FLAGS = $(OBJCOPY_FLAGS)) $(info CARGO_FLAGS = $(CARGO_FLAGS)) - $(info CARGO_FLAGS_TOCK = $(CARGO_FLAGS_TOCK)) - $(info CARGO_FLAGS_TOCK_NO_BUILD_STD = $(CARGO_FLAGS_TOCK_NO_BUILD_STD)) $(info SIZE_FLAGS = $(SIZE_FLAGS)) $(info CARGO_BLOAT_FLAGS = $(CARGO_BLOAT_FLAGS)) $(info ) @@ -291,12 +228,12 @@ all: release # binary. This makes checking for Rust errors much faster. .PHONY: check check: - $(Q)$(CARGO) check $(VERBOSE_FLAGS) $(CARGO_FLAGS_TOCK) + $(Q)$(CARGO) check $(VERBOSE_FLAGS) $(CARGO_FLAGS) .PHONY: clean clean:: - $(Q)$(CARGO) clean $(VERBOSE_FLAGS) --target-dir=$(TARGET_DIRECTORY) + $(Q)$(CARGO) clean $(VERBOSE_FLAGS) .PHONY: release release: $(TARGET_PATH)/release/$(PLATFORM).bin @@ -309,7 +246,7 @@ debug-lst: $(TARGET_PATH)/debug/$(PLATFORM).lst .PHONY: doc doc: | target - $(Q)RUSTDOCFLAGS='$(RUSTDOC_FLAGS_TOCK)' $(CARGO) --color=always doc $(VERBOSE_FLAGS) --release --package $(PLATFORM) + $(Q)$(CARGO) --color=always doc $(VERBOSE_FLAGS) --release --package $(PLATFORM) .PHONY: lst @@ -322,32 +259,22 @@ show-target: $(info $(TARGET)) # This rule is a copy of the rule used to build the release target, but `cargo -# rustc` has been replaced with `cargo bloat`. `cargo bloat` replicates the -# interface of `cargo build`, rather than `cargo rustc`, so we need to move -# `RUSTC_FLAGS_FOR_BIN` into the `RUSTFLAGS` environment variable. This only -# means that cargo cannot reuse built dependencies built using `cargo bloat`. -# See the discussion on `RUSTC_FLAGS_FOR_BIN` above for additional details. To -# pass additional flags to `cargo bloat`, populate the CARGO_BLOAT_FLAGS -# environment variable, e.g. run `CARGO_BLOAT_FLAGS=--crates make cargobloat` +# rustc` has been replaced with `cargo bloat`. .PHONY: cargobloat cargobloat: - $(Q)$(CARGO) install cargo-bloat > /dev/null 2>&1 || echo 'Error: Failed to install cargo-bloat' - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK) $(RUSTC_FLAGS_FOR_BIN)" CARGO_FLAGS="-Z build-std=core" $(CARGO) bloat $(CARGO_FLAGS_TOCK_NO_BUILD_STD) --bin $(PLATFORM) --release $(CARGO_BLOAT_FLAGS) + $(Q)$(CARGO) bloat --bin $(PLATFORM) --release $(CARGO_BLOAT_FLAGS) # To pass additional flags to `cargo cargobloatnoinline`, populate the # CARGO_BLOAT_FLAGS environment variable, e.g. run `CARGO_BLOAT_FLAGS=--crates # make cargobloatnoinline` .PHONY: cargobloatnoinline cargobloatnoinline: - $(Q)$(CARGO) install cargo-bloat > \dev\null 2>&1 || echo 'Error: Failed to install cargo-bloat' - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK) -C inline-threshold=0 $(RUSTC_FLAGS_FOR_BIN)" $(CARGO) bloat $(CARGO_FLAGS_TOCK) --bin $(PLATFORM) --release $(CARGO_BLOAT_FLAGS) + $(Q)RUSTFLAGS="-C inline-threshold=0" $(CARGO) bloat $(CARGO_FLAGS_TOCK) --bin $(PLATFORM) --release $(CARGO_BLOAT_FLAGS) .PHONY: stack-analysis -#stack_analysis: RUSTC_FLAGS_TOCK += -Z emit-stack-sizes -stack-analysis: +stack-analysis: $(TARGET_PATH)/release/$(PLATFORM) @$ echo $(PLATFORM) @$ echo ---------------------- - $(Q)$(MAKE) release RUSTC_FLAGS="$(RUSTC_FLAGS) -Z emit-stack-sizes" $(DEVNULL) 2>&1 $(Q)$(TOCK_ROOT_DIRECTORY)/tools/stack_analysis.sh $(TARGET_PATH)/release/$(PLATFORM).elf # Run the `print_tock_memory_usage.py` script for this board. @@ -383,10 +310,10 @@ $(TOCK_ROOT_DIRECTORY)tools/sha256sum/target/debug/sha256sum: .PHONY: $(TARGET_PATH)/release/$(PLATFORM) $(TARGET_PATH)/release/$(PLATFORM): - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" $(CARGO) rustc $(CARGO_FLAGS_TOCK) --bin $(PLATFORM) --release -- $(RUSTC_FLAGS_FOR_BIN) + $(Q)$(CARGO) rustc $(CARGO_FLAGS) --bin $(PLATFORM) --release $(Q)$(SIZE) $(SIZE_FLAGS) $@ .PHONY: $(TARGET_PATH)/debug/$(PLATFORM) $(TARGET_PATH)/debug/$(PLATFORM): - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" $(CARGO) rustc $(CARGO_FLAGS_TOCK) --bin $(PLATFORM) -- $(RUSTC_FLAGS_FOR_BIN) + $(Q)$(CARGO) build $(CARGO_FLAGS) --bin $(PLATFORM) $(Q)$(SIZE) $(SIZE_FLAGS) $@ diff --git a/boards/apollo3/lora_things_plus/Makefile b/boards/apollo3/lora_things_plus/Makefile index 9d2604a8a1..0e91a408e6 100644 --- a/boards/apollo3/lora_things_plus/Makefile +++ b/boards/apollo3/lora_things_plus/Makefile @@ -49,4 +49,4 @@ test: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(CARGO_FLAGS_TOCK_NO_BUILD_STD) $(NO_RUN) --bin $(PLATFORM) --release + $(Q)OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release diff --git a/boards/apollo3/redboard_artemis_atp/Makefile b/boards/apollo3/redboard_artemis_atp/Makefile index bf174f462e..bc092fd350 100644 --- a/boards/apollo3/redboard_artemis_atp/Makefile +++ b/boards/apollo3/redboard_artemis_atp/Makefile @@ -49,4 +49,4 @@ test: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(CARGO_FLAGS_TOCK_NO_BUILD_STD) $(NO_RUN) --bin $(PLATFORM) --release + $(Q)OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release diff --git a/boards/apollo3/redboard_artemis_nano/Makefile b/boards/apollo3/redboard_artemis_nano/Makefile index fd16b7d3c9..28e0be8d4c 100644 --- a/boards/apollo3/redboard_artemis_nano/Makefile +++ b/boards/apollo3/redboard_artemis_nano/Makefile @@ -49,4 +49,4 @@ test: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(CARGO_FLAGS_TOCK_NO_BUILD_STD) $(NO_RUN) --bin $(PLATFORM) --release + $(Q)OBJCOPY=${OBJCOPY} PORT=$(PORT) $(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release diff --git a/boards/cargo/tock_flags.toml b/boards/cargo/tock_flags.toml index fb9f83635a..16c878f2d7 100644 --- a/boards/cargo/tock_flags.toml +++ b/boards/cargo/tock_flags.toml @@ -24,13 +24,18 @@ rustflags = [ # Opt-in to Rust v0 symbol mangling scheme. See # https://github.com/rust-lang/rust/issues/60705 and # https://github.com/tock/tock/issues/3529. - # https://github.com/rust-lang/rust/pull/89917 tracks this becoming the default, then we can remove this. + # https://github.com/rust-lang/rust/pull/89917 tracks this becoming the + # default, then we can remove this. "-C", "symbol-mangling-version=v0", # Enable link-time-optimization "-C", "lto", + # Have rustc generate stack sizes for analyzing the size of stack frames. + "-Z", "emit-stack-sizes", ] - rustdocflags = [ + # Error if there are warnings. This allows CI to fail on warnings. "-D", "warnings", + # Document internal code. This is helpful for understanding how the kernel + # works and developing within crates. "--document-private-items" ] diff --git a/boards/esp32-c3-devkitM-1/Makefile b/boards/esp32-c3-devkitM-1/Makefile index 6283fcff31..4b88d9a3cd 100644 --- a/boards/esp32-c3-devkitM-1/Makefile +++ b/boards/esp32-c3-devkitM-1/Makefile @@ -30,4 +30,4 @@ test: mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp ../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/ - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" $(CARGO) test $(CARGO_FLAGS_TOCK_NO_BUILD_STD) $(NO_RUN) --bin $(PLATFORM) --release + $(Q)$(CARGO) test $(NO_RUN) --bin $(PLATFORM) --release diff --git a/boards/opentitan/earlgrey-cw310/Makefile b/boards/opentitan/earlgrey-cw310/Makefile index 261664924f..627e9a223a 100644 --- a/boards/opentitan/earlgrey-cw310/Makefile +++ b/boards/opentitan/earlgrey-cw310/Makefile @@ -99,16 +99,16 @@ endif mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp test_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/layout.ld $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} QEMU_ENTRY_POINT=${QEMU_ENTRY_POINT} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS_TOCK) $(NO_RUN) --bin $(PLATFORM) --release + $(Q)TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} QEMU_ENTRY_POINT=${QEMU_ENTRY_POINT} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS) $(NO_RUN) --bin $(PLATFORM) --release test-hardware: ot-check mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp test_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/layout.ld $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" OBJCOPY=$(RISC_PREFIX)-objcopy TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS_TOCK) $(NO_RUN) --bin $(PLATFORM) --release --features=hardware_tests + $(Q)OBJCOPY=$(RISC_PREFIX)-objcopy TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS) $(NO_RUN) --bin $(PLATFORM) --release --features=hardware_tests test-verilator: ot-check mkdir -p $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/ $(Q)cp test_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/deps/layout.ld $(Q)cp ../../kernel_layout.ld $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/ - $(Q)RUSTFLAGS="$(RUSTC_FLAGS_TOCK)" VERILATOR="yes" OBJCOPY=$(RISC_PREFIX)-objcopy TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS_TOCK) $(NO_RUN) --bin $(PLATFORM) --release --features=hardware_tests,sim_verilator + $(Q)VERILATOR="yes" OBJCOPY=$(RISC_PREFIX)-objcopy TOCK_ROOT_DIRECTORY=${TOCK_ROOT_DIRECTORY} TARGET=${TARGET} $(CARGO) test $(CARGO_FLAGS) $(NO_RUN) --bin $(PLATFORM) --release --features=hardware_tests,sim_verilator From 9041fdf6eb494e0c13e4172b2f67b67f1fb222e7 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 16 Jul 2024 11:22:04 -0400 Subject: [PATCH 26/33] boards: make: remove bloat target Can just run `cargo bloat` now. --- boards/Makefile.common | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index 64b862bdb6..685a5d520c 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -158,11 +158,6 @@ ifneq (,$(findstring thumb,$(TARGET))) OBJDUMP_FLAGS += --arch-name=thumb endif -# Additional flags that can be passed to cargo bloat via an environment -# variable. Allows users to pass arbitrary flags supported by cargo bloat to -# customize the output. By default, pass an empty string. -CARGO_BLOAT_FLAGS ?= - # Additional flags that can be passed to print_tock_memory_usage.py via an # environment variable. By default, pass an empty string. PTMU_ARGS ?= @@ -200,7 +195,6 @@ ifeq ($(VERBOSE_MODE),1) $(info OBJCOPY_FLAGS = $(OBJCOPY_FLAGS)) $(info CARGO_FLAGS = $(CARGO_FLAGS)) $(info SIZE_FLAGS = $(SIZE_FLAGS)) - $(info CARGO_BLOAT_FLAGS = $(CARGO_BLOAT_FLAGS)) $(info ) $(info TOOLCHAIN = $(TOOLCHAIN)) $(info SIZE = $(SIZE)) @@ -258,19 +252,6 @@ lst: $(TARGET_PATH)/release/$(PLATFORM).lst show-target: $(info $(TARGET)) -# This rule is a copy of the rule used to build the release target, but `cargo -# rustc` has been replaced with `cargo bloat`. -.PHONY: cargobloat -cargobloat: - $(Q)$(CARGO) bloat --bin $(PLATFORM) --release $(CARGO_BLOAT_FLAGS) - -# To pass additional flags to `cargo cargobloatnoinline`, populate the -# CARGO_BLOAT_FLAGS environment variable, e.g. run `CARGO_BLOAT_FLAGS=--crates -# make cargobloatnoinline` -.PHONY: cargobloatnoinline -cargobloatnoinline: - $(Q)RUSTFLAGS="-C inline-threshold=0" $(CARGO) bloat $(CARGO_FLAGS_TOCK) --bin $(PLATFORM) --release $(CARGO_BLOAT_FLAGS) - .PHONY: stack-analysis stack-analysis: $(TARGET_PATH)/release/$(PLATFORM) @$ echo $(PLATFORM) From b7316ab83366311964df6cb63a54b19b3079c147 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 9 Jul 2024 14:27:11 -0400 Subject: [PATCH 27/33] boards: use trim-paths rather than remap-prefix --- boards/Makefile.common | 2 +- boards/cargo/unstable_flags.toml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index 685a5d520c..c592b4e920 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -18,7 +18,7 @@ MAKEFILE_COMMON_PATH := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) TOCK_ROOT_DIRECTORY := $(dir $(abspath $(MAKEFILE_COMMON_PATH))) # The path to the root of the rust installation used for this build. -# Useful for remapping paths and for finding already-installed llvm tools. +# Useful for finding already-installed llvm tools. RUSTC_SYSROOT := "$(shell rustc --print sysroot)" # Common defaults that specific boards can override, but likely do not need to. diff --git a/boards/cargo/unstable_flags.toml b/boards/cargo/unstable_flags.toml index 5aada10b8f..ea876e290d 100644 --- a/boards/cargo/unstable_flags.toml +++ b/boards/cargo/unstable_flags.toml @@ -14,3 +14,6 @@ build-std = ["core", "compiler_builtins" ] # produce smaller implementations for certain algorithms. See # https://github.com/rust-lang/rust/pull/125011 for more details. build-std-features = ["core/optimize_for_size"] +# Remove machine-specific paths from the binary. This helps create reproducible +# builds. +trim-paths = true From 836e1d3d4625000abcb3159bc5c13095dbac128f Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 16 Jul 2024 16:01:05 -0400 Subject: [PATCH 28/33] boards: make: autodiscover TARGET and PLATFORM --- boards/Makefile.common | 17 +++++++++++++++++ boards/acd52832/Makefile | 3 --- boards/apollo3/lora_things_plus/Makefile | 2 -- boards/apollo3/redboard_artemis_atp/Makefile | 2 -- boards/apollo3/redboard_artemis_nano/Makefile | 2 -- boards/arty_e21/Makefile | 3 --- boards/clue_nrf52840/Makefile | 4 ---- .../nrf52840dk-test-appid-sha256/Makefile | 3 --- .../nrf52840dk-test-appid-tbf/Makefile | 3 --- .../nrf52840dk/nrf52840dk-test-kernel/Makefile | 3 --- boards/esp32-c3-devkitM-1/Makefile | 2 -- boards/hail/Makefile | 1 - boards/hifive1/Makefile | 2 -- boards/hifive_inventor/Makefile | 2 -- boards/imix/Makefile | 3 --- boards/imxrt1050-evkb/Makefile | 3 --- boards/litex/arty/Makefile | 3 --- boards/litex/sim/Makefile | 3 --- boards/makepython-nrf52840/Makefile | 4 ---- boards/microbit_v2/Makefile | 4 ---- boards/msp_exp432p401r/Makefile | 2 -- boards/nano33ble/Makefile | 4 ---- boards/nano33ble_rev2/Makefile | 4 ---- boards/nano_rp2040_connect/Makefile | 4 ---- boards/nordic/nrf52840_dongle/Makefile | 3 --- boards/nordic/nrf52840dk/Makefile | 3 --- boards/nordic/nrf52dk/Makefile | 3 --- boards/nucleo_f429zi/Makefile | 2 -- boards/nucleo_f446re/Makefile | 2 -- boards/opentitan/earlgrey-cw310/Makefile | 2 -- boards/particle_boron/Makefile | 3 --- boards/pico_explorer_base/Makefile | 4 ---- boards/qemu_rv32_virt/Makefile | 3 --- boards/raspberry_pi_pico/Makefile | 4 ---- boards/redboard_redv/Makefile | 2 -- boards/sma_q3/Makefile | 3 --- boards/stm32f3discovery/Makefile | 2 -- boards/stm32f412gdiscovery/Makefile | 2 -- boards/stm32f429idiscovery/Makefile | 2 -- boards/swervolf/Makefile | 3 --- boards/teensy40/Makefile | 3 --- .../tutorials/nrf52840dk-hotp-tutorial/Makefile | 3 --- .../nrf52840dk-thread-tutorial/Makefile | 3 --- boards/weact_f401ccu6/Makefile | 2 -- boards/wm1110dev/Makefile | 6 +----- 45 files changed, 18 insertions(+), 125 deletions(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index c592b4e920..dfcbc869ff 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -48,6 +48,23 @@ TARGET_DIRECTORY ?= $(TOCK_ROOT_DIRECTORY)target/ # error otherwise. check_defined = $(strip $(foreach 1,$1,$(if $(value $1),,$(error Undefined variable "$1")))) + +# Get the name of the package by hacking the `cargo tree` command. This prints +# the local package name first so we can use that to get the package name. Ex: +# +# wm1110dev v0.1.0 (/Users/bradjc/git/tock/boards/wm1110dev) +# ├── capsules-core v0.1.0 (/Users/bradjc/git/tock/capsules/core) +# │ ├── enum_primitive v0.1.0 (/Users/bradjc/git/tock/libraries/enum_primitive) +PLATFORM := $(firstword $(shell $(CARGO) tree)) +# Set `TARGET` if not already defined. Note: this only works on nightly. +ifeq ($(TARGET),) + # Get the specified target using the unstable `cargo config get` command. + TARGET_QUOTES := $(shell $(CARGO) config get --format json-value build.target) + # Remove the quotes from around the target name. + TARGET := $(patsubst "%",%,$(TARGET_QUOTES)) +endif + + # Check that we know the basics of what we are compiling for. # - `PLATFORM`: The name of the board that the kernel is being compiled for. # - `TARGET` : The Rust target architecture the kernel is being compiled for. diff --git a/boards/acd52832/Makefile b/boards/acd52832/Makefile index 61e86d8692..03d78461f4 100644 --- a/boards/acd52832/Makefile +++ b/boards/acd52832/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the nRF development kit -TARGET=thumbv7em-none-eabi -PLATFORM=acd52832 - include ../Makefile.common TOCKLOADER=tockloader diff --git a/boards/apollo3/lora_things_plus/Makefile b/boards/apollo3/lora_things_plus/Makefile index 0e91a408e6..b78df434f7 100644 --- a/boards/apollo3/lora_things_plus/Makefile +++ b/boards/apollo3/lora_things_plus/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the SparkFun LoRa Thing Plus - expLoRaBLE # -TARGET=thumbv7em-none-eabi -PLATFORM=lora_things_plus include ../../Makefile.common diff --git a/boards/apollo3/redboard_artemis_atp/Makefile b/boards/apollo3/redboard_artemis_atp/Makefile index bc092fd350..ba9c32c40b 100644 --- a/boards/apollo3/redboard_artemis_atp/Makefile +++ b/boards/apollo3/redboard_artemis_atp/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the RedBoard Artemis ATP platform # -TARGET=thumbv7em-none-eabi -PLATFORM=redboard_artemis_atp include ../../Makefile.common diff --git a/boards/apollo3/redboard_artemis_nano/Makefile b/boards/apollo3/redboard_artemis_nano/Makefile index 28e0be8d4c..3f6828d6f6 100644 --- a/boards/apollo3/redboard_artemis_nano/Makefile +++ b/boards/apollo3/redboard_artemis_nano/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the RedBoard Artemis Nano platform # -TARGET=thumbv7em-none-eabi -PLATFORM=redboard_artemis_nano include ../../Makefile.common diff --git a/boards/arty_e21/Makefile b/boards/arty_e21/Makefile index 0c10493cd8..c60d5d1631 100644 --- a/boards/arty_e21/Makefile +++ b/boards/arty_e21/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the HiFive1 platform -TARGET=riscv32imac-unknown-none-elf -PLATFORM=arty_e21 - include ../Makefile.common TOCKLOADER=tockloader diff --git a/boards/clue_nrf52840/Makefile b/boards/clue_nrf52840/Makefile index ed33251eb6..c36a0803ac 100644 --- a/boards/clue_nrf52840/Makefile +++ b/boards/clue_nrf52840/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the CLUE nRF52840 board. -TOCK_ARCH=cortex-m4 -TARGET=thumbv7em-none-eabi -PLATFORM=clue_nrf52840 - include ../Makefile.common ifdef PORT diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/Makefile b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/Makefile index 99e0a57161..8cfe49d181 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/Makefile +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/Makefile @@ -2,8 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. -TARGET=thumbv7em-none-eabi -PLATFORM=nrf52840dk-test-appid-sha256 - include ../../../Makefile.common include ../nrf52840dk.mk diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/Makefile b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/Makefile index 6008df0d70..8cfe49d181 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/Makefile +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-appid-tbf/Makefile @@ -2,8 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. -TARGET=thumbv7em-none-eabi -PLATFORM=nrf52840dk-test-appid-tbf - include ../../../Makefile.common include ../nrf52840dk.mk diff --git a/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/Makefile b/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/Makefile index c97b7a8ed8..8cfe49d181 100644 --- a/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/Makefile +++ b/boards/configurations/nrf52840dk/nrf52840dk-test-kernel/Makefile @@ -2,8 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. -TARGET=thumbv7em-none-eabi -PLATFORM=nrf52840dk-test-kernel - include ../../../Makefile.common include ../nrf52840dk.mk diff --git a/boards/esp32-c3-devkitM-1/Makefile b/boards/esp32-c3-devkitM-1/Makefile index 4b88d9a3cd..52c572e0dd 100644 --- a/boards/esp32-c3-devkitM-1/Makefile +++ b/boards/esp32-c3-devkitM-1/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the ESP32-C3 platform -TARGET=riscv32imc-unknown-none-elf -PLATFORM=esp32-c3-board RISC_PREFIX = riscv64-linux-gnu include ../Makefile.common diff --git a/boards/hail/Makefile b/boards/hail/Makefile index 83abd0eb7d..7ddad88afa 100644 --- a/boards/hail/Makefile +++ b/boards/hail/Makefile @@ -5,7 +5,6 @@ # Makefile for building the tock kernel for the Hail platform TARGET=thumbv7em-none-eabi -PLATFORM=hail USE_STABLE_RUST=1 include ../Makefile.common diff --git a/boards/hifive1/Makefile b/boards/hifive1/Makefile index 39ab6518fd..dc71ab9cbe 100644 --- a/boards/hifive1/Makefile +++ b/boards/hifive1/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the HiFive1 platform -TARGET=riscv32imac-unknown-none-elf -PLATFORM=hifive1 QEMU ?= qemu-system-riscv32 include ../Makefile.common diff --git a/boards/hifive_inventor/Makefile b/boards/hifive_inventor/Makefile index 7e473ed2b6..a7691c3718 100644 --- a/boards/hifive_inventor/Makefile +++ b/boards/hifive_inventor/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the HiFive Inventor platform -TARGET=riscv32imac-unknown-none-elf -PLATFORM=hifive_inventor QEMU ?= qemu-system-riscv32 include ../Makefile.common diff --git a/boards/imix/Makefile b/boards/imix/Makefile index 574e606fcb..2654d4a781 100644 --- a/boards/imix/Makefile +++ b/boards/imix/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the Imix platform -TARGET=thumbv7em-none-eabi -PLATFORM=imix - include ../Makefile.common TOCKLOADER=tockloader diff --git a/boards/imxrt1050-evkb/Makefile b/boards/imxrt1050-evkb/Makefile index 6e844fd47f..e131d36c7a 100644 --- a/boards/imxrt1050-evkb/Makefile +++ b/boards/imxrt1050-evkb/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the i.MX RT1052 platform -TARGET=thumbv7em-none-eabi -PLATFORM=imxrt1050-evkb - include ../Makefile.common # Default target for installing the kernel. diff --git a/boards/litex/arty/Makefile b/boards/litex/arty/Makefile index e761758ac4..d69e343d50 100644 --- a/boards/litex/arty/Makefile +++ b/boards/litex/arty/Makefile @@ -5,8 +5,5 @@ # Makefile for building the tock kernel for a LiteX SoC targeting a # Digilent Arty-A7 FPGA development board -TARGET=riscv32imc-unknown-none-elf -PLATFORM=litex_arty - include ../../Makefile.common diff --git a/boards/litex/sim/Makefile b/boards/litex/sim/Makefile index f6f573c261..a729b6f569 100644 --- a/boards/litex/sim/Makefile +++ b/boards/litex/sim/Makefile @@ -5,8 +5,5 @@ # Makefile for building the tock kernel for a LiteX SoC running in a # Verilated simulation -TARGET=riscv32imc-unknown-none-elf -PLATFORM=litex_sim - include ../../Makefile.common diff --git a/boards/makepython-nrf52840/Makefile b/boards/makepython-nrf52840/Makefile index 7f1258392c..4f2f1fd863 100644 --- a/boards/makepython-nrf52840/Makefile +++ b/boards/makepython-nrf52840/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the Arduino Nano 33 BLE board. -TOCK_ARCH=cortex-m4 -TARGET=thumbv7em-none-eabi -PLATFORM=makepython-nrf52840 - include ../Makefile.common ifdef PORT diff --git a/boards/microbit_v2/Makefile b/boards/microbit_v2/Makefile index 9517629f75..eef439c94c 100644 --- a/boards/microbit_v2/Makefile +++ b/boards/microbit_v2/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the BBC microbit v2 board. -TOCK_ARCH=cortex-m4 -TARGET=thumbv7em-none-eabi -PLATFORM=microbit_v2 - include ../Makefile.common OPENOCD=openocd diff --git a/boards/msp_exp432p401r/Makefile b/boards/msp_exp432p401r/Makefile index 21ed3bc732..4008d61f8b 100644 --- a/boards/msp_exp432p401r/Makefile +++ b/boards/msp_exp432p401r/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the MSP-EXP432P401 launchpad # -TARGET=thumbv7em-none-eabi -PLATFORM=msp-exp432p401r include ../Makefile.common diff --git a/boards/nano33ble/Makefile b/boards/nano33ble/Makefile index d16030a01b..69c9258510 100644 --- a/boards/nano33ble/Makefile +++ b/boards/nano33ble/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the Arduino Nano 33 BLE board. -TOCK_ARCH=cortex-m4 -TARGET=thumbv7em-none-eabi -PLATFORM=nano33ble - include ../Makefile.common ifdef PORT diff --git a/boards/nano33ble_rev2/Makefile b/boards/nano33ble_rev2/Makefile index f5d3a52c22..4b4297dede 100644 --- a/boards/nano33ble_rev2/Makefile +++ b/boards/nano33ble_rev2/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the Arduino Nano 33 BLE Sense Rev2 board. -TOCK_ARCH=cortex-m4 -TARGET=thumbv7em-none-eabi -PLATFORM=nano33ble_rev2 - include ../Makefile.common ifdef PORT diff --git a/boards/nano_rp2040_connect/Makefile b/boards/nano_rp2040_connect/Makefile index c66757a7c9..b2add56a63 100644 --- a/boards/nano_rp2040_connect/Makefile +++ b/boards/nano_rp2040_connect/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the Arduino Nano RP2040 Connect board. -TOCK_ARCH=cortex-m0p -TARGET=thumbv6m-none-eabi -PLATFORM=nano_rp2040_connect - include ../Makefile.common KERNEL=$(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).elf diff --git a/boards/nordic/nrf52840_dongle/Makefile b/boards/nordic/nrf52840_dongle/Makefile index 28ad999a96..bb98b113dc 100644 --- a/boards/nordic/nrf52840_dongle/Makefile +++ b/boards/nordic/nrf52840_dongle/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the nRF development kit -TARGET=thumbv7em-none-eabi -PLATFORM=nrf52840_dongle - include ../../Makefile.common TOCKLOADER=tockloader diff --git a/boards/nordic/nrf52840dk/Makefile b/boards/nordic/nrf52840dk/Makefile index 0838920eff..34c5228ac7 100644 --- a/boards/nordic/nrf52840dk/Makefile +++ b/boards/nordic/nrf52840dk/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the nRF development kit -TARGET=thumbv7em-none-eabi -PLATFORM=nrf52840dk - include ../../Makefile.common TOCKLOADER=tockloader diff --git a/boards/nordic/nrf52dk/Makefile b/boards/nordic/nrf52dk/Makefile index 6aee9c5256..d248bcd4cb 100644 --- a/boards/nordic/nrf52dk/Makefile +++ b/boards/nordic/nrf52dk/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the nRF52 development kit -TARGET=thumbv7em-none-eabi -PLATFORM=nrf52dk - include ../../Makefile.common TOCKLOADER=tockloader diff --git a/boards/nucleo_f429zi/Makefile b/boards/nucleo_f429zi/Makefile index 028aa98743..5f3fe4fa10 100644 --- a/boards/nucleo_f429zi/Makefile +++ b/boards/nucleo_f429zi/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the NUCLEO-429ZI platform # -TARGET=thumbv7em-none-eabi -PLATFORM=nucleo_f429zi include ../Makefile.common diff --git a/boards/nucleo_f446re/Makefile b/boards/nucleo_f446re/Makefile index a816188618..1086912335 100644 --- a/boards/nucleo_f446re/Makefile +++ b/boards/nucleo_f446re/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the NUCLEO-446RE platform # -TARGET=thumbv7em-none-eabi -PLATFORM=nucleo_f446re include ../Makefile.common diff --git a/boards/opentitan/earlgrey-cw310/Makefile b/boards/opentitan/earlgrey-cw310/Makefile index 627e9a223a..d5b0e62ef3 100644 --- a/boards/opentitan/earlgrey-cw310/Makefile +++ b/boards/opentitan/earlgrey-cw310/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the OpenTitan platform -TARGET=riscv32imc-unknown-none-elf -PLATFORM=earlgrey-cw310 FLASHID=--dev-id="0403:6010" RISC_PREFIX ?= riscv64-linux-gnu QEMU ?= ../../../tools/qemu/build/qemu-system-riscv32 diff --git a/boards/particle_boron/Makefile b/boards/particle_boron/Makefile index 3ac8098250..b5eda5fe05 100644 --- a/boards/particle_boron/Makefile +++ b/boards/particle_boron/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the Particle Boron -TARGET=thumbv7em-none-eabi -PLATFORM=particle_boron - include ../Makefile.common TOCKLOADER=tockloader diff --git a/boards/pico_explorer_base/Makefile b/boards/pico_explorer_base/Makefile index 927633fa92..aa149036b6 100644 --- a/boards/pico_explorer_base/Makefile +++ b/boards/pico_explorer_base/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the Pico Explorer Base board. -TOCK_ARCH=cortex-m0p -TARGET=thumbv6m-none-eabi -PLATFORM=pico_explorer_base - include ../Makefile.common OPENOCD=openocd diff --git a/boards/qemu_rv32_virt/Makefile b/boards/qemu_rv32_virt/Makefile index 61327ab577..e305cf2a0e 100644 --- a/boards/qemu_rv32_virt/Makefile +++ b/boards/qemu_rv32_virt/Makefile @@ -5,9 +5,6 @@ # Makefile for building the Tock kernel for the qemu-system-riscv32 `virt` # platform / machine type. -TARGET = riscv32imac-unknown-none-elf -PLATFORM = qemu_rv32_virt - include ../Makefile.common QEMU_CMD := qemu-system-riscv32 diff --git a/boards/raspberry_pi_pico/Makefile b/boards/raspberry_pi_pico/Makefile index e61730a3fc..aa149036b6 100644 --- a/boards/raspberry_pi_pico/Makefile +++ b/boards/raspberry_pi_pico/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the Pico Explorer Base board. -TOCK_ARCH=cortex-m0p -TARGET=thumbv6m-none-eabi -PLATFORM=raspberry_pi_pico - include ../Makefile.common OPENOCD=openocd diff --git a/boards/redboard_redv/Makefile b/boards/redboard_redv/Makefile index 2a7bf9f60b..ac3a0fb753 100644 --- a/boards/redboard_redv/Makefile +++ b/boards/redboard_redv/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the RedV platform -TARGET=riscv32imac-unknown-none-elf -PLATFORM=redboard_redv QEMU ?= qemu-system-riscv32 include ../Makefile.common diff --git a/boards/sma_q3/Makefile b/boards/sma_q3/Makefile index 8061e67037..af2e30b4c5 100644 --- a/boards/sma_q3/Makefile +++ b/boards/sma_q3/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the SMA Q3 smart watch -TARGET=thumbv7em-none-eabi -PLATFORM=sma_q3 - include ../Makefile.common TOCKLOADER=tockloader diff --git a/boards/stm32f3discovery/Makefile b/boards/stm32f3discovery/Makefile index d14974b371..93216ad2d9 100644 --- a/boards/stm32f3discovery/Makefile +++ b/boards/stm32f3discovery/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the STM32F3DISCOVERY platform # -TARGET=thumbv7em-none-eabi -PLATFORM=stm32f3discovery include ../Makefile.common diff --git a/boards/stm32f412gdiscovery/Makefile b/boards/stm32f412gdiscovery/Makefile index 2c353b7f8f..d0a22130cd 100644 --- a/boards/stm32f412gdiscovery/Makefile +++ b/boards/stm32f412gdiscovery/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the stm32412gdiscovery platform # -TARGET=thumbv7em-none-eabi -PLATFORM=stm32f412gdiscovery include ../Makefile.common diff --git a/boards/stm32f429idiscovery/Makefile b/boards/stm32f429idiscovery/Makefile index 5af464414f..49069bd5ca 100644 --- a/boards/stm32f429idiscovery/Makefile +++ b/boards/stm32f429idiscovery/Makefile @@ -4,8 +4,6 @@ # Makefile for building the tock kernel for the STM32F429i Discovery board # -TARGET=thumbv7em-none-eabi -PLATFORM=stm32f429idiscovery include ../Makefile.common diff --git a/boards/swervolf/Makefile b/boards/swervolf/Makefile index e21213b87c..e66069c0e1 100644 --- a/boards/swervolf/Makefile +++ b/boards/swervolf/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the SweRVolf platform -TARGET=riscv32imc-unknown-none-elf -PLATFORM=swervolf - include ../Makefile.common # Default target for installing the kernel. diff --git a/boards/teensy40/Makefile b/boards/teensy40/Makefile index 30098ec9f8..5c7f38ac6e 100644 --- a/boards/teensy40/Makefile +++ b/boards/teensy40/Makefile @@ -4,9 +4,6 @@ # Makefile for building the tock kernel for the Teensy 4 -TARGET=thumbv7em-none-eabi -PLATFORM=teensy40 - include ../Makefile.common # Default target for installing the kernel. diff --git a/boards/tutorials/nrf52840dk-hotp-tutorial/Makefile b/boards/tutorials/nrf52840dk-hotp-tutorial/Makefile index 211bf81cbf..07f917f20f 100644 --- a/boards/tutorials/nrf52840dk-hotp-tutorial/Makefile +++ b/boards/tutorials/nrf52840dk-hotp-tutorial/Makefile @@ -2,8 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2024. -TARGET=thumbv7em-none-eabi -PLATFORM=nrf52840dk-hotp-tutorial - include ../../Makefile.common include ../../configurations/nrf52840dk/nrf52840dk.mk diff --git a/boards/tutorials/nrf52840dk-thread-tutorial/Makefile b/boards/tutorials/nrf52840dk-thread-tutorial/Makefile index 6bf14928c1..ac9238d30a 100644 --- a/boards/tutorials/nrf52840dk-thread-tutorial/Makefile +++ b/boards/tutorials/nrf52840dk-thread-tutorial/Makefile @@ -2,8 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2022. -TARGET=thumbv7em-none-eabi -PLATFORM=nrf52840dk-thread-tutorial - include ../../Makefile.common include ../../configurations/nrf52840dk/nrf52840dk.mk diff --git a/boards/weact_f401ccu6/Makefile b/boards/weact_f401ccu6/Makefile index 061e5f9ac2..f14b977d5f 100644 --- a/boards/weact_f401ccu6/Makefile +++ b/boards/weact_f401ccu6/Makefile @@ -3,8 +3,6 @@ # Copyright Tock Contributors 2022. # Makefile for building the tock kernel for the WeAct STM32F401CCU6 Core Board -TARGET=thumbv7em-none-eabihf -PLATFORM=weact-f401ccu6 KERNEL=$(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).elf KERNEL_WITH_APP=$(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM)-app.elf diff --git a/boards/wm1110dev/Makefile b/boards/wm1110dev/Makefile index 615b99accd..0f0a38dfbd 100644 --- a/boards/wm1110dev/Makefile +++ b/boards/wm1110dev/Makefile @@ -4,10 +4,6 @@ # Makefile for building the tock kernel for the Arduino Nano 33 BLE board. -TOCK_ARCH=cortex-m4 -TARGET=thumbv7em-none-eabi -PLATFORM=wm1110dev - include ../Makefile.common ifdef PORT @@ -27,4 +23,4 @@ program: $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM).bin flash-bootloader: curl -L --output /tmp/wm1110_dev-bootloader_v1.1.3.bin https://github.com/tock/tock-bootloader/releases/download/v1.1.3/wm1110_dev-bootloader_v1.1.3.bin tockloader flash --address 0 /tmp/wm1110_dev-bootloader_v1.1.3.bin - rm /tmp/wm1110_dev-bootloader_v1.1.3.bin \ No newline at end of file + rm /tmp/wm1110_dev-bootloader_v1.1.3.bin From 76f7ac031ac4b8f34534b796b67b11c1e744f230 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 16 Jul 2024 16:17:42 -0400 Subject: [PATCH 29/33] boards: make: no need to create target dir --- boards/Makefile.common | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index dfcbc869ff..745c19d39d 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -39,8 +39,7 @@ else RUSTUP ?= true endif -# Default location of target directory (relative to board makefile) passed to -# cargo `--target_dir`. +# Default location of target directory (relative to board makefile). TARGET_DIRECTORY ?= $(TOCK_ROOT_DIRECTORY)target/ # http://stackoverflow.com/questions/10858261/abort-makefile-if-variable-not-set @@ -256,7 +255,7 @@ debug: $(TARGET_PATH)/debug/$(PLATFORM).bin debug-lst: $(TARGET_PATH)/debug/$(PLATFORM).lst .PHONY: doc -doc: | target +doc: $(Q)$(CARGO) --color=always doc $(VERBOSE_FLAGS) --release --package $(PLATFORM) @@ -282,9 +281,6 @@ memory: $(TARGET_PATH)/release/$(PLATFORM).elf # Support rules -target: - @mkdir -p $(TARGET_PATH) - # Cargo outputs an elf file (just without a file extension) %.elf: % $(Q)cp $< $@ From bcce85a26cbf44216ded389116bcf2b38d607e71 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 16 Jul 2024 16:59:37 -0400 Subject: [PATCH 30/33] boards: make: set sentinel in config.toml Then check that it exists in build.rs. It's pretty gobsmacking what it takes to make a semi-reasonable build system using cargo. --- boards/build.rs | 27 +++++++++++++++++++++++++++ boards/cargo/tock_flags.toml | 3 +++ boards/hail/.cargo/config.toml | 3 +++ 3 files changed, 33 insertions(+) diff --git a/boards/build.rs b/boards/build.rs index dd5ffb0405..8529ed0b4f 100644 --- a/boards/build.rs +++ b/boards/build.rs @@ -24,6 +24,33 @@ fn main() { panic!("Boards must provide a `layout.ld` link script file"); } + // The `RUSTFLAGS` that the Tock config files set can be easily overridden + // by command line flags. The build will still succeed but the resulting + // binary may be invalid as it was not built with the intended flags. This + // check seeks to prevent that. Our approach is we set a sentinel flag in + // our configuration file and then check that it is set here. If it isn't, + // the flags were overwritten and the build will be invalid. + // + // We only do this check if we are actually building for an embedded target + // (i.e., the TARGET is not the same as the HOST). This avoids a false + // positive when running tools like `cargo clippy`. + // + // If you are intentionally not using the standard Tock config files, set + // `cfg-tock-buildflagssentinel` in your cargo config to prevent this + // error. + if std::env::var("HOST") != std::env::var("TARGET") { + let rust_flags = std::env::var("CARGO_ENCODED_RUSTFLAGS"); + if !rust_flags + .iter() + .any(|f| f.contains("cfg_tock_buildflagssentinel")) + { + panic!( + "Incorrect build configuration. \ + Verify you have not unintentionally set the RUSTFLAGS environment variable." + ); + } + } + // Include the folder where the board's Cargo.toml is in the linker file // search path. println!("cargo:rustc-link-arg=-L{}", std::env!("CARGO_MANIFEST_DIR")); diff --git a/boards/cargo/tock_flags.toml b/boards/cargo/tock_flags.toml index 16c878f2d7..dbd8bafc42 100644 --- a/boards/cargo/tock_flags.toml +++ b/boards/cargo/tock_flags.toml @@ -4,6 +4,9 @@ [build] rustflags = [ + # Set a sentinel cfg flag so that we know this configuration file was included + # in the build. This is checked in build.rs. + "--cfg", "cfg_tock_buildflagssentinel", # Tell rustc to use the LLVM linker. This avoids needing GCC as a dependency # to build the kernel. "-C", "linker=rust-lld", diff --git a/boards/hail/.cargo/config.toml b/boards/hail/.cargo/config.toml index 489163269a..026b7d3901 100644 --- a/boards/hail/.cargo/config.toml +++ b/boards/hail/.cargo/config.toml @@ -8,6 +8,9 @@ [build] target = "thumbv7em-none-eabi" rustflags = [ + # Set a sentinel cfg flag so that we know this configuration file was included + # in the build. This is checked in build.rs. + "--cfg", "cfg_tock_buildflagssentinel", # Tell rustc to use the LLVM linker. This avoids needing GCC as a dependency # to build the kernel. "-C", "linker=rust-lld", From 19fbd07c297e8256455173ef542e2be4f7771f5f Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Wed, 17 Jul 2024 13:08:51 -0400 Subject: [PATCH 31/33] boards: make: add back verbose to cargo build Now that we don't have CARGO_FLAGS_TOCK we lost the `make V=1` --verbose flag. This adds that back to match the other cargo commands in the makefile. --- boards/Makefile.common | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index 745c19d39d..0e9c1edb2b 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -304,10 +304,10 @@ $(TOCK_ROOT_DIRECTORY)tools/sha256sum/target/debug/sha256sum: .PHONY: $(TARGET_PATH)/release/$(PLATFORM) $(TARGET_PATH)/release/$(PLATFORM): - $(Q)$(CARGO) rustc $(CARGO_FLAGS) --bin $(PLATFORM) --release + $(Q)$(CARGO) rustc $(VERBOSE_FLAGS) $(CARGO_FLAGS) --bin $(PLATFORM) --release $(Q)$(SIZE) $(SIZE_FLAGS) $@ .PHONY: $(TARGET_PATH)/debug/$(PLATFORM) $(TARGET_PATH)/debug/$(PLATFORM): - $(Q)$(CARGO) build $(CARGO_FLAGS) --bin $(PLATFORM) + $(Q)$(CARGO) build $(VERBOSE_FLAGS) $(CARGO_FLAGS) --bin $(PLATFORM) $(Q)$(SIZE) $(SIZE_FLAGS) $@ From e3b44e4661e0d64b93b073479ead59a36d6f2b32 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Sun, 21 Jul 2024 10:58:48 -0700 Subject: [PATCH 32/33] boards: re-add RUST_FLAGS to build using cargo --- boards/Makefile.common | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boards/Makefile.common b/boards/Makefile.common index 0e9c1edb2b..232165826a 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -195,6 +195,7 @@ endif # Dump configuration for verbose builds ifeq ($(VERBOSE_MODE),1) +RUST_FLAGS = $(shell $(CARGO) -Zunstable-options config get build.rustflags --format json-value 2> /dev/null || echo "Listing Rust flags only accessible on nightly cargo") $(info ) $(info *******************************************************) $(info TOCK KERNEL BUILD SYSTEM -- VERBOSE BUILD CONFIGURATION) @@ -206,6 +207,7 @@ ifeq ($(VERBOSE_MODE),1) $(info PLATFORM = $(PLATFORM)) $(info TARGET = $(TARGET)) $(info TOCK_KERNEL_VERSION = $(TOCK_KERNEL_VERSION)) + $(info RUSTFLAGS = $(RUST_FLAGS)) $(info MAKEFLAGS = $(MAKEFLAGS)) $(info OBJDUMP_FLAGS = $(OBJDUMP_FLAGS)) $(info OBJCOPY_FLAGS = $(OBJCOPY_FLAGS)) From a7190c4f4c747fa02cd7800cddd84bece6f5a2a5 Mon Sep 17 00:00:00 2001 From: Amit Aryeh Levy Date: Sun, 21 Jul 2024 11:12:15 -0700 Subject: [PATCH 33/33] boards: remove CARGO_FLAGS in Makefile.common Instead, just override the rules in earlgrey that are the only ones that rely on it (to set features). --- boards/Makefile.common | 13 +++---------- boards/opentitan/earlgrey-cw310/Makefile | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/boards/Makefile.common b/boards/Makefile.common index 232165826a..5ab3bea373 100644 --- a/boards/Makefile.common +++ b/boards/Makefile.common @@ -157,12 +157,6 @@ OBJDUMP ?= $(TOOLCHAIN)-objdump # removing it, we prevent the kernel binary from overwriting applications. OBJCOPY_FLAGS ?= --strip-sections --strip-all --remove-section .apps -# This make variable allows board-specific Makefiles to pass down options to -# the Cargo build command. For example, in boards//Makefile: -# `CARGO_FLAGS += --features=foo` would pass feature `foo` to the top level -# Cargo.toml. -CARGO_FLAGS ?= - # Set the default flags we need for objdump to get a .lst file. OBJDUMP_FLAGS ?= --disassemble-all --source --section-headers --demangle @@ -211,7 +205,6 @@ RUST_FLAGS = $(shell $(CARGO) -Zunstable-options config get build.rustflags --fo $(info MAKEFLAGS = $(MAKEFLAGS)) $(info OBJDUMP_FLAGS = $(OBJDUMP_FLAGS)) $(info OBJCOPY_FLAGS = $(OBJCOPY_FLAGS)) - $(info CARGO_FLAGS = $(CARGO_FLAGS)) $(info SIZE_FLAGS = $(SIZE_FLAGS)) $(info ) $(info TOOLCHAIN = $(TOOLCHAIN)) @@ -240,7 +233,7 @@ all: release # binary. This makes checking for Rust errors much faster. .PHONY: check check: - $(Q)$(CARGO) check $(VERBOSE_FLAGS) $(CARGO_FLAGS) + $(Q)$(CARGO) check $(VERBOSE_FLAGS) .PHONY: clean @@ -306,10 +299,10 @@ $(TOCK_ROOT_DIRECTORY)tools/sha256sum/target/debug/sha256sum: .PHONY: $(TARGET_PATH)/release/$(PLATFORM) $(TARGET_PATH)/release/$(PLATFORM): - $(Q)$(CARGO) rustc $(VERBOSE_FLAGS) $(CARGO_FLAGS) --bin $(PLATFORM) --release + $(Q)$(CARGO) rustc $(VERBOSE_FLAGS) --bin $(PLATFORM) --release $(Q)$(SIZE) $(SIZE_FLAGS) $@ .PHONY: $(TARGET_PATH)/debug/$(PLATFORM) $(TARGET_PATH)/debug/$(PLATFORM): - $(Q)$(CARGO) build $(VERBOSE_FLAGS) $(CARGO_FLAGS) --bin $(PLATFORM) + $(Q)$(CARGO) build $(VERBOSE_FLAGS) --bin $(PLATFORM) $(Q)$(SIZE) $(SIZE_FLAGS) $@ diff --git a/boards/opentitan/earlgrey-cw310/Makefile b/boards/opentitan/earlgrey-cw310/Makefile index d5b0e62ef3..59242308d2 100644 --- a/boards/opentitan/earlgrey-cw310/Makefile +++ b/boards/opentitan/earlgrey-cw310/Makefile @@ -22,9 +22,23 @@ include ../../Makefile.common # Pass OpenTitan board configuration option in `BOARD_CONFIGURATION` through # Cargo `--features`. Please see `Cargo.toml` for available options. ifneq ($(BOARD_CONFIGURATION),) - CARGO_FLAGS += --no-default-features --features=$(BOARD_CONFIGURATION) + CARGO_FLAGS = --no-default-features --features=$(BOARD_CONFIGURATION) endif +.PHONY: check +check: + $(Q)$(CARGO) check $(VERBOSE_FLAGS) $(CARGO_FLAGS) + +.PHONY: $(TARGET_PATH)/release/$(PLATFORM) +$(TARGET_PATH)/release/$(PLATFORM): + $(Q)$(CARGO) build $(VERBOSE_FLAGS) $(CARGO_FLAGS) --release + $(Q)$(SIZE) $(SIZE_FLAGS) $@ + +.PHONY: $(TARGET_PATH)/debug/$(PLATFORM) +$(TARGET_PATH)/debug/$(PLATFORM): + $(Q)$(CARGO) build $(VERBOSE_FLAGS) $(CARGO_FLAGS) + $(Q)$(SIZE) $(SIZE_FLAGS) $@ + .PHONY: ot-check ifneq ($(OPENTITAN_TREE),) OPENTITAN_ACTUAL_SHA := $(shell cd $(OPENTITAN_TREE); git show --pretty=format:"%H" --no-patch)