Skip to content

Should -Ctarget-feature go straight to LLVM? #49653

Open
@hanna-kruppe

Description

@hanna-kruppe

The --print target-features and -C target-feature options list/accept all target features LLVM knows, under the names LLVM gives them (see discussion in #49428). This is in contrast to #[target_feature] and cfg(target_feature), which accept only explicitly whitelisted features, and in some cases change the LLVM names (e.g., bmi1 instead of bmi). This is inconsistent, and also makes the command line interface less stable than it could be.

As @gnzlbg noted in #49428, this difference has existed for a while. However, in effect the command line options don't have a real stability guarantee: rustcs not built with our LLVM fork don't currently recognize any target features, and the LLVM names can change under our feet (this was part of the rationale for having a whitelist in rustc). Note that -C flags "without stability guarantee" are not without precedent, e.g., consider -C passes (which also depends on LLVM internals).

So I believe we're within our rights to change this. Especially now that the whitelist is much more complete. And it has real advantages: consistency between command line and attributes/cfgs, more stability for the command line switch, and making it work on rustcs with system LLVMs, thanks to @cuviper's work in #49428.

cc @japaric are you aware of uses of this option that aren't covered by the current whitelists?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-stabilityArea: `#[stable]`, `#[unstable]` etc.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions