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

Target-feature documented as unsafe #64145

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

togiberlin
Copy link
Contributor

@togiberlin togiberlin commented Sep 4, 2019

@nikomatsakis asked me to help out on the docs on this issue: #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

Preview of src/doc/rustc/src/targets/known-issues.md

Screenshot 2019-09-17 at 12 22 25

Fixes #63597

@rust-highfive
Copy link
Collaborator

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2019
@nikomatsakis
Copy link
Contributor

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!

Copy link
Contributor

@hanna-kruppe hanna-kruppe left a 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.

src/doc/rustc/src/targets/index.md Outdated Show resolved Hide resolved
src/doc/rustc/src/targets/known-issues.md Outdated Show resolved Hide resolved
src/doc/rustc/src/targets/known-issues.md Outdated Show resolved Hide resolved
@togiberlin togiberlin force-pushed the feature/target-features-doc branch 2 times, most recently from aa92e72 to 54aadaf Compare September 8, 2019 19:00
@togiberlin
Copy link
Contributor Author

Hello @rkruppe ,
thx for your detailed feedback :)
I rewrote some parts of my text.

Could you please check it again?
Thanks!

src/doc/rustc/src/codegen-options/index.md Outdated Show resolved Hide resolved
src/doc/rustc/src/command-line-arguments.md Outdated Show resolved Hide resolved
# 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
Copy link
Contributor

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?).

Copy link
Contributor Author

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 :)

src/librustc/session/config.rs Outdated Show resolved Hide resolved

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:
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

@gnzlbg gnzlbg Sep 17, 2019

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.

@hanna-kruppe
Copy link
Contributor

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.

Copy link
Contributor

@gnzlbg gnzlbg left a 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.

@togiberlin togiberlin force-pushed the feature/target-features-doc branch 2 times, most recently from 536e650 to a0c56cb Compare September 17, 2019 10:20
@togiberlin
Copy link
Contributor Author

togiberlin commented Sep 17, 2019

@gnzlbg @rkruppe Thank you very much for your helpful input! :)
Do you think this PR is ready?

@Alexendoo
Copy link
Member

Ping from triage, any updates? @GuillaumeGomez

@JohnCSimon
Copy link
Member

Pinging again from triage. This PR has sat idle for the last 10 days.
@GuillaumeGomez Can you provide an update?

@gnzlbg @rkruppe
Thanks!

@hanna-kruppe
Copy link
Contributor

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+

@bors
Copy link
Contributor

bors commented Oct 5, 2019

📌 Commit a0c56cb09c2d71613426244fbd1c26a891dfd654 has been approved by rkruppe

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2019
src/doc/rustc/src/codegen-options/index.md Outdated Show resolved Hide resolved
src/doc/rustc/src/command-line-arguments.md Outdated Show resolved Hide resolved
src/doc/rustc/src/targets/index.md Outdated Show resolved Hide resolved
src/doc/rustc/src/targets/known-issues.md Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Oct 5, 2019

Sorry, I'd like the links fixed before merging.

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 5, 2019
@hanna-kruppe
Copy link
Contributor

That's fair! I had assumed we have linkcheck for the book too, but apparently not?

@ehuss
Copy link
Contributor

ehuss commented Oct 5, 2019

http/https links are not validated, since they are somewhat unreliable in CI.

@Centril
Copy link
Contributor

Centril commented Oct 10, 2019

r? @ehuss

@joelpalmer
Copy link

Ping from Triage: Any updates @togiberlin @ehuss?

@hanna-kruppe
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 22, 2019

📌 Commit 4f400b13b0bb4640ff66f2e9085db8581dee4ae0 has been approved by rkruppe

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 22, 2019
@togiberlin
Copy link
Contributor Author

@ehuss Thanks for your help. I accepted your changes and squashed/rebased commits.
It should be ready now.

@ehuss
Copy link
Contributor

ehuss commented Oct 22, 2019

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 22, 2019

📌 Commit de3fd02 has been approved by ehuss

@bors
Copy link
Contributor

bors commented Oct 22, 2019

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Oct 23, 2019
…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
bors added a commit that referenced this pull request Oct 23, 2019
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
@bors bors merged commit de3fd02 into rust-lang:master Oct 23, 2019
@bors
Copy link
Contributor

bors commented Oct 23, 2019

☔ The latest upstream changes (presumably #65716) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

document that target features are unsafe