-
Notifications
You must be signed in to change notification settings - Fork 162
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
riscv: build: make cfg
variables more robust
#205
Conversation
Change which Cargo `CFG` environment variables are used to select the custom `cfg` variables. See rust-embedded#204 (comment) for discussion.
I don't know why the cargo clippy --package riscv-rt --all --features=s-mode -- -D warnings The checks pass. 🤔 |
In nightly, clippy now complains about "custom" compiler features (check this). So, as suggested by the CI, now we should add to println!("cargo::rustc-check-cfg=cfg(riscv)");
println!("cargo::rustc-check-cfg=cfg(riscv32)");
println!("cargo::rustc-check-cfg=cfg(riscv64)"); |
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.
Looks good to me! However, we still need to address new clippy requirements
Build checks on Without an MSRV bump, the cargo +nightly clippy --all --no-default-features --target riscv64imac-unknown-none-elf -- -D warnings
Compiling riscv v0.11.1 (/riscv/riscv)
Compiling riscv-rt v0.13.0 (/riscv/riscv-rt)
error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but the minimum supported Rust version of `riscv v0.11.1 (/riscv/riscv)` is 1.60.
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script for more information about build script outputs. |
riscv/build.rs
Outdated
@@ -1,12 +1,16 @@ | |||
use std::env; | |||
|
|||
fn main() { | |||
let target = env::var("TARGET").unwrap(); | |||
println!("cargo::rustc-check-cfg=cfg(riscv)"); | |||
println!("cargo::rustc-check-cfg=cfg(riscv32)"); |
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.
We might want to move these checks (riscv32
+ riscv64
) into their respective conditional branches.
All the checks pass, so I'm not 100% on how these checks are supposed to work.
Edit: I guess it works because of this line from the docs:
Note that all possible cfgs should be defined, regardless of which cfgs are currently enabled. This includes all possible values of a given cfg name.
Which probably means I should change the checks in riscv-rt
and riscv-semihosting
.
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.
with cargo:rustc-check-cfg
you just inform cargo that you might have a custom cfg
item.
I don't like the idea of bumping MSRV from 1.60 to 1.77 due to a nightly clippy issue... I looked at the line provided by your post and:
I suggest using just |
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.
Let's see if we can get rid of bumping the MSRV
Uses new lint checks for `cfg` variables.
Uses new lint checks for `cfg` variables.
Uses new lint checks for `cfg` variables.
I didn't like it either. Looks like the single colon fixed the warning/error. Weird that the compiler would suggest the non-MSRV compatible fix... Probably pretty involved for it to do otherwise. Either way, the CI looks like it's fixed now. Thank you for the suggestion @romancardenas. |
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.
LGTM
Change which Cargo
CFG
environment variables are used to select the customcfg
variables.See #204 (comment) for discussion.