Arm assembly code generated dependecy on stack 8-byte alignment

In I opened the issue: arm: incorrect assembly code generated · Issue #134166 · rust-lang/rust · GitHub which was mentioned.

Arm target will generate the assembly code that relies on the stack alignment of 8 bytes.
Otherwise, the application will not work as expected.

I checked the Arm development manual but can't find the hard requirements.
I also checked the implementation of Threadx, It does require the stack to be 8-byte aligned. e.g. threadx/ports/cortex_r5/gnu/src/tx_thread_stack_build.S at master · eclipse-threadx/threadx · GitHub

I don't know why there is such an agreed convention. Or where can I get any documents?

I used the profile as follows:

[profile.release]
opt-level = 3
debug = 2
split-debuginfo = '...'  # Platform-specific.
strip = "none"
debug-assertions = false
overflow-checks = false
lto = false
panic = 'unwind'
incremental = false
codegen-units = 1
rpath = false

Is there any configuration to generate the assembly code which no reliance on 8-byte alignment?

it is part of AAPCS (Arm Archtecture Procedure Call Standard), to quote section 6.2.1.2:

The stack must also conform to the following constraint at a public interface:

SP mod 8 = 0. The stack must be double-word aligned.

2 Likes