Skip to content

Enable f16 and f128 on targets that were fixed in LLVM21 #144987

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

Merged
merged 1 commit into from
Aug 9, 2025

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented Aug 6, 2025

LLVM21 fixed the new float types on a number of targets:

Thus, enable the types on relevant targets for LLVM > 21.0.0.

NVPTX also gained handling of f128 as a storage type, but it lacks support for basic math operations so is still disabled here.

try-job: dist-i586-gnu-i586-i686-musl
try-job: dist-i686-linux
try-job: dist-i686-msvc
try-job: dist-s390x-linux
try-job: dist-various-1
try-job: dist-various-2
try-job: dist-x86_64-linux
try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: test-various

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2025
@tgross35
Copy link
Contributor Author

tgross35 commented Aug 6, 2025

@bors2 try

@rust-bors
Copy link

rust-bors bot commented Aug 6, 2025

⌛ Trying commit c38cb12 with merge 0ca61d0

To cancel the try build, run the command @bors try cancel.

rust-bors bot added a commit that referenced this pull request Aug 6, 2025
Enable f16 and f128 on targets that were fixed in LLVM21

try-job: dist-i586-gnu-i586-i686-musl
try-job: dist-i686-linux
try-job: dist-i686-msvc
try-job: dist-s390x-linux
try-job: dist-various
try-job: dist-x86_64-linux
try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: test-various
@rust-bors
Copy link

rust-bors bot commented Aug 6, 2025

💔 Test failed (CI). Failed job:

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor Author

tgross35 commented Aug 6, 2025

@bors2 try

@rust-bors
Copy link

rust-bors bot commented Aug 6, 2025

⌛ Trying commit c38cb12 with merge dbb859a

To cancel the try build, run the command @bors try cancel.

rust-bors bot added a commit that referenced this pull request Aug 6, 2025
Enable f16 and f128 on targets that were fixed in LLVM21

try-job: dist-i586-gnu-i586-i686-musl
try-job: dist-i686-linux
try-job: dist-i686-msvc
try-job: dist-s390x-linux
try-job: dist-various-1
try-job: dist-various-2
try-job: dist-x86_64-linux
try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: test-various
@tgross35 tgross35 added the F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` label Aug 6, 2025
@tgross35
Copy link
Contributor Author

tgross35 commented Aug 6, 2025

I am going to drop nvptx after the try completes because it has further crashes for f128 https://llvm.godbolt.org/z/snYbYx1ds. These will need new LLVM issues

Cc @beetrees in case you know of other possible problems, but the rest seems to at least build core and compiler-builtins without crashing.

Cc target maintainers @uweigand (s390x), @Gelbpunkt (mips) and @androm3da (hexagon) in case you want to make sure that the std testsuite still passes with the types enabled here.

@rust-bors
Copy link

rust-bors bot commented Aug 6, 2025

☀️ Try build successful (CI)
Build commit: dbb859a (dbb859a01b7299fa57b562dc0b6b00a81854684f, parent: dc0bae1db725fbba8524f195f74f680995fd549e)

@beetrees
Copy link
Contributor

beetrees commented Aug 7, 2025

@bjorn3 does rustc_codegen_cranelift care about being able to pass tests when building against an LLVM-built sysroot built using an older version of LLVM? The has_reliable_f16/has_reliable_f128 in rustc_codegen_cranelift/src/lib.rs are all because of the LLVM bugs (as rustc_codegen_cranelift runs tests against an LLVM-built sysroot). There's no way AFAIK to check the LLVM version used to build the sysroot here, but if support for passing tests when building against an LLVM-21-built sysroot is all that is required, I believe the whole thing in rustc_codegen_cranelift can be simplified to:

        // FIXME(f16_f128): `rustc_codegen_llvm` currently disables support on Windows GNU
        // targets due to GCC using a different ABI than LLVM. Therefore `f16`/`f128` won't be
        // available when using a LLVM-built sysroot.
        let llvm_has_reliable_f16_f128 = !(sess.target.arch == "x86_64"
            && sess.target.os == "windows"
            && sess.target.env == "gnu"
            && sess.target.abi != "llvm");

        TargetConfig {
            target_features,
            unstable_target_features,
            // `rustc_codegen_cranelift` polyfills functionality not yet
            // available in Cranelift.
            has_reliable_f16: llvm_has_reliable_f16_f128,
            has_reliable_f16_math: llvm_has_reliable_f16_f128,
            has_reliable_f128: llvm_has_reliable_f16_f128,
            has_reliable_f128_math: llvm_has_reliable_f16_f128,
        }

@tgross35 tgross35 force-pushed the llvm21-f16-f128 branch 2 times, most recently from 0c88ecc to ae2585d Compare August 7, 2025 20:34
LLVM21 fixed the new float types on a number of targets:

* SystemZ gained f16 support
  llvm/llvm-project#109164
* Hexagon now uses soft f16 to avoid recursion bugs
  llvm/llvm-project#130977
* Mips now correctly handles f128 (actually since LLVM20)
  llvm/llvm-project#117525
* f128 is now correctly aligned when passing the stack on x86
  llvm/llvm-project#138092

Thus, enable the types on relevant targets for LLVM > 21.0.0.

NVPTX also gained handling of f128 as a storage type, but it lacks
support for basic math operations so is still disabled here.
@tgross35 tgross35 marked this pull request as ready for review August 7, 2025 20:35
@rustbot
Copy link
Collaborator

rustbot commented Aug 7, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 7, 2025
@tgross35
Copy link
Contributor Author

tgross35 commented Aug 7, 2025

Updated to remove nvptx from the list.

Verified that we can build compiler-builtins now as well rust-lang/compiler-builtins#1004. PPC failures are unrelated, and I am assuming that the i686-msvc will go away once this PR makes it to nightly and we start building the symbols.

r? @nikic

@rustbot rustbot assigned nikic and unassigned petrochenkov Aug 7, 2025
@nikic
Copy link
Contributor

nikic commented Aug 8, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 8, 2025

📌 Commit cdb299c has been approved by nikic

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 8, 2025
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 8, 2025
Enable f16 and f128 on targets that were fixed in LLVM21

LLVM21 fixed the new float types on a number of targets:

* SystemZ gained f16 support  llvm/llvm-project#109164
* Hexagon now uses soft f16 to avoid recursion bugs  llvm/llvm-project#130977
* Mips now correctly handles f128 (actually since LLVM20) llvm/llvm-project#117525
* f128 is now correctly aligned when passing the stack on x86  llvm/llvm-project#138092

Thus, enable the types on relevant targets for LLVM > 21.0.0.

NVPTX also gained handling of f128 as a storage type, but it lacks support for basic math operations so is still disabled here.

try-job: dist-i586-gnu-i586-i686-musl
try-job: dist-i686-linux
try-job: dist-i686-msvc
try-job: dist-s390x-linux
try-job: dist-various-1
try-job: dist-various-2
try-job: dist-x86_64-linux
try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: test-various
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 8, 2025
Enable f16 and f128 on targets that were fixed in LLVM21

LLVM21 fixed the new float types on a number of targets:

* SystemZ gained f16 support  llvm/llvm-project#109164
* Hexagon now uses soft f16 to avoid recursion bugs  llvm/llvm-project#130977
* Mips now correctly handles f128 (actually since LLVM20) llvm/llvm-project#117525
* f128 is now correctly aligned when passing the stack on x86  llvm/llvm-project#138092

Thus, enable the types on relevant targets for LLVM > 21.0.0.

NVPTX also gained handling of f128 as a storage type, but it lacks support for basic math operations so is still disabled here.

try-job: dist-i586-gnu-i586-i686-musl
try-job: dist-i686-linux
try-job: dist-i686-msvc
try-job: dist-s390x-linux
try-job: dist-various-1
try-job: dist-various-2
try-job: dist-x86_64-linux
try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: test-various
bors added a commit that referenced this pull request Aug 8, 2025
Rollup of 7 pull requests

Successful merges:

 - #144039 (Use `tcx.short_string()` in more diagnostics)
 - #144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - #144823 (coverage: Extract HIR-related helper code out of the main module)
 - #144987 (Enable f16 and f128 on targets that were fixed in LLVM21)
 - #145001 (regression test for intrinsics may not inline properly on pclmulqdq)
 - #145080 (Escape diff strings in MIR dataflow graphviz)
 - #145083 (Fix cross-compilation of Cargo)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 8, 2025
Rollup of 8 pull requests

Successful merges:

 - #139451 (Add `target_env = "macabi"` and `target_env = "sim"`)
 - #144039 (Use `tcx.short_string()` in more diagnostics)
 - #144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - #144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses)
 - #144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697))
 - #144649 (Account for bare tuples and `Pin` methods in field searching logic)
 - #144775 (more strongly dissuade use of `skip_binder`)
 - #144987 (Enable f16 and f128 on targets that were fixed in LLVM21)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 660bf91 into rust-lang:master Aug 9, 2025
10 checks passed
rust-timer added a commit that referenced this pull request Aug 9, 2025
Rollup merge of #144987 - tgross35:llvm21-f16-f128, r=nikic

Enable f16 and f128 on targets that were fixed in LLVM21

LLVM21 fixed the new float types on a number of targets:

* SystemZ gained f16 support  llvm/llvm-project#109164
* Hexagon now uses soft f16 to avoid recursion bugs  llvm/llvm-project#130977
* Mips now correctly handles f128 (actually since LLVM20) llvm/llvm-project#117525
* f128 is now correctly aligned when passing the stack on x86  llvm/llvm-project#138092

Thus, enable the types on relevant targets for LLVM > 21.0.0.

NVPTX also gained handling of f128 as a storage type, but it lacks support for basic math operations so is still disabled here.

try-job: dist-i586-gnu-i586-i686-musl
try-job: dist-i686-linux
try-job: dist-i686-msvc
try-job: dist-s390x-linux
try-job: dist-various-1
try-job: dist-various-2
try-job: dist-x86_64-linux
try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: test-various
@rustbot rustbot added this to the 1.91.0 milestone Aug 9, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 9, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#139451 (Add `target_env = "macabi"` and `target_env = "sim"`)
 - rust-lang/rust#144039 (Use `tcx.short_string()` in more diagnostics)
 - rust-lang/rust#144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - rust-lang/rust#144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses)
 - rust-lang/rust#144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697))
 - rust-lang/rust#144649 (Account for bare tuples and `Pin` methods in field searching logic)
 - rust-lang/rust#144775 (more strongly dissuade use of `skip_binder`)
 - rust-lang/rust#144987 (Enable f16 and f128 on targets that were fixed in LLVM21)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants