Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Sep 19, 2023

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

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
@joshlf joshlf marked this pull request as draft September 19, 2023 23:55
Comment on lines +224 to +230
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"#
);
Copy link
Collaborator

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:

Suggested change
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
};

Copy link
Collaborator

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:

Suggested change
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"#
);

Copy link
Collaborator

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:

Suggested change
#[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"#
);

@joshlf
Copy link
Member Author

joshlf commented Sep 23, 2023

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.

@joshlf joshlf closed this Sep 23, 2023
@joshlf joshlf deleted the target-arch branch October 24, 2023 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants