Skip to content

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

Closed
@jbeich

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

cuviper

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
added
A-driverArea: rustc_driver that ties everything together into the `rustc` compiler
on Jan 27, 2019
petrochenkov

petrochenkov commented on May 9, 2020

@petrochenkov
Contributor

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

self-assigned this
on May 9, 2020
petrochenkov

petrochenkov commented on May 11, 2020

@petrochenkov
Contributor

Fixed in #72094.

removed their assignment
on May 12, 2020
added 2 commits that reference this issue on May 15, 2020

Rollup merge of rust-lang#72094 - petrochenkov:overfeature, r=nikic

7dc2c01

Rollup merge of rust-lang#72094 - petrochenkov:overfeature, r=nikic

4fe6d52

2 remaining items

Loading
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

      Participants

      @cuviper@jonas-schievink@petrochenkov@jbeich

      Issue actions

        -C target-feature=+foo overrides previous values · Issue #56527 · rust-lang/rust