Skip to content

-C target-feature=+foo overrides previous values #56527

Closed

Description

@jbeich

I'm trying to pass multiple -C target-feature conditionally downstream. However, despite +/- for adding/removing a feature it appears only the last value takes effect.

$ cat >a.rs
fn main() {
    if cfg!(target_feature="avx2") {
        println!("AVX2 available");
    }
    if cfg!(target_feature="fma") {
        println!("FMA available");
    }
}

$ rustc a.rs -C target-feature=+avx2 -C target-feature=+fma
$ ./a
FMA available
$ rustc a.rs -C target-feature=+avx2,+fma
$ ./a
AVX2 available
FMA available

Activity

  1. cuviper commented on Dec 7, 2018

    @cuviper
    Member

    FWIW, you can check for cfg values without any test program like:

    $ rustc --print cfg  -C target-feature=+avx2 -C target-feature=+fma
    
    $ rustc --print cfg  -C target-feature=+avx2,+fma
    
  2. added
    A-driverArea: rustc_driver that ties everything together into the `rustc` compiler
    on Jan 27, 2019
  3. petrochenkov commented on May 9, 2020

    @petrochenkov
    Contributor

    I agree that it's a bug and will try to fix it.

  4. self-assigned this
    on May 9, 2020
  5. petrochenkov commented on May 11, 2020

    @petrochenkov
    Contributor

    Fixed in #72094.

  6. removed their assignment
    on May 12, 2020
  7. added 2 commits that reference this issue on May 15, 2020
  8. added a commit that references this issue on Apr 1, 2021
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

    A-driverArea: rustc_driver that ties everything together into the `rustc` compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions