-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Add s390x-unknown-none-softfloat with RustcAbi::Softfloat
#151154
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
Conversation
|
Cc @RalfJung who is the expert in this bit of code.
There aren't any tests indicating how this is meant to be used; do you mean that attempting to use +soft-float is rejected via target properties? I.e., what happens when a binary built with +soft-float gets linked against the normal The ABI change can be covered with a simple test in |
|
The way the code works allows us to take a simpler route for this case:
Then we do not need to have "agreement" on the soft-float flag between target-features in FeatureConstraints, because it becomes "use the target or bust". |
|
The above description of how it is easier to solve this by avoiding the question of target-features being set at all is why we have nudged towards "a new target": @fneddy @uweigand To bring you up to speed on a detail that has become important to clarify, and I think may have been missed: Rust target features are not LLVM target features. This is not just because Cranelift and GCC are backends in the process of being implemented. It is mandated by the language itself. Long ago, in Rust RFC 2045, Rust decided to allow However, because these attributes live in Rust source code, they are subject to rustc's stability policies around the language, or at least there is an expectation that they are. People are not amused when you tell them that their source code doesn't build because LLVM changed how they support that feature! Unfortunately, the list of LLVM features changes surprisingly often. This story is well-told by the mapping of Rust features to LLVM features in And that is on top of the realization that many target features are nonsensical to set on a per-function basis, despite being implemented as settable in that way by LLVM! Since that realization, the compiler and language teams have more-or-less been trying to walk that back as much as possible. I'm approximating. This is the other big reason for my and Ralf's suggestion of "new target" as the way to "configure" this, instead of requiring agreement: There's no reason to reflect the way C compilers configure something like this when we already have to go so far in a different direction. The main reason to introduce target modifiers for a target is when you want to support many subtle variations, especially along more than one axis. The many-splendored world of ABI-incompatible RISCV variants, for example. Here, we only have heard calls for two de facto targets. |
Note that the target feature already exists, it just needs the message to be changed. Also I think we can't make it |
Actually, it seems I misremembered. It can remain |
|
my further agenda so far:
open question:
|
Since you can't even set the flag any more, we also don't have to worry about linking I think. Linking things with different target triples is so far out there, IMO we can ignore that case. |
Correction: three. I forgot we also supported musl for this target!
Yeah, I also think we can rely on "...they're different targets, did you really expect linking them to go well?" People implementing non-Cargo build systems could try to bypass our resistance to that, but they usually try to exercise a mote of sense here and provide a slightly better UX than "directly wielding the three-edged sword of a C compiler", and usually are target-aware in how they operate. We do know the way cargo works simply won't try it. There's still some possibilities we could try to test for locking down, but as far as I know Linux's kbuild is also reluctant to make this conflation, so that covers the two major users of interest. |
|
Mind, if you can easily trick rustc into trying to link incompatible binaries when it drives the linker, we'd want to investigate that further. But we do consider external tool usage... using a linker without going through rustc, supplying a linker script to rustc, or interdicting rustc's attempts to access external tools via replacing the linker with a wrapper script... to be essentially equivalent to |
|
currently the resulting ABI incompatibility is modeled here: rust/compiler/rustc_target/src/target_features.rs Lines 1221 to 1233 in e87834e
However this is not (yet) treated as a hard failure but just a warning: rust/compiler/rustc_interface/src/util.rs Lines 92 to 100 in b765963
rust/compiler/rustc_interface/messages.ftl Lines 1 to 3 in b765963
As mentioned, llvm currently will silently switch to the unofficial Should I keep this as is for this case or should I add another check that will create a hard failure?. |
|
What do you find misleading about the warning? It says that the ABI of the current target is not implemented correctly when using I don't think we should have a separate check, but we could make the warning a hard error on s390x if the target maintainers are fine with that. |
|
I just wanted to point out that one could ignore the warning and do nonsense like We will definitely need hard errors on |
Yeah. I'm aware. I think making the warning a hard error for some targets is a good idea; we just didn't do this globally due to backwards compatibility. Also, what's wrong with the last example? Is
Yeah finding a good place for such an odd target limitation will be tricky. :/ But that's a question for a different PR. |
on s390x the float and vector registers overlap. So if you enable softfloat you consequently should disable vector. This is present in llvm. I would also add this as incompatible to generate proper errors from rustc. |
I don't see why that's a consequence. |
Well, on SystemZ the |
|
We only allow vector types to be passed by-val when But, I'm also fine with making |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in src/doc/rustc/src/platform-support cc @Noratrieb |
This comment has been minimized.
This comment has been minimized.
|
Ok I think I incorporated the points needed. I would appreciate more comments and reviews. |
s390x-unknown-none-softfloat
src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md
Outdated
Show resolved
Hide resolved
| There is no need to build the target. | ||
|
|
||
| ## Building Rust programs | ||
|
|
||
| This target is not intended to build stand-alone binaries. You should only use | ||
| it in conjunction with the kernel toolchain that provides its own libcore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am perplexed by this.
The Linux kernel toolchain presumably does need to build the target's libcore, no? And they just build the same libcore, last I checked. Are you thinking of liballoc?
In any case, this is... unhelpful. Please address your peers with this section, instead. People who are working on building the Linux kernel with Rust on s390x. It would be better to just link out to Linux kernel documentation if you would prefer that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right. I don’t know what I saw that made me think the kernel has its own libcore. I will correct this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This segment is still waiting on an update, I think, both to correct the libcore detail and also... just... you might as well say something like...
"Code for this target can be built by the usual methods of -Zbuild-std or building a custom toolchain after enabling the target in bootstrap.toml, but you probably want to just use kconfig/kbuild which should take care of this for you."
...At least, if my understanding of what kbuild does is correct, heh.
That way people get an appropriate nudge to do the right thing, instead of just telling them the thing that clearly can be done shouldn't ever need to be done. Because, well, they might be someone updating kbuild.
src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md
Outdated
Show resolved
Hide resolved
src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md
Outdated
Show resolved
Hide resolved
src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
ok so this is ready for a next round. through I have to wait for rust-lang/stdarch#2022 to be merged and then i'll rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool and good. Found some nits. Will take a final scan after the final rebase.
compiler/rustc_target/src/spec/targets/s390x_unknown_none_softfloat.rs
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
|
|
e0972bb to
edc58b1
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
edc58b1 to
ae5d03b
Compare
|
@rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And with one last note, we're done!
src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md
Outdated
Show resolved
Hide resolved
src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md
Outdated
Show resolved
Hide resolved
This target is intended to be used for kernel development. Becasue on s390x float and vector registers overlap we have to disable the vector extension. The default s390x-unknown-gnu-linux target will not allow use of softfloat. Co-authored-by: Jubilee <workingjubilee@gmail.com>
tests will check: - correct emit of assembly for softfloat target - incompatible set features will emit warnings/errors - incompatible target tripples in crates will not link
ea19036 to
83dba5b
Compare
|
cool! mostly-additive change, should be fine to @bors r+ rollup |
s390x-unknown-none-softfloats390x-unknown-none-softfloat with RustcAbi::Softfloat
…uwer Rollup of 7 pull requests Successful merges: - #151960 (rustc_parse: improve the error diagnostic for "missing let") - #152157 (Fix error spans for `asm!()` args that are macros) - #152317 (fix: sup_trace to sub_trace) - #150897 (rustc_parse_format: improve diagnostics for unsupported debug = syntax) - #151154 (Add `s390x-unknown-none-softfloat` with `RustcAbi::Softfloat`) - #152013 (Update to Xcode 26.2) - #152326 (Remove the compiler adhoc group)
Rollup merge of #151154 - fneddy:s390x_softfloat_abi, r=workingjubilee Add `s390x-unknown-none-softfloat` with `RustcAbi::Softfloat` followup on #150766 add an `s390x-unknown-none-softfloat` target to use for kernel compilation, as the Linux kernel does not wish to pay the overhead of saving float registers by default on kernel switch. this target's `extern "C"` ABI is unspecified, so it is unstable and subject to change between versions, just like the Linux intrakernel ABI and `extern "Rust"` ABIs are unstable. enforce target feature incompatibility by adding `RustcAbi::Softfloat`. this is itself just a rename of `RustcAbi::X86Softfloat`, accepting both "x86-softfloat" and "softfloat" as valid strings in the target.json format. the target-features of `"soft-float"` and `"vector"` are incompatible for s390x, so issue a compatibility warning if they are combined.
followup on #150766
add an
s390x-unknown-none-softfloattarget to use for kernel compilation, as the Linux kernel does not wish to pay the overhead of saving float registers by default on kernel switch. this target'sextern "C"ABI is unspecified, so it is unstable and subject to change between versions, just like the Linux intrakernel ABI andextern "Rust"ABIs are unstable.enforce target feature incompatibility by adding
RustcAbi::Softfloat. this is itself just a rename ofRustcAbi::X86Softfloat, accepting both "x86-softfloat" and "softfloat" as valid strings in the target.json format. the target-features of"soft-float"and"vector"are incompatible for s390x, so issue a compatibility warning if they are combined.