New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix various cfg-related crimes #1774
base: master
Are you sure you want to change the base?
Conversation
These were named after the generic processor model, which isn't right.
09a9197
to
013ffeb
Compare
This code can't be built, because we have no board support for PSC A anymore.
All of this code was statically unreachable and hasn't been built in... years, at this point. If we want it we can find it in version control.
There's no way to turn this on, so it definitely hasn't been tested in $PERIOD.
a212a56
to
1d3d2ad
Compare
The trailing compile_error! will do fine, and this prevents it from matching on something that rustc thinks is a typo'd board name.
Jefe had a check that attempted to avoid building dump support on LPC55, but that check didn't work, because it was checking for the presence of one of our custom cfgs...but not doing the invocation in its build script that actually generates that cfg. rustc will start checking such things soon, which is how I found this.
This crate was generating code that required the _client crate_ to have certain features defined, which is almost certainly a mistake, since this crate has the same set of features. Changed to key off features in the code generator instead.
As of this commit, the following two classes of mistakes will be caught when using a recent rustc: 1. Detecting the armv6m, armv7m, or armv8m features without a build script that actually exposes them. 2. Misspelling a target_board.
We were apparently picking up this feature from a dep, which changed when I attempted a cargo update.
|
||
let values = boards.join(","); | ||
|
||
println!("cargo:rustc-check-cfg=cfg(target_board, values({values}))"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it took me a while to figure out what was going on here, but it's amazing
#[cfg(feature = "h7b3")] | ||
OctoSpi1 = periph(Group::Ahb3, 14), // B3 only | ||
#[cfg(any(feature = "h743", feature = "h747", feature = "h753"))] | ||
#[cfg(any(feature = "h743", feature = "h753"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is any(feature = "h743", feature = "h753")
guaranteed to be true? Now that we've removed h7b3
support, h743
and h753
are the only remaining h7*
features, so I think we can remove this condition (and others below).
@@ -158,12 +151,9 @@ pub enum Peripheral { | |||
Swp = periph(Group::Apb1H, 2), | |||
Crsen = periph(Group::Apb1H, 1), | |||
|
|||
#[cfg(feature = "h7b3")] | |||
Dfsdm1 = periph(Group::Apb2, 30), // B3 differs from 43/47 | |||
|
|||
Hrtim = periph(Group::Apb2, 29), // 43/47 only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by the comments in this file – there are many lines which was 43/47 only
but aren't gated on h743
.
(we could also probably remove the references to the B3
and 47
more generally, since they're both unsupported)
- `cargo xtask dist app/demo-stm32g0-nucleo/app-g0b1.toml` - stm32g0b1 | ||
- `cargo xtask dist app/demo-stm32g0-nucleo/app-g031.toml` - stm32g031-nucleo | ||
- `cargo xtask dist app/demo-stm32g0-nucleo/app-g070.toml` - stm32g070-nucleo | ||
- `cargo xtask dist app/demo-stm32g0-nucleo/app-g0b1.toml` - stm32g0b1-nucleo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming nit: should nucleo
be at the start or end? We have both stm32g0b1-nucleo
and nucleo-ih743zi2
board names.
@@ -71,7 +71,6 @@ cfg_if::cfg_if! { | |||
target_board = "gimlet-d", | |||
target_board = "gimlet-e", | |||
target_board = "gimlet-f", | |||
target_board = "sidecar-a", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫡
target_board = "psc-b", | ||
target_board = "psc-c" | ||
), | ||
any(target_board = "psc-b", target_board = "psc-c"), | ||
path = "bsp/psc_abc.rs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: rename to psc_bc.rs
now that rev A is gone?
Thanks for doing all of this cleanup! With the toolchain bump, do you see any changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
let Ok(dirent) = dirent else { | ||
continue; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we maybe print a warning on weird/bad dir entries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments passing by
); | ||
} | ||
boards.sort(); | ||
boards.dedup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Duplicates would probably be a mistake of some sort, maybe worth a warning print as well?
Hrtim = periph(Group::Apb2, 29), // 43/47 only | ||
|
||
#[cfg(any(feature = "h743", feature = "h747", feature = "h757"))] | ||
#[cfg(feature = "h743")] | ||
Dfsdm1 = periph(Group::Apb2, 28), // 43/47 differ from B3 | ||
|
||
Sai3 = periph(Group::Apb2, 24), // 43/47 only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: There's a bunch of "B3 only" commented lines below: Are those now entirely unused?
I have not yet been able to test this. I'd be willing to remove the toolchain bump from this PR, but the changes may regress and I'd like to opt out of refixing them. |
The nightly toolchain started doing checking for cfgs on Sunday, so I bumped our toolchain revision locally to see what it'd find.
In short, it got big mad.
This PR fixes All The Things. The commits provide detailed descriptions, but here's a summary:
target_board
) now have to be defined somewhere. I've added aboards
directory containing (currently empty) config files per board. Any reference to atarget_board
without a corresponding file will now be treated as a typo.psc-a
andsidecar-a
boards, which saw firmware support ended a while ago, but were never fully removed from the code.traptrace
feature in Sidecar, which isn't actually in the Cargo.toml and thus can't be built.stm32xx-i2c
, which was attempting to key off oftarget_board
without actually exposing the cfg in its build script. Forgetting to do this is now a compiler warning.jefe
, which was attempting to key off ofarmv8m
without actually exposing the cfg in its build script. Also now a warning.build/i2c
to use its own features instead of generating code that tried to match on features in its clients, which was working by accident.In order to formally move us to a toolchain that prevents this from regressing, I had to do some small unrelated fixes, namely:
core::uXX::MAX
constants, which are deprecated now.derive
macros produced code the new compiler dislikes.syn
feature inderive-idol-err
, which had apparently been picking it up from some dependency.