-
Notifications
You must be signed in to change notification settings - Fork 105
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
Fail compilation on targets w/o soundness proof #404
Conversation
TODO: Figure out how to make sure we block the next minor version release on adding back all of the targets that people actually rely on. Makes progress on #383
compile_error!( | ||
r#"Zerocopy has not been proven sound on this architecture. | ||
|
||
This doesn't mean that it is unsound - just that we haven't gotten around to | ||
proving it sound. If you need support for this architecture, let us know and | ||
we'll prioritize it: https://github.com/google/zerocopy/issues/383"# | ||
); |
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.
Re. this:
TODO: Figure out how to make sure we block the next minor version release on adding back all of the targets that people actually rely on.
We could potentially take the initial, weaker step of merely warning on unproven architectures:
compile_error!( | |
r#"Zerocopy has not been proven sound on this architecture. | |
This doesn't mean that it is unsound - just that we haven't gotten around to | |
proving it sound. If you need support for this architecture, let us know and | |
we'll prioritize it: https://github.com/google/zerocopy/issues/383"# | |
); | |
const _: () = { | |
#[deprecated = r#"Zerocopy has not been proven sound on this architecture. | |
This doesn't mean that it is unsound - just that we haven't gotten around to | |
proving it sound. If you need support for this architecture, let us know and | |
we'll prioritize it: https://github.com/google/zerocopy/issues/383"#] | |
const _WARNING: () = (); | |
#[warn(deprecated)] | |
_WARNING | |
}; |
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 think there's almost certainly merit in providing an escape hatch for weird architectures, too:
compile_error!( | |
r#"Zerocopy has not been proven sound on this architecture. | |
This doesn't mean that it is unsound - just that we haven't gotten around to | |
proving it sound. If you need support for this architecture, let us know and | |
we'll prioritize it: https://github.com/google/zerocopy/issues/383"# | |
); | |
#[cfg(not(ZEROCOPY_ALLOW_EXPERIMENTAL_ARCH))] | |
compile_error!( | |
r#"Zerocopy has not been proven sound on this architecture. | |
This doesn't mean that it is unsound - just that we haven't gotten around to | |
proving it sound. If you need support for this architecture, let us know and | |
we'll prioritize it: https://github.com/google/zerocopy/issues/383 | |
You can temporarily enable this architecture by setting: | |
export RUSTFLAGS="--cfg ZEROCOPY_ALLOW_EXPERIMENTAL_ARCH" | |
"# | |
); | |
#[cfg(ZEROCOPY_ALLOW_EXPERIMENTAL_ARCH)] | |
const _: () = { | |
#[deprecated = r#"If you need support for this architecture, let us know and | |
we'll prioritize it: https://github.com/google/zerocopy/issues/383"#] | |
const _WARNING: () = (); | |
#[warn(deprecated)] | |
_WARNING | |
}; |
proving it sound. If you need support for this architecture, let us know and | ||
we'll prioritize it: https://github.com/google/zerocopy/issues/383"# | ||
); | ||
|
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.
When an architecture is expressly unsupported, we should report asmuch:
#[cfg(target_arch = "spirv")] | |
compile_error!( | |
r#"Zerocopy is not sound on this architecture. SPIRV's memory model | |
prohibits freely reinterpreting memory. If you believe this limitation is | |
incorrect, let us know: https://github.com/google/zerocopy/issues/383"# | |
); | |
Given the discussion in rust-lang/unsafe-code-guidelines#461, I'm going to close this on the assumption that we'll adopt a policy of not reasoning about target architecture. We can always re-open if that's not how it plays out. |
TODO: Figure out how to make sure we block the next minor version release on adding back all of the targets that people actually rely on.
Makes progress on #383