Skip to content

Tracking issue for turning unstable / incorrect -Ctarget-feature into a hard error #162235

Description

@RalfJung

When -Ctarget-feature was introduced, we allowed passing arbitrary LLVM target features. This turned out to be a mistake:

  • Some target features alter the ABI, so using them in -C flags is unsound as different crates with different values for those flags may be linked together.
  • LLVM can rename / remove target features, which is in conflict with our stability policy.

For #[target_feature] and cfg(target_feature), we were a lot more careful, and we only allow/expose explicitly stabilized target features. This issue is tracking our move towards doing the same with -Ctarget-feature. This means it will become a hard error to:

  • Use a target feature that we don't know at all.
  • Use a target feature that we know but is unstable.
  • Use a target feature that we know but is marked as "internal-only", i.e. it is not meant to be stabilized and just tracked for internal compiler purposes. This is usually done because the target feature alters the ABI or because LLVM chose to expose something as a target feature that rustc exposed via other knobs.
  • Use a target feature that we know and that is stable, but that would alter the ABI of the current target.

The intended immediate replacement for all of these is -Zllvm-target-feature. This is a target modifier, so we ensure that there are no ABI differences across crates that are being linked together. However, that also means it depends on -Zbuild-std to avoid ABI differences with the pre-built standard library. This means we will likely wait for both of those to stabilize before we turn this warning into a hard error.

The other possible replacement, at least for target features that actually are harmless on the ABI side, is to stabilize the relevant target features. If you cannot use nightly for some reason, this is the best way forward for you. Please let us know which target features are causing this FCW, and ideally help us stabilize them. :)

Activity

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-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions