Skip to content

Tracking issue for target_feature 1.1 RFC #69098

Closed

Description

@nikomatsakis

View all comments

This is a tracking issue for the RFC "target_feature 1.1" (rust-lang/rfcs#2396).

Issues: F-target_feature_11 target feature 1.1 RFC

People

Last updated in Mar 2023:

  • Shepherd: gnzlbg @workingjubilee (person who can help answer tricky questions that arise during implementation)
  • Lang team liaison: @joshtriplett (main point of contact from lang team)

Step

Unresolved questions

Activity

  1. added
    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-langRelevant to the language team
    on Feb 12, 2020
  2. LeSeulArtichaut commented on Feb 18, 2020

    @LeSeulArtichaut
    Contributor

    I've been working on this, trying to see if I would be able to implement this with my very little knowledge of the compiler. I think I can propose a PR soon.

    @rustbot claim

  3. self-assigned this
    on Feb 18, 2020
  4. hanna-kruppe commented on May 2, 2020

    @hanna-kruppe
    Contributor

    In #69274 (comment), @petrochenkov pointed out a complication not made clear in the RFC (nor realized by anyone during the original discussion, AFAICT): safe trait functions are explicitly excluded because we can't check all call sites, but function items implement the Fn* traits, so safe functions with target features enabled face a similar problem. That is, unless they are special-cased in some way that results in them not implementing those traits.

  5. petrochenkov commented on May 2, 2020

    @petrochenkov
    Contributor

    It would probably be better to add the unsafe to #[target_feature] functions implicitly during lowering to HIR.
    Implicit unsafe is already added to functions in extern blocks in the same way.

    That would make the unsafety checker the only place (besides AST lowering) where they would be treated specially. Like, "yes, the function is unsafe, but we know that it's safe to call in this specific context, so the unsafe block can be omitted".

    The special coercion checks would no longer be necessary in that case.

  6. added a commit that references this issue on May 2, 2020
  7. added a commit that references this issue on May 2, 2020
  8. LeSeulArtichaut commented on May 3, 2020

    @LeSeulArtichaut
    Contributor

    Now that #69274 landed, I think we can check Implement the RFC 🙂

  9. LeSeulArtichaut commented on May 3, 2020

    @LeSeulArtichaut
    Contributor

    @rustbot release-assignment

  10. removed their assignment
    on May 3, 2020
  11. hanna-kruppe commented on May 8, 2020

    @hanna-kruppe
    Contributor

    Filed #72012 for the unsoundness discussed above (I think this is how T-lang tracking issues are supposed to be used now).

  12. nikomatsakis commented on Jun 22, 2020

    @nikomatsakis
    ContributorAuthor

    Opened #73631 to discuss the expected behavior of closures with target-feature.

  13. 44 remaining items

  14. calebzulawski commented on Nov 24, 2024

    @calebzulawski
    Member

    I've written some code which I think would trigger the future-compat lint you're proposing (obviously I can't try it out yet).

    This looks like it would trigger it. While not directly related to this topic, I see you are passing the closure via Fn--I've run into issues passing closures via Fn* traits in the past (#96929)

  15. briansmith commented on Nov 24, 2024

    @briansmith
  16. calebzulawski commented on Nov 24, 2024

    @calebzulawski
  17. RalfJung commented on Nov 25, 2024

    @RalfJung
    Member

    The idea that target_features inhibits inlining or that inlining inhibits target feature usage doesn't make sense.

    It's a work-around for an LLVM bug. In an ideal world we wouldn't have to worry about this.

    why we can't inline a function f() with target features into a function g() that doesn't have a superset of f() target features

    Strictly speaking this doesn't make sense either. LLVM "just" has to ensure that the operations from f are not hoisted out of any conditionals or loops in g. But LLVM isn't able to represent that, so instead it just stops inlining altogether. Which then puts us into a pickle regarding inline(always) (even ignoring the bug): the user requested to be always inlined, but we can't actually make that happen if the function has target features. What do we do?

    The status quo is that:

    • on regular functions, we just error on that combination
    • on a closure, then if TF 1.1 is turned on we'd usually inherit the surrounding function's target features into the closure, but if the closure is inline(always) then we don't inherit

    It's not pretty, but between that long-standing LLVM bug and the general LLVM limitation around inlining and target features, and given our backwards compatibility constraints, it is unclear how to do better.

    Compared to stable, with TF 1.1 nothing changes for the behavior of inline(always) functions or closures. What does change is the behavior of non-inline(always) closures in a target_feature function.

  18. added a commit that references this issue on Feb 11, 2025
  19. added 2 commits that reference this issue on Feb 13, 2025
  20. added a commit that references this issue on Feb 13, 2025
  21. added 2 commits that reference this issue on Mar 11, 2025
  22. SabrinaJewson commented on Sep 11, 2025

    @SabrinaJewson
    Contributor

    Should this issue be closed?

  23. folkertdev commented on Jul 1, 2026

    @folkertdev
    Contributor

    Probably, this has been stable since 1.86, the stabilization PR is #134090.

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.B-RFC-implementedBlocker: Approved by a merged RFC and implemented but not stabilized.B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-target_feature_11target feature 1.1 RFCS-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRT-langRelevant to the language team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions