Repository navigation
cmake: lint the zephyr crate with a clippy_zephyr target - #3
Open
JPHutchins wants to merge 2 commits into
Open
JPHutchins wants to merge 2 commits into
JPHutchins wants to merge 2 commits into
Conversation
This was referenced Oct 28, 2026
The async GPIO code disables a firing pin with `ZR_GPIO_INT_MODE_DISABLE_ONLY`, which zephyr-sys defines only under CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT. That option is EXPERIMENTAL, and nothing in the module Kconfig or the crate declares the dependency. Any build with the `async-drivers` feature and CONFIG_GPIO=y but without the option, such as a blocking-pool app on a board with GPIO enabled, fails with "unresolved import `zephyr_sys::ZR_GPIO_INT_MODE_DISABLE_ONLY`". Compile the async GPIO module only when both are set, and fall back to the existing stub otherwise. Name the requirement next to the `async-drivers` feature. Selecting an EXPERIMENTAL symbol from the module Kconfig would force it on every Rust app. Checked on native_sim/native/64 with only CONFIG_GPIO=y added, running clippy with all features on the zephyr crate: without this change it fails with the unresolved import, and with it, it passes. Assisted-by: Claude:claude-opus-5-5
The `clippy` target lints only the application crate. The zephyr crate reaches the build as a `[patch.crates-io]` path dependency, not a workspace member, so cargo compiles it with rustc instead of clippy-driver and none of the module's lint flags ever apply to it. A deny-by-default lint (`eq_op`) planted in zephyr/src/lib.rs went unreported by `west build -t clippy`. Add `clippy_zephyr`, which runs clippy with the same Zephyr environment on the zephyr crate's manifest, with all features and the same flags as `clippy`. It is not part of ALL, so a new clippy release cannot break application builds. CI runs it next to `clippy` for every sample and platform in the test plan. Verified with the zephyr crate passing on native_sim/native/64 (hello_world, a minimal config without RUST_ALLOC and LOG, and a maximal config with GPIO, I2C, I2C target, flash, LED, LED strip and the blocking pool), qemu_cortex_m3 and qemu_cortex_m0. Assisted-by: Claude:claude-opus-5-5
JPHutchins
force-pushed
the
clippy/3-clippy-zephyr-target
branch
from
October 28, 2026 23:34
30a9fe7 to
365f6c2
Compare
JPHutchins
force-pushed
the
clippy/2-zephyr-lint
branch
from
October 28, 2026 23:34
256c55d to
5f7bdb3
Compare
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
LLM Disclosure
This post was authored by claude-opus-5-5 on behalf of @JPHutchins. JP asked to bring zephyr-lang-rust under strict clippy rules matching embassy's (default groups,
-D warnings), to report deficiencies found along the way, and to open the work as a stacked series of review PRs on the intercreate fork.Adds a
clippy_zephyrCMake target that lints thezephyrcrate itself, with the same Zephyr environment and flags asclippy. CI runs it for every sample and platform in the test plan. Before this, a deny-by-default lint (eq_op) planted inzephyr/src/lib.rswent unreported bywest build -t clippy. The target is not part ofALL, so a new clippy release cannot break application builds.The target lints with all features, so the PR first fixes an existing compile error. Async GPIO needs
CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT, an EXPERIMENTAL option that nothing declared. Anyasync-driversbuild withCONFIG_GPIO=ybut without that option failed with an unresolved import ofZR_GPIO_INT_MODE_DISABLE_ONLY.Stack, merge in order:
zephyrcrate passes the module's clippy flagsclippy_zephyrtarget and CI (this PR)embedded_hal_async::digital::WaitforGpioPinCommits
69dc97c1236czephyr: device: gpio: gate async GPIO on GPIO_ENABLE_DISABLE_INTERRUPT365f6c2bfa5bcmake: lint the zephyr crate with a clippy_zephyr targetThe target:
CMakeLists.txt#L240The CI step:
.github/workflows/build.yml#L92The gate:
zephyr/src/device/gpio.rs#L15Why:
zephyr-sysdefines the constant only under the option,zephyr-sys/wrapper.h#L110, which Zephyr marks experimental:drivers/gpio/Kconfig#L88Testing
west build -t clippy_zephyrpasses at this PR's head on native_sim/native/64 with the maximal config, and with onlyCONFIG_GPIO=yadded to hello_world. The second config fails without the gate commit.Review notes
rust-toolchain.toml. With-D warnings, new clippy releases can add CI failures. A pin would only cover builds whose working directory is under the module, since cargo looks the file up from the app's directory.GPIO_INT_DISABLEinstead ofGPIO_INT_MODE_DISABLE_ONLY, becausepollreconfigures the interrupt anyway. That would drop the experimental dependency, but needs hardware testing.