-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Target-feature documented as unsafe #64145
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Hey @nikic or @rkruppe -- any comments on the text to be added to the rustc-guide? It looks like it was largely cribbed from @rkruppe's comment here, which seems like a good source. Thanks @togiberlin for pulling this together! |
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 taking a stab at this! I have some suggestions and one correction.
aa92e72
to
54aadaf
Compare
Hello @rkruppe , Could you please check it again? |
# Known Issues | ||
This section informs you about known "gotchas". Keep in mind, that this section is (and always will be) incomplete. For suggestions and amendments, feel free to [contribute](https://doc.rust-lang.org/rustc/contributing.html) to this guide. | ||
|
||
## Target Features |
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.
Why isn't this in the target_feature
section? (i.e. why do we need a new section for 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.
As far as I understood, there are waay more issues, which are not documented yet.
Niko asked me to create a dedicated page, where all issues are listed.
The benefit is, that this vital info is not scattered/fragmented across many pages.
I am always open to suggestions :)
|
||
By default, compiling your code with the `-C target-feature` flag will not recompile the entire standard library and/or imported crates with matching target features. Therefore, target features are generally considered as unsafe. Using `#[target_feature]` on individual functions makes the function unsafe. | ||
|
||
Examples: |
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'm not sure how useful this would be. I don't think it is practical for us to document all features on all architectures that could cause problems when combined in different ways, and would very much prefer a solution to the problem that does not rely on documentation.
Right now Rust does not know much about how target-features interact with call ABI. It probably should.
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.
You're invited to wish for a better solution but we're not even generating shims for the more specific sub-problem of vector values and we've been suffering from that problem for the several years. Documenting that it is de facto unsafe now and underlining that with some scary examples is a good step forward. I agree that an exhaustive list is not practical but that's not necessary.
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.
@eddyb a quick workaround for this form of UB would be to pass f32
and f64
by memory in the Rust ABI, just like we do for Vector types.
This would be a temporary solution, until we can either diagnose these issues or generate appropriate shims. It might be horrible for performance of numeric code, I don't know.
Sorry for taking a while to get back to this, @togiberlin! It seems to be all correct now and largely in good shape. There's some minor editorial suggestions I could make but it seems like @gnzlbg is already on that. |
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'm not sure it is a good idea to split all the knowledge required to use target-feature correctly across multiple documents, but I suppose we can copy paste what gets documented here into a central document and try to keep those in sync.
536e650
to
a0c56cb
Compare
Ping from triage, any updates? @GuillaumeGomez |
Pinging again from triage. This PR has sat idle for the last 10 days. |
This is what happens when nobody feels personally responsible as the reviewer 😓 I'm going to go ahead and say this is ready now. There's much more that could be written about the topic but this is good as it is. Thank you for your work and patience, @togiberlin! @bors r+ |
📌 Commit a0c56cb09c2d71613426244fbd1c26a891dfd654 has been approved by |
Sorry, I'd like the links fixed before merging. @bors r- |
That's fair! I had assumed we have linkcheck for the book too, but apparently not? |
http/https links are not validated, since they are somewhat unreliable in CI. |
r? @ehuss |
Ping from Triage: Any updates @togiberlin @ehuss? |
@bors r+ |
📌 Commit 4f400b13b0bb4640ff66f2e9085db8581dee4ae0 has been approved by |
4f400b1
to
56141b0
Compare
56141b0
to
de3fd02
Compare
@ehuss Thanks for your help. I accepted your changes and squashed/rebased commits. |
@bors r+ rollup |
📌 Commit de3fd02 has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
…doc, r=ehuss Target-feature documented as unsafe @nikomatsakis asked me to help out on the docs on this issue: rust-lang#63597 The following docs have been modified - ```rustc -C help``` text for `target-feature` - RustC book: ## Preview of src/doc/rustc/src/targets/index.md ![Screenshot 2019-09-17 at 12 22 45](https://user-images.githubusercontent.com/13764830/65033746-f7826700-d945-11e9-9dd2-d8f9b08f45de.png) ## Preview of src/doc/rustc/src/targets/known-issues.md ![Screenshot 2019-09-17 at 12 22 25](https://user-images.githubusercontent.com/13764830/65033774-00733880-d946-11e9-9398-90f01f3938d5.png) Fixes rust-lang#63597
Rollup of 14 pull requests Successful merges: - #64145 (Target-feature documented as unsafe) - #65007 (Mention keyword closing policy) - #65417 (Add more coherence tests) - #65507 (Fix test style in unused parentheses lint test) - #65591 (Add long error explanation for E0588) - #65617 (Fix WASI sleep impl) - #65656 (Add option to disable keyboard shortcuts in docs) - #65678 (Add long error explanation for E0728) - #65681 (Code cleanups following up on #65576.) - #65686 (refactor and move `maybe_append` ) - #65688 (Add some tests for fixed ICEs) - #65689 (bring back some Debug instances for Miri) - #65695 (self-profiling: Remove module names from some event-ids in codegen backend.) - #65706 (Add missing space in librustdoc) Failed merges: r? @ghost
☔ The latest upstream changes (presumably #65716) made this pull request unmergeable. Please resolve the merge conflicts. |
@nikomatsakis asked me to help out on the docs on this issue: #63597
The following docs have been modified
rustc -C help
text fortarget-feature
Preview of src/doc/rustc/src/targets/index.md
Preview of src/doc/rustc/src/targets/known-issues.md
Fixes #63597