Skip to content

rustc silently ignores invalid -C target-feature names #44815

Open

Description

@johnthagen

Compiling a simple Hello, World program:

$ rustc -V
rustc 1.20.0 (f3d6973f4 2017-08-27)

# Note the trailing "zzzz"
$ RUSTFLAGS=-Ctarget-feature=+crt-staticzzzz cargo build -v
   Compiling rust-test v0.1.0 (rust-test)
     Running `rustc --crate-name rust_test src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=aafe1708c049ad76 -C extra-filename=-aafe1708c049ad76 --out-dir rust-test/target/debug/deps -L dependency=rust-test/target/debug/deps '-Ctarget-feature=+crt-staticzzzz'`
    Finished dev [unoptimized + debuginfo] target(s) in 0.25 secs

Should RUSTFLAGS=-Ctarget-feature=+crt-staticzzzz be silently accepted?

If I pass RUSTFLAGS=-Ctarget-feature=+batman, a warning is printed, as expected.

'+batman' is not a recognized feature for this target (ignoring feature)

Why is trailing misspelling silently allowed?

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Sep 26, 2017
  2. zackmdavis commented on Oct 2, 2017

    @zackmdavis
    Contributor

    This is happening inside LLVM and plausibly should be filed with that project.

  3. hanna-kruppe commented on Oct 2, 2017

    @hanna-kruppe
    Contributor

    crt-static is not passed to LLVM (and shouldn't be). It seems as if rustc consumes not just crt-static but also other target features that have it as a prefix? This filtering looks suspicious:

    let llvm_features = requested_features.filter(|f| {
    !rustc_features.iter().any(|s| f.contains(s))
    });

  4. petrochenkov commented on May 10, 2020

    @petrochenkov
    Contributor

    Also rustc:

  5. self-assigned this
    on May 10, 2020
  6. added 2 commits that reference this issue on May 15, 2020
  7. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 11, 2020
  8. removed their assignment
    on Jan 27, 2022
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-diagnosticsArea: Messages for errors, warnings, and lintsA-target-featureArea: Enabling/disabling target features like AVX, Neon, 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