Description
Split peripheral modules into crates
This proposal is to add a CLI option to split peripheral modules into separate crates in a project workspace.
Motivation
For large PAC crates, compilation on machines with less-powerful cores is excruciatingly slow. The bottleneck for any projects depending on the PAC crate is obviously the PAC, because one core is pinged to full usage, while all other cores are idle.
By splitting the PAC into separate crates for each peripheral, each core could work on a separate peripheral crate. The separate crates could also improve incremental compilation, since a change in one of the peripheral crates would not necessarily require recompilation of other peripheral crates.
Challenges
Much of the plumbing is already there for creating separate crates for each peripheral.
Each peripheral already generates its own module.
Peripheral versioning would inherit from the top-level Cargo.toml
version.
The main challenge will be making minimal changes to enable the code generation, without adding too much to maintainability burden.
Example
An example project structure might look like:
- Cargo.toml
- <soc>-generic
- Cargo.toml
- src
- lib.rs
- <soc>-i2c
- Cargo.toml
- src
- lib.rs
- i2c0
- i2c1
- ...
- i2c<N>
- <soc>-spi
- Cargo.toml
- src
- lib.rs
- spi0
- spi1
- ...
- spi<N>
Alternative approaches
Once the parallel front-end is stable in rustc
, the main motivation for this proposal may be less relevant.
However, there will still be users stuck on older versions of rustc
where this proposal will be useful.