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

warn when using an unstable feature with -Ctarget-feature #117616

Merged
merged 2 commits into from Nov 7, 2023

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Nov 5, 2023

Setting or unsetting the wrong target features can cause ABI incompatibility (#116344, #116558). We need to carefully audit features for their ABI impact before stabilization. I just learned that we currently accept arbitrary unstable features on stable and if they are in the list of Rust target features, even unstable, then we don't even warn about that!1 That doesn't seem great, so I propose we introduce a warning here.

This has an obvious loophole via -Ctarget-cpu. I'm not sure how to best deal with that, but it seems better to fix what we can and think about the other cases later, maybe once we have a better idea for how to resolve the general mess that are ABI-affecting target features.

@rustbot
Copy link
Collaborator

rustbot commented Nov 5, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 5, 2023
@rust-log-analyzer

This comment has been minimized.

@@ -76,8 +76,8 @@ codegen_llvm_target_machine = could not create LLVM TargetMachine for triple: {$
codegen_llvm_target_machine_with_llvm_err = could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}

codegen_llvm_unknown_ctarget_feature =
unknown feature specified for `-Ctarget-feature`: `{$feature}`
.note = it is still passed through to the codegen backend
unknown and unstable feature specified for `-Ctarget-feature`: `{$feature}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"and"? or "or"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"and"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I don't totally understand how something can both be unknown and unstable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's unknown it's clearly not stable, and hence it is unstable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does that need clarification? Like, if it's clearly not stable by virtue of being uknown, why are we saying it's unknown and unstable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth emphasizing that unknown implies unstable. Unstable has a particular meaning in the Rust context, and that implication is very clear to us, but might not be clear at all to users.

It is extremely unusual that we allow unstable things to even be done on stable Rust, making it even more important to point this out explicitly.

@compiler-errors
Copy link
Member

@bors r+

idk if you intended this to go through an FCP, but it's a warning, and I think the warning is well-justified, so I see no reason for that. you can r- if you disagree, and I can start one.

@bors
Copy link
Contributor

bors commented Nov 7, 2023

📌 Commit b85c683 has been approved by compiler-errors

It is now in the queue for this repository.

@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 Nov 7, 2023
@bors
Copy link
Contributor

bors commented Nov 7, 2023

⌛ Testing commit b85c683 with merge 43786cf...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 7, 2023
…=compiler-errors

warn when using an unstable feature with -Ctarget-feature

Setting or unsetting the wrong target features can cause ABI incompatibility (rust-lang#116344, rust-lang#116558). We need to carefully audit features for their ABI impact before stabilization. I just learned that we currently accept arbitrary unstable features on stable and if they are in the list of Rust target features, even unstable, then we don't even warn about that!1 That doesn't seem great, so I propose we introduce a warning here.

This has an obvious loophole via `-Ctarget-cpu`. I'm not sure how to best deal with that, but it seems better to fix what we can and think about the other cases later, maybe once we have a better idea for how to resolve the general mess that are ABI-affecting target features.
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 7, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 7, 2023
@RalfJung
Copy link
Member Author

RalfJung commented Nov 7, 2023

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Nov 7, 2023

📌 Commit 84abf83 has been approved by compiler-errors

It is now in the queue for this repository.

@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 Nov 7, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 7, 2023
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#115485 (Format macro const literals with pretty printer)
 - rust-lang#117616 (warn when using an unstable feature with -Ctarget-feature)
 - rust-lang#117639 (Update books)
 - rust-lang#117675 (llvm-wrapper: Remove include of non-existant Vectorize.h)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f8c6770 into rust-lang:master Nov 7, 2023
11 checks passed
@rustbot rustbot added this to the 1.75.0 milestone Nov 7, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 7, 2023
Rollup merge of rust-lang#117616 - RalfJung:unstable-target-features, r=compiler-errors

warn when using an unstable feature with -Ctarget-feature

Setting or unsetting the wrong target features can cause ABI incompatibility (rust-lang#116344, rust-lang#116558). We need to carefully audit features for their ABI impact before stabilization. I just learned that we currently accept arbitrary unstable features on stable and if they are in the list of Rust target features, even unstable, then we don't even warn about that!1 That doesn't seem great, so I propose we introduce a warning here.

This has an obvious loophole via `-Ctarget-cpu`. I'm not sure how to best deal with that, but it seems better to fix what we can and think about the other cases later, maybe once we have a better idea for how to resolve the general mess that are ABI-affecting target features.
@RalfJung RalfJung deleted the unstable-target-features branch November 11, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants