ABI

2 Posts

Basic Types, Structs, and Memory Layout

3 minute

When C developers first look at Rust types, the obvious move is to find familiar mappings: uint8_t to u8, int32_t to i32, size_t to usize, struct to struct.

That is a good starting point, but similar names are not enough.

In C, basic types, struct layout, alignment, and ABI affect file formats, network packets, register maps, dynamic library interfaces, and cross-language calls. Rust also cares about these issues, but its defaults have a different goal: Rust types first serve internal safety and optimization. If a type has to match C or a binary layout, that boundary must be made explicit.

Read More

Why ABI, Calling Conventions, and Cross-Compilation Can Produce Binaries That Build but Do Not Run

8 minute

Cross-compilation creates an easy illusion: if the program built successfully, it should run on the board.

In practice, that often fails. The executable is copied to the device and reports Exec format error. The file exists, but execution says not found. Linking succeeds, but the program crashes when calling a library function. Both targets are ARM, but changing toolchains breaks floating-point arguments. Both targets are RISC-V, but the generated program uses instructions the board does not support.

Read More