mips64 ABI bug passing 16-byte aligned scalars
Open
@Gelbpunkt is already working on this.
Since Aug 24, 2026.
A-ABI
I-miscompile
I-prioritize
needs-triage
O-MIPS
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
16-byte aligned scalars (f128, i128, u128, probably also vectors) are passed in a way that is inconsistent with GCC/Clang. Aggregates seem fine.
E.g. C calling rust (but also rust calling C) fails:
// caller.c
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdarg.h>
void val_in_0_perturbed_small(uint8_t arg0, __int128_t arg1, __int128_t arg2, float arg3) {
printf("%d", arg1);
}
// callee.rs
extern "C" {
fn val_in_0_perturbed_small(arg0: u8, arg1: i128, arg2: i128, arg3: f32);
}
#[no_mangle]
pub extern "C" fn do_test() {
unsafe {
let arg0 = 192u8;
let arg1 = -42707334047547540181846984563639529008i128;
println!("{:?}", {arg1});
let arg2 = -21356283574076891493948969979685445152i128;
let arg3 = f32::from_bits(4092785136);
val_in_0_perturbed_small(arg0, arg1, arg2, arg3);
}
}
When running abi-cafe that prints
func val_in_0_perturbed_small's values differed
values (native-endian hex bytes):
expect: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
caller: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
callee: D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7
the value was arg1: i128
whose arg was arg1: i128
So looks like the callee side is off by 8 bytes.
I used this abi-cafe command (on my fork that cross-compiles https://github.com/folkertdev/abi-cafe):
env RUSTUP_TOOLCHAIN=stage1 QEMU_LD_PREFIX=/usr/mips64el-linux-gnuabi64 ABI_CAFE_RUNNER= ./target/release/abi-cafe --target mips64el-unknown-linux-gnuabi64 --linker mips64el-linux-gnuabi64-gcc --conventions c --reprs c -t i128
Which requires a stage1 toolchain with the right std, e.g. something like this (also building the host is often convenient):
./x build library --target x86_64-unknown-linux-gnu,mips64-unknown-linux-gnuabi64,mips64el-unknown-linux-gnuabi64,mips-unknown-linux-gnu,mipsel-unknown-linux-gnu
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.