Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for RFC 2045: improving #[target_feature] #44839

Open
8 of 22 tasks
alexcrichton opened this issue Sep 25, 2017 · 46 comments
Open
8 of 22 tasks

Tracking issue for RFC 2045: improving #[target_feature] #44839

alexcrichton opened this issue Sep 25, 2017 · 46 comments
Labels
A-SIMD Area: SIMD (Single Instruction Multiple Data) A-stability Area: `#[stable]`, `#[unstable]` etc. A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. Libs-Tracked Libs issues that are tracked on the team's project board. S-tracking-design-concerns Status: There are blocking ❌ design concerns. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@alexcrichton
Copy link
Member

alexcrichton commented Sep 25, 2017

This is a tracking issue for the #[target_feature] segment of RFC 2045 (rust-lang/rfcs#2045).
#[cfg(target_feature)] was tracked in #29717 and has since been stabilized.

Steps

@gnzlbg have anything else you want filled out here?

(below added from comments on PR)

  • consensus on the API for run-time feature detection
  • should cfg!(feature) work across #[inline(always)] functions, generics, etc?

And some related tasks:

@alexcrichton alexcrichton added B-unstable Blocker: Implemented in the nightly compiler and unstable. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Sep 25, 2017
@alexcrichton alexcrichton added the A-SIMD Area: SIMD (Single Instruction Multiple Data) label Sep 25, 2017
@gnzlbg
Copy link
Contributor

gnzlbg commented Sep 26, 2017

@alexchrichton

Yes, we should also clear some of the unresolved questions:

  • consensus on the API for run-time feature detection
  • should cfg!(feature) work across #[inline(always)] functions, generics, etc?

And some related tasks:

It would be nice if those API breaking changes could be prioritized.

@retep998
Copy link
Member

Rust already will sometimes not inline a #[inline(always)] function (notably recursive situations), so unsafe code already can't assume that #[inline(always)] code will always be inlined.

@gnzlbg
Copy link
Contributor

gnzlbg commented Sep 26, 2017

@retep998 cfg!(feature) does not require any unsafe code.

@retep998
Copy link
Member

@gnzlbg I meant in regards to where the RFC states that #[target_feature] and #[inline(always)] mixed together should result in an error. We can simply not inline functions in that case, even if they are marked as #[inline(always)], because Rust will already sometimes not inline functions marked #[inline(always)].

@gnzlbg
Copy link
Contributor

gnzlbg commented Sep 26, 2017

@retep998 We could definitely relax this by just not inlining an #[inline(always)] function. I don't know if we want to do so: the user did not write inline, but inline(always), we should at least warn here.

What we cannot currently do is inlining a function across mismatching features (independently of its inlining annotations). The alternative sections of the RFC explores this a bit though.

@TimNN TimNN added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Sep 27, 2017
@newpavlov
Copy link
Contributor

Any news on implementation status of --enable-features="feature0,feature1,..." proposed in the RFC?

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 4, 2018

@newpavlov this is being discussed in issue 49658 . (note from pnkfelix: did this mean to say #49653 ?)

@alexcrichton
Copy link
Member Author

#48556 has entered FCP which I believe will implicitly stabilize this attribute

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 4, 2018

So after the inline-always fix it looks like the only bug open still being tracked here is #42515 .

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 4, 2018

That bug looks hard to solve and probably won't make it before stabilization.

The following issues look "easy" to fix low-hanging fruit. It might be worth to fix these before stabilization:

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 14, 2022
Add support for MIPS VZ ISA extension

[Link to relevant LLVM line where virt extension is specified](https://github.com/llvm/llvm-project/blob/83fab8cee9d6b9fa911195c20325b4512a7a22ef/llvm/lib/Target/Mips/Mips.td#L172-L173)

This has been tested on mips-unknown-linux-musl with a target-cpu that is >= MIPS32 5 and `target-features=+virt`. The example was checked in a disassembler to ensure the correct assembly sequence was being generated using the virtualization instructions.

Needed additional work:

* MIPS is missing from [the Rust reference CPU feature lists](https://doc.rust-lang.org/reference/attributes/codegen.html#available-features)

Example docs for later:

```md
#### `mips` or `mips64`

This platform requires that `#[target_feature]` is only applied to [`unsafe`
functions][unsafe function]. This target's feature support is currently unstable
and must be enabled by `#![feature(mips_target_feature)]` ([Issue rust-lang#44839])

[Issue rust-lang#44839]: rust-lang#44839

Further documentation on these features can be found in the [MIPS Instruction Set
Reference Manual], or elsewhere on [mips.com].

[MIPS Instruction Set Reference Manual]: https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00086-2B-MIPS32BIS-AFP-6.06.pdf
[developer.arm.com]: https://www.mips.com/products/architectures/ase/

Feature        | Implicitly Enables | Description
---------------|--------------------|-------------------
`fp64`         |                    | 64-bit Floating Point
`msa`          |                    | "MIPS SIMD Architecture"
`virt`         |                    | Virtualization instructions (VZ ASE)
```

If the above is good I can also submit a PR for that if there's interest in documenting it while it's still unstable. Otherwise that can be dropped, I just wrote it before realizing it was possibly not a good idea.

Relevant to rust-lang#44839
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 12, 2023
…ature, r=petrochenkov

Stabilize f16c_target_feature

Resolves rust-lang/stdarch#1234

Library PR for stabilizing corresponding intrinsics: rust-lang/stdarch#1366

See also rust-lang#44839 tracking issue for target_feature
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 12, 2023
…ature, r=petrochenkov

Stabilize f16c_target_feature

Resolves rust-lang/stdarch#1234

Library PR for stabilizing corresponding intrinsics: rust-lang/stdarch#1366

See also rust-lang#44839 tracking issue for target_feature
@bkolligs
Copy link

Any update on AVX 512 support?

bors added a commit to rust-lang-ci/rust that referenced this issue Feb 28, 2023
Stabilize cmpxchg16b_target_feature

Tracking issue for target features
+ rust-lang#44839

stdarch issue
+ rust-lang/stdarch#827

stdarch PR
+ rust-lang/stdarch#1358

reference PR
+ rust-lang/reference#1331

It's my first time contributing to rust-lang/rust. Please tell me if I missed something.
@workingjubilee workingjubilee added the A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. label Mar 3, 2023
@qwandor
Copy link
Contributor

qwandor commented Jun 2, 2023

Hi, is there anything blocking stabilising arm_target_feature?

@coastalwhite
Copy link
Contributor

Hey! I am currently implementing RISC-V Zk intrinsics, and I am running into a pattern that is currently not well covered by this PR.

Either Zkne and Zknd extension needs to be enabled to get access to an intrinsic. I imagine for the compiler it is enough to write:

#[target_feature(enable = "zkne")]
pub unsafe fn aes64ks1i(...) -> ... {
     ...
}

But this produces wrong cargo doc output and can be misleading. Namely, it states that zkne needs to be enabled.

#[target_feature(enable = "zkne", enable = "zknd")]
// OR
#[target_feature(enable = "zkne")]
#[target_feature(enable = "zknd")]
pub unsafe fn aes64ks1i(...) -> ... {
     ...
}

Produces zkne AND zknd.

#[target_feature(enable = "zkne,zknd")]
pub unsafe fn aes64ks1i(...) -> ... {
     ...
}

Produces zkne,zknd which does not exist.

I feel like this is only a documentation issue, but still an issue.

@majaha
Copy link
Contributor

majaha commented Aug 21, 2023

I'm not sure if this is the right place for this, but the wasm feature #[target_feature(enable = "multivalue")] is broken at the moment, as it leaks into other untagged functions: Godbolt
This is essentially for the same reasons I've outline here: #83788 (comment)
There may be other target features with similar non-local behaviour, I haven't tested them all.

bors added a commit to rust-lang-ci/rust that referenced this issue Oct 30, 2023
…features, r=Amanieu

Stabilize Ratified RISC-V Target Features

Stabilization PR for the ratified RISC-V target features. This stabilizes some of the target features tracked by rust-lang#44839. This is also a part of rust-lang#114544 and eventually needed for the RISC-V part of rust-lang/rfcs#3268.

There is a similar PR for the the stdarch crate which can be found at rust-lang/stdarch#1476.

This was briefly discussed on Zulip
(https://rust-lang.zulipchat.com/#narrow/stream/250483-t-compiler.2Frisc-v/topic/Stabilization.20of.20RISC-V.20Target.20Features/near/394793704).

Specifically, this PR stabilizes the:
* Atomic Instructions (A) on v2.0
* Compressed Instructions (C) on v2.0
* ~Double-Precision Floating-Point (D) on v2.2~
* ~Embedded Base (E) (Given as `RV32E` / `RV64E`) on v2.0~
* ~Single-Precision Floating-Point (F) on v2.2~
* Integer Multiplication and Division (M) on v2.0
* ~Vector Operations (V) on v1.0~
* Bit Manipulations (B) on v1.0 listed as `zba`, `zbc`, `zbs`
* Scalar Cryptography (Zk) v1.0.1 listed as `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, `zkt`, `zbkb`, `zbkc` `zkbx`
* ~Double-Precision Floating-Point in Integer Register (Zdinx) on v1.0~
* ~Half-Precision Floating-Point (Zfh) on v1.0~
* ~Minimal Half-Precision Floating-Point (Zfhmin) on v1.0~
* ~Single-Precision Floating-Point in Integer Register (Zfinx) on v1.0~
* ~Half-Precision Floating-Point in Integer Register (Zhinx) on v1.0~
* ~Minimal Half-Precision Floating-Point in Integer Register (Zhinxmin) on v1.0~

r? `@Amanieu`
@jhorstmann
Copy link
Contributor

I tried reading through the open issues regarding target features, but could not find a more fitting one for this question. I have the following code, which currently returns different values on stable vs nightly when compiled with -Ctarget-cpu=skx (Godbolt). I would have expected that target-cpu implicitly enables that feature, or a warning/error that the avx512 target features are still unstable.

pub fn preferred_vec_size() -> usize {
    if cfg!(all(target_arch = "x86_64", target_feature = "avx512f")) {
        64
    } else if cfg!(all(target_arch = "x86_64", target_feature="avx")) {
        32
    } else {
        16
    }
}

@workingjubilee
Copy link
Member

workingjubilee commented Nov 13, 2023

That's... huh. I guess the first branch is being ignored as an invalid feature gate on stable.

@tarcieri
Copy link
Contributor

tarcieri commented Jan 9, 2024

Are there any particular stabilization blockers for feature(avx512_target_feature), or does it just need a stabilization PR?

Edit: response here

bors added a commit to rust-lang-ci/rust that referenced this issue Apr 9, 2024
…=wesleywiser

Stabilize Wasm target features that are in phase 4 and 5

This stabilizes the Wasm target features that are known to be working and in [phase 4 and 5](https://github.com/WebAssembly/proposals/tree/04fa8c810e1dc99ab399e41052a6e427ee988180).

Feature stabilized:
- [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions)
- [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global)
- [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops)
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations)
- [Extended Constant Expressions](https://github.com/WebAssembly/extended-const)

Features not stabilized:
- [Multi-value](https://github.com/WebAssembly/multi-value): requires rebuilding `std` rust-lang#73755.
- [Reference Types](https://github.com/WebAssembly/reference-types): no point stabilizing without rust-lang#103516.
- [Threads](https://github.com/webassembly/threads): requires rebuilding `std` rust-lang#77839.
- [Relaxed SIMD](https://github.com/WebAssembly/relaxed-simd): separate PR rust-lang#117468.
- [Multi Memory](https://github.com/WebAssembly/multi-memory): not implemented.

See rust-lang#117457 (comment) for more context.

Documentation: rust-lang/reference#1420
Tracking issue: rust-lang#44839
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 21, 2024
…=wesleywiser

Stabilize Wasm target features that are in phase 4 and 5

This stabilizes the Wasm target features that are known to be working and in [phase 4 and 5](https://github.com/WebAssembly/proposals/tree/04fa8c810e1dc99ab399e41052a6e427ee988180).

Feature stabilized:
- [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions)
- [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global)
- [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops)
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations)
- [Extended Constant Expressions](https://github.com/WebAssembly/extended-const)

Features not stabilized:
- [Multi-value](https://github.com/WebAssembly/multi-value): requires rebuilding `std` rust-lang#73755.
- [Reference Types](https://github.com/WebAssembly/reference-types): no point stabilizing without rust-lang#103516.
- [Threads](https://github.com/webassembly/threads): requires rebuilding `std` rust-lang#77839.
- [Relaxed SIMD](https://github.com/WebAssembly/relaxed-simd): separate PR rust-lang#117468.
- [Multi Memory](https://github.com/WebAssembly/multi-memory): not implemented.

See rust-lang#117457 (comment) for more context.

Documentation: rust-lang/reference#1420
Tracking issue: rust-lang#44839
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Apr 23, 2024
Stabilize Wasm target features that are in phase 4 and 5

This stabilizes the Wasm target features that are known to be working and in [phase 4 and 5](https://github.com/WebAssembly/proposals/tree/04fa8c810e1dc99ab399e41052a6e427ee988180).

Feature stabilized:
- [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions)
- [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global)
- [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops)
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations)
- [Extended Constant Expressions](https://github.com/WebAssembly/extended-const)

Features not stabilized:
- [Multi-value](https://github.com/WebAssembly/multi-value): requires rebuilding `std` #73755.
- [Reference Types](https://github.com/WebAssembly/reference-types): no point stabilizing without #103516.
- [Threads](https://github.com/webassembly/threads): requires rebuilding `std` #77839.
- [Relaxed SIMD](https://github.com/WebAssembly/relaxed-simd): separate PR #117468.
- [Multi Memory](https://github.com/WebAssembly/multi-memory): not implemented.

See rust-lang/rust#117457 (comment) for more context.

Documentation: rust-lang/reference#1420
Tracking issue: rust-lang/rust#44839
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
Stabilize Wasm target features that are in phase 4 and 5

This stabilizes the Wasm target features that are known to be working and in [phase 4 and 5](https://github.com/WebAssembly/proposals/tree/04fa8c810e1dc99ab399e41052a6e427ee988180).

Feature stabilized:
- [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions)
- [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global)
- [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops)
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations)
- [Extended Constant Expressions](https://github.com/WebAssembly/extended-const)

Features not stabilized:
- [Multi-value](https://github.com/WebAssembly/multi-value): requires rebuilding `std` #73755.
- [Reference Types](https://github.com/WebAssembly/reference-types): no point stabilizing without #103516.
- [Threads](https://github.com/webassembly/threads): requires rebuilding `std` #77839.
- [Relaxed SIMD](https://github.com/WebAssembly/relaxed-simd): separate PR #117468.
- [Multi Memory](https://github.com/WebAssembly/multi-memory): not implemented.

See rust-lang/rust#117457 (comment) for more context.

Documentation: rust-lang/reference#1420
Tracking issue: rust-lang/rust#44839
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-SIMD Area: SIMD (Single Instruction Multiple Data) A-stability Area: `#[stable]`, `#[unstable]` etc. A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. Libs-Tracked Libs issues that are tracked on the team's project board. S-tracking-design-concerns Status: There are blocking ❌ design concerns. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests