- Notifications
You must be signed in to change notification settings - Fork81
Friendly non linux compilation error#80
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Friendly non linux compilation error#80
Uh oh!
There was an error while loading.Please reload this page.
Conversation
byte_conv is also unmaintained for 9 years and has an open bug aboutunsoundness.
This doesn't seem to require any code modifications
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.
Thanks for the PR! This should be helpful.
Unfortunately, there is a build error:
error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but the minimum supported Rust version of `socketcan v3.4.0-pre.0 (/home/fmp/projects/rust/embedded/socketcan)` is 1.70.Switch to the old `cargo:rerun-if-changed=build.rs` syntax (note the single colon).See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script for more information about build script outputs.
I think the string in the println should just have a single colon, ':'
"cargo:rerun-if-changed=build.rs"
Ok(val) if val == "linux" => Ok(()), | ||
_ => Err("Building for anything but Linux is not supported by socketcan".into()), | ||
} | ||
} |
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.
This works, but I usually force a compile error for an error message that's even more clear:
// build.rs#[cfg(not(target_os = "linux"))]compile_error!("socketcan can only be build for a Linux target");fn main() {}
which gives:
error: socketcan can only be build for a Linux target --> build.rs:4:1 |4 | compile_error!("socketcan can only be build for a Linux target"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^error: could not compile `buildtgt` (build script) due to 1 previous error
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.
This does not work for cross compiles, as far as I know. Inside a build script, you cannot rely on #[cfg] for target_os but have to use the cargo environment variable. The reason is that the build script is built for the architecture that you're running the build on because it gets executed there.
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.
Oh, yeah, I think you're right. This keeps tripping me up.
This avoids confusing errors about missing symbols etc.fix
897e549
toeb55dab
CompareSorry for the MSRV violation and thanks for catching it. I added a fix. With regards to the |
I tried to make it a bit friendlier for someone accidentally building on non-linux by adding a build script to check and only including neli for linux. Also this removes an unused and very outdated dependency as well as updating thiserror to version 2, which has permeated through the ecosystem quite a bit