-
Notifications
You must be signed in to change notification settings - Fork 193
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
Allow for manual opt-out of CAS features #120
Conversation
Thanks for the PR and sorry it took me so long to get to it. Ideally, I would like to use the output of $ rustc --print cfg thumbv6m-none-eabi
debug_assertions
target_arch="arm"
target_endian="little"
target_env=""
target_feature="mclass"
target_feature="v5te"
target_feature="v6"
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_os="none"
target_pointer_width="32"
target_vendor=""
$ rustc --print cfg --target thumbv7m-none-eabi
debug_assertions
target_arch="arm"
target_endian="little"
target_env=""
target_feature="mclass"
target_feature="v5te"
target_feature="v6"
target_feature="v6k"
target_feature="v6t2"
target_feature="v7"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_os="none"
target_pointer_width="32"
target_vendor=""
$ cargo +beta --print cfg --target thumbv7m-none-eabi
debug_assertions
target_arch="arm"
target_endian="little"
target_env=""
target_os="none"
target_pointer_width="32"
target_vendor="" As that can't be used, using Cargo features is the next best option. However, Cargo features must be additive (*); meaning that instead of an opt-in (*) To see what can go wrong with |
I've inverted the logic here, and tried to add some helpful diagnostics:
|
@@ -154,7 +154,6 @@ | |||
//! | |||
//! [1]: https://static.docs.arm.com/ddi0403/eb/DDI0403E_B_armv7m_arm.pdf | |||
|
|||
#[cfg(not(armv6m))] |
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.
Note: This is okay to remove, as the entire pool module is removed when the cas
feature is not set, and it is not possible to set the cas
feature with armv6m targets.
In this PR, by inverting the features here, I believe this is now a breaking change, as any users who were intentionally or unintentionally setting With the |
You are correct. This is in principle a breaking change. However, the crate currently has zero default features so the number of people using Thanks! bors r+ |
120: Allow for manual opt-out of CAS features r=japaric a=jamesmunns I've been working on a bare metal platform lately that does not have CAS (specifically ARMv4 bare metal), and this is not caught by the CPU detection logic in the build.rs. This PR adds a flag that allows for manual specification to avoid CAS features. Co-authored-by: James Munns <[email protected]>
Build failed |
pub mod mpmc; | ||
#[cfg(not(armv6m))] |
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.
Right, so we actually need to keep this not
as: cfg(all(not(armv6m), feature = "cas"))
to keep cargo build --target thumbv6m-none-eabi
working.
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 that the interface you would like (implicitly masking the features), rather than forcing the user to opt-out with no-default-features
?
I mentioned this in this comment.
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.
To get this PR into a new patch version we need to keep cargo build --target thumbv6m-none-eabi
(note: "cas" is implicitly enabled) working so the logic needs to make the "cas" feature a no-op on that target.
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.
Happy to make the change, though I might suggest that we change the "implicit no-op" behavior on the next breaking (minor) release.
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.
And probably make "cas" opt-in as well; I don't like having a crate that by default doesn't build for all targets. Could you make an issue to make sure we don't forget? I'll put on the v0.6.0 milestone.
src/lib.rs
Outdated
pub mod pool; | ||
pub mod spsc; | ||
|
||
#[cfg(all(armv6m, feature = "cas"))] | ||
core::compile_error!("The 'cas' feature may not be used with `armv6m` targets."); |
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.
And we have to drop this
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.
Basically, the state of the "cas" feature should have no effect on ARMv6-M.
@japaric back to you. |
Thanks! bors r+ |
120: Allow for manual opt-out of CAS features r=japaric a=jamesmunns I've been working on a bare metal platform lately that does not have CAS (specifically ARMv4 bare metal), and this is not caught by the CPU detection logic in the build.rs. This PR adds a flag that allows for manual specification to avoid CAS features. Co-authored-by: James Munns <[email protected]>
Build failed |
@japaric I missed you added a feature at the end of the file in my merge. This should work now. |
bors r+ |
120: Allow for manual opt-out of CAS features r=japaric a=jamesmunns I've been working on a bare metal platform lately that does not have CAS (specifically ARMv4 bare metal), and this is not caught by the CPU detection logic in the build.rs. This PR adds a flag that allows for manual specification to avoid CAS features. Co-authored-by: James Munns <[email protected]>
Build succeeded |
I've been working on a bare metal platform lately that does not have CAS (specifically ARMv4 bare metal), and this is not caught by the CPU detection logic in the build.rs. This PR adds a flag that allows for manual specification to avoid CAS features.