stabilize s390x specific target-feature backchain#158612
Conversation
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Target features always need to be documented (example from a past s390x stabilization). Also, since these always need a lang FCP, they generally need a written proposal as to what is being stabilized in order for them to make a decision. |
|
According to target expert @uweigand, there are no ABI concerns with this feature (having some parts of the code compiled with and some without can lead to poor backtraces but doesn't break anything worse than that). So 👍 from the ABI side. |
PRELIMINARY - STILL IN WORK
Stabilization report: s390x
backchaintarget featureSummary
This stabilizes the s390x (SystemZ) target feature
backchain.When
backchainis enabled, the function prologue stores the caller's stackpointer into the first slot (the
backchainslot) of the function's stackframe. This links all stack frames into a chain that can be walked without
DWARF/CFI unwind information, which is how the Linux kernel unwinds the stack
on s390x. The primary motivation for stabilization is Rust-for-Linux: the s390x
kernel is compiled with
backchainenabled (-mbackchainin GCC/Clang), andRust kernel code must match.
backchainis not a hardware (ISA) capability — it is a pure codegen option,available on every s390x CPU. The feature name matches LLVM's SystemZ feature
backchain; GCC and Clang expose the same functionality as-mbackchain.Tracking:
-Ctarget-feature=+backchain#158014Reference PRs:
backchainto the s390x target-feature table)What is stabilized
On s390x targets,
backchainbecomes a stable target feature, i.e. all of thefollowing are accepted on stable without warnings:
and on the command line:
What isn't stabilized
vector-*extensions were stabilizedseparately in 1.93 via
s390x_target_feature_vector; the remaining ISAfeatures stay gated behind
s390x_target_feature).-Zpacked-stack(the GCC-mpacked-stackequivalent) remains unstable; onlyits interaction with
backchainis relevant here (see below).soft-floatremains unstable.Design
Reference
The Reference documents stable target features per architecture in
attributes/codegen.md. A PR addingbackchainto the s390x table accompaniesthis stabilization: TODO link.
RFC history
None. Target features are added and stabilized through the tracking-issue /
stabilization-report process rather than the RFC process.
Answers to unresolved questions
The tracking issue (#150259) listed one unresolved question about
the
packed-stackinteraction (#152432). It has no impact onbackchainitself, which stays a regular target feature matching how LLVMmodels it; the
packed-stackcombination is handled as described in Key points.No unresolved questions remain.
Post-RFC changes
None (no RFC; see above).
Key points
The only design decision of note is how to handle the interaction with the
(unstable)
-Zpacked-stackoption. A packed stack frame has nobackchainslot unless
soft-floatis also enabled, so thepacked-stack+backchain+hard-floatcombination cannot be lowered and makes LLVM ICE.rustcrejectsit up front with a dedicated hard error (#152432).
backchainonits own is uncontentious: it is a pure, additive codegen option available on
every s390x CPU.
Nightly extensions
The remaining s390x ISA target features stay gated behind
s390x_target_feature, and-Zpacked-stackandsoft-floatremain unstable.Stabilizing
backchaincommits us to nothing about those: it is a single,self-contained codegen flag whose only cross-feature interaction
(
packed-stack) is guarded by a hard error (see Key points).Doors closed
None.
backchainmaps directly onto the LLVMbackchainfeature and theestablished
-mbackchainsemantics shared with GCC/Clang, so stabilizing itdoes not constrain future language or target-feature work.
Feedback
Call for testing
No formal "call for testing" was issued. The feature has been exercised on
nightly by the Rust-for-Linux s390x work (see Nightly use).
Nightly use
The known nightly consumer is Rust-for-Linux: the s390x kernel is built with
-mbackchain, so Rust kernel code targeting s390x must enablebackchaintomatch. This is the motivation for stabilization.
Implementation
Major parts
s390x-unknown-none-softfloatwithRustcAbi::Softfloat#151154Coverage
tests/codegen-llvm/backchain.rs—-Ctarget-feature=+backchainresults inthe
+backchainLLVM function attribute.tests/assembly-llvm/s390x-backchain-toggle.rs— the prologue actuallystores the
backchainwhen enabled (+backchain), and does not when disabled(
-backchain) or by default.tests/ui/target-feature/packedstack-combinations.rs— thepacked-stack/backchaininteraction: rejected onhard-floattargetswhether
backchaincomes from#[target_feature]or-Ctarget-feature,accepted on
s390x-unknown-none-softfloat.tests/codegen-llvm/packedstack.rs—packed-stackattribute emission onthe
soft-floattarget.tests/ui/check-cfg/target_feature.rs—backchainis a known value forcfg(target_feature).There are no known or intentional gaps in coverage.
Outstanding bugs
None. The former blocker #142412 is fixed.
Outstanding FIXMEs
None.
Tool changes
None required — target features need no support from these tools beyond what
exists generically.
Breaking changes
None. This stabilization only makes an already-existing nightly target feature
available on stable; it does not change the meaning of any existing code, so no
crater run is applicable.
Crater report:
Crater analysis:
PRs to affected crates:
Type system, opsem
Compile-time checks
The only compile-time check is the rejection of the invalid
packed-stack+backchain+hard-floatcombination, which LLVM cannot lower and would ICEon.
rustcemits a dedicated hard error up front (#152432); seeCoverage for the test.
Type system rules
No new type system rules.
backchainis governed by the existingtarget_feature1.1 rules for enabling and detecting target features; it addsno feature-specific typing rules.
Sound by default?
Yes. It does not change the calling convention or any type's ABI: the
backchainslot is part of the standard s390x ELF ABI stack frame layout, andthe feature only controls whether the prologue stores into it. Since it is not
a hardware
capability (see Summary), the
#[target_feature]caller obligation is triviallysatisfied on every s390x CPU, so no unsafe opt-in is needed.
Breaks the AM?
No. It cannot introduce undefined behavior or expose the underlying
assembly-level implementation. The one invalid combination is rejected at
compile time (see Compile-time checks).
Common interactions
Temporaries
Not applicable. The feature introduces no new expressions and therefore no new
temporaries.
Drop order
Not applicable. The feature does not affect the order in which values are
dropped.
Pre-expansion / post-expansion
Not applicable.
backchainraises no new pre- vs. post-expansion questions; itis handled like any other target feature in
#[target_feature]andcfg(target_feature).Edition hygiene
Not applicable. The feature is not gated on an edition.
SemVer implications
No new hazards beyond those that already apply to
#[target_feature]generally. As with any target feature, adding or removing
#[target_feature(enable = "backchain")]on a public function can affectwhether it can be used as a plain function pointer, so it follows the existing
target_featureconventions;backchainintroduces nothing beyond that.Exposing other features
None. Its only interaction with an unstable feature is the guarded
-Zpacked-stackcombination (see Key points); nopacked-stackbehavior leaksonto stable.
History
See Major parts for the annotated implementation PRs. Additional context not
listed there:
cfg(target_feature = "backchain")(s390x target feature) be enabled? #142412-Ctarget-feature=+backchain#158014Acknowledgments
backchaintarget featurepacked-stacksupport,soft-floattarget, this stabilizationNo one who worked on this has objected to stabilizing it now.
Open items
backchainto the s390x target-featuretable and replace the TODO link above.