Skip to content

rustc --print cfg prints features that are invalid for -Ctarget-feature #81881

@djc

Description

@djc
Contributor

I have been investigating how to optimize my binaries for the least common denominator across a number of different CPU types (that is, something between the default CPU and target-cpu=native). In the linked thread, someone pointed me at rustc --print cfg and I found some relevant documentation in the SIMD docs. However, I found that the output of rustc --target x86_64-unknown-linux-gnu --print target-features and rustc --print cfg --target x86_64-unknown-linux-gnu are inconsistent, and the latter outputs features that don't actually work with -Ctarget-feature. So far, the ones that I noticed are:

  • bmi (target-feature) vs bmi1 (cfg)
  • pclmul vs pclmulqdq
  • rdrnd vs rdrand

Should the --print cfg command be updated to print output that's consistent with the target-feature list?

djc-2019 cpu-features rust $ rustc -vV                                                      
rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-apple-darwin
release: 1.49.0

Activity

added
C-bugCategory: This is a bug.
on Feb 8, 2021
nagisa

nagisa commented on Jul 23, 2021

@nagisa
Member

-Ctarget-feature accepts rust feature names as of #84991

djc

djc commented on Jul 25, 2021

@djc
ContributorAuthor

@nagisa the other part of this issue is getting --print target-features aligned with --print cfg, which as far as I can tell is not affected by #84991. Should we keep this issue open until that part is addressed as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @djc@nagisa

        Issue actions

          rustc --print cfg prints features that are invalid for `-Ctarget-feature` · Issue #81881 · rust-lang/rust