Skip to content

Commit

Permalink
Switch back to a workspace.
Browse files Browse the repository at this point in the history
I switched away from a Cargo Workspace in the days before resolver="2"
was an option -- it's required to get feature resolution to be separate
per binary target in a workspace, which is in turn required because of
how the PACs abuse Cargo features.

That's been fixed for like three years, however, and a workspace
slightly reduces build times and greatly reduces target directory size.

The interaction between workspaces and .cargo/config.toml is still
frustrating -- config.toml is still the only way to set several critical
build options, but is ignored unless you CD into the relevant directory
before building, which is otherwise not required in a workspace. But,
I'll give this a shot.

Before:
- Clean build: 2m27s
- No-change rebuild: 0.428s

After:
- Clean build: 30s (!)
- rebuild: 16s :/
  • Loading branch information
cbiffle committed Apr 26, 2024
1 parent 1df4598 commit 237e33e
Show file tree
Hide file tree
Showing 48 changed files with 391 additions and 2,714 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
name: lm3s6965-image-pinned
path: |
testsuite/lm3s6965/target/thumbv7m-none-eabi/debug/lilos-testsuite-lm3s6965
target/thumbv7m-none-eabi/debug/lilos-testsuite-lm3s6965
test_qemu:
needs: build
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
with:
name: lm3s6965-image-${{ matrix.toolchain }}
path: |
testsuite/lm3s6965/target/thumbv7m-none-eabi/debug/lilos-testsuite-lm3s6965
target/thumbv7m-none-eabi/debug/lilos-testsuite-lm3s6965
test_qemu_future:
strategy:
Expand Down
162 changes: 162 additions & 0 deletions testsuite/stm32f4/Cargo.lock → Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[workspace]
resolver = "2"
members = [
"os",
"handoff",
"examples/*/*",
"testsuite",
"testsuite/stm32f3",
"testsuite/stm32f4",
"testsuite/stm32g0",
"testsuite/lm3s6965",
]

[workspace.package]
# common defaults
edition = "2021"
license = "MPL-2.0"
repository = "https://github.com/cbiffle/lilos"
rust-version = "1.69"

[workspace.dependencies]
# Internal
lilos = { path = "os", version = "1.0.2-pre.0", default-features = false }
lilos-testsuite = { path = "testsuite" }
lilos-handoff = { path = "handoff" }

# External
cfg-if = "1.0.0"
cortex-m = {version = "0.7.4", features = ["inline-asm"]}
cortex-m-rt = {version = "0.7.1"}
cortex-m-semihosting = "0.5.0"
pin-project = "1.1.5"
panic-halt = "0.2.0"
panic-semihosting = "0.6.0"
futures = { version = "0.3.21", default-features = false, features = ["async-await"] }
stm32-metapac = {version = "15.0", features = ["rt", "pac"]}
rp2040-pac = {version = "0.3", features = ["rt"]}
rp2040-boot2 = "0.2"
scopeguard = { version = "1.2.0", default-features = false }

#
# Before you get excited about turning on the workspace.lints table here, note
# that it is silently ignored by our MSRV of 1.69.
#

# Turn on some basic optimizations even in dev for space reasons.
[profile.dev]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
opt-level = 1 # very basic optimization

# The testsuite ain't tiny and doesn't fit in a 32 kiB M0 without
# cranking up the optimization level:
[profile.dev.package.lilos-testsuite-stm32g0]
opt-level = "s"

[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
opt-level = "s"
overflow-checks = true
8 changes: 5 additions & 3 deletions README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ will find it useful too.

## Repo layout

This repo contains crates in subdirectories, but it is _not_ a Cargo workspace.
This means you will need to `cd` into subdirectories to build things. Here is a
map:
This repo contains crates in subdirectories, and the subdirectories use
`.cargo/config.toml` files to change settings that Cargo has so far declined to
allow in `Cargo.toml`, such as the target triple. This means you will need to
`cd` into subdirectories to build things, rather than using `cargo build
--all`. Here is a map:

- `os` contains the operating system crate.
- `testsuite` contains a test suite for the operating system, which can run on a
Expand Down
3 changes: 3 additions & 0 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ done
DIRS="handoff testsuite/stm32f4 testsuite/stm32g0 testsuite/stm32f3 testsuite/lm3s6965 examples/*/*/"

for d in $DIRS; do
if [[ $d == *memory.x ]]; then
continue
fi
echo "---- building in $d"
pushd $d > /dev/null
cargo build
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion examples/rp2040/minimal/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
runner = "elf2uf2-rs -d"

rustflags = [
"-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Lexamples/rp2040",
]

[build]
Expand Down
Loading

0 comments on commit 237e33e

Please sign in to comment.