mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-05 09:23:31 +00:00
LLVM 24: configure float-abi via module flag
`TargetOptions::FloatABIType` was removed in https://github.com/llvm/llvm-project/pull/215796
See https://github.com/llvm/llvm-project/pull/212985 for the corresponding clang change.
The `ModuleFlagMergeBehavior::Error` was copied from the clang implementation.
This currently relies on the string representation of Rust's [`FloatAbi` "target_spec_enum"](e71c0f1e33/compiler/rustc_target/src/spec/mod.rs (L978-L986)) matching LLVM. This seemed reasonable to me since the representation is quite straightforward ("soft" and "hard"), but let me know if you'd like an explicit `to_llvm_float_abi_str`, either defined in Rust or forwarding to `llvm::FloatABI::getABITypeName`.
Contrary to the clang implementation which only sets the module flag if it differs from the target default, we set it whenever the Rust target has an explicit float ABI set. See also discussion in [#t-compiler/llvm > float-abi module flag behavior](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/float-abi.20module.20flag.20behavior/with/617279073).
The added test won't actually run on Rust's own CI until that updates to LLVM 24.
@rustbot label llvm-main
The files here use the LLVM FileCheck framework, documented at https://llvm.org/docs/CommandGuide/FileCheck.html.
One extension worth noting is the use of revisions as custom prefixes for FileCheck. If your codegen test has different behavior based on the chosen target or different compiler flags that you want to exercise, you can use a revisions annotation, like so:
// revisions: aaa bbb
// [bbb] compile-flags: --flags-for-bbb
After specifying those variations, you can write different expected, or
explicitly unexpected output by using <prefix>-SAME: and <prefix>-NOT:,
like so:
// CHECK: expected code
// aaa-SAME: emitted-only-for-aaa
// aaa-NOT: emitted-only-for-bbb
// bbb-NOT: emitted-only-for-aaa
// bbb-SAME: emitted-only-for-bbb