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

Categorize and explain target features support #84004

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

mattico
Copy link
Contributor

@mattico mattico commented Apr 8, 2021

There are 3 different uses of the -C target-feature args passed to rustc:

  1. All of the features are passed to LLVM, which uses them to configure code-generation. This is sort-of stabilized since 1.0 though LLVM does change/add/remove target features regularly.
  2. Target features which are in the compiler's allowlist can be used in cfg!(target_feature) etc. These may have different names than in LLVM and are renamed before passing them to LLVM.
  3. Target features which are in the allowlist and which are stabilized or feature-gate-enabled can be used in #[target_feature].

It can be confusing that rustc --print target-features just prints out the LLVM features without separating out the rustc features or even mentioning that the dichotomy exists.

This improves the situation by separating out the rustc and LLVM target features and adding a brief explanation about the difference.

Abbreviated Example Output:

$ rustc --print target-features
Features supported by rustc for this target:
    adx                         - Support ADX instructions.
    aes                         - Enable AES instructions.
...
    xsaves                      - Support xsaves instructions.
    crt-static                  - Enables libraries with C Run-time Libraries(CRT) to be statically linked.

Code-generation features supported by LLVM for this target:
    16bit-mode                  - 16-bit mode (i8086).
    32bit-mode                  - 32-bit mode (80386).
...
    x87                         - Enable X87 float instructions.
    xop                         - Enable XOP instructions.

Use +feature to enable a feature, or -feature to disable it.
For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2

Code-generation features cannot be used in cfg or #[target_feature],
and may be renamed or removed in a future version of LLVM or rustc.

Motivated by #83975.
CC #49653

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 8, 2021
@rust-log-analyzer

This comment has been minimized.

@mattico mattico force-pushed the print-target-features-improvements branch from 63f0546 to 5e7cb7a Compare April 8, 2021 17:23
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

or even mentioning that the dichotomy exists

It's quite possible that such "dichotomy" is an unintentional result of different features being implemented at different time by different people not having a vision of the larger picture, then it's not surprising that's not documented.

@mattico mattico force-pushed the print-target-features-improvements branch from 5e7cb7a to f701247 Compare April 8, 2021 19:22
@petrochenkov
Copy link
Contributor

The main thing here is to avoid documenting more guarantees than it was previously documented.
The wording looks ok in this sense (and is otherwise an improvement).

@petrochenkov petrochenkov 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-review Status: Awaiting review from the assignee but also interested parties. labels Apr 8, 2021
@mattico mattico force-pushed the print-target-features-improvements branch from ca5ac3f to e1a4e2b Compare April 8, 2021 21:54
@rust-log-analyzer

This comment has been minimized.

@mattico mattico force-pushed the print-target-features-improvements branch from e1a4e2b to e4c3cfe Compare April 8, 2021 22:07
@petrochenkov
Copy link
Contributor

r=me with commits squashed.

@mattico mattico force-pushed the print-target-features-improvements branch from e4c3cfe to e258a5b Compare April 9, 2021 15:16
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 9, 2021

📌 Commit e258a5b has been approved by petrochenkov

@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 Apr 9, 2021
@bors
Copy link
Contributor

bors commented Apr 9, 2021

⌛ Testing commit e258a5b with merge dae9d6a...

@bors
Copy link
Contributor

bors commented Apr 9, 2021

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing dae9d6a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 9, 2021
@bors bors merged commit dae9d6a into rust-lang:master Apr 9, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 9, 2021
@mattico mattico deleted the print-target-features-improvements branch April 9, 2021 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants