Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

166 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ABI Cafe 🧩☕️❤️

Not sure if your compilers have matching ABIs? Then put them through the ultimate compatibility crucible and pair them up on a shift at The ABI Cafe! Find out if your one true pairing fastcalls for each other or are just another slowburn disaster. (Maid outfits optional but recommended.)

Quickstart

To run ABI Cafe you can cargo install abi-cafe and run abi-cafe, or checkout the repository and cargo run!

What Is This

ABI Cafe automates testing that two languages/compilers agree on their ABIs.

ABI Cafe is essentially an ABI fuzzer, which:

If they agree, great!

If they don't agree, even better, we just learned something! We then try to diagnose why they disagreed, and generate a minimized version that a human can inspect and report!

Now do this a bajillion times and suddenly we're learning a whole lot! Alternatively, you can hand-craft any type or function signature you're interested in, and explore its interoperability between different toolchains.

ABI Cafe is purely descriptive. It has no preconceived notion of what should work, and it doesn't trust any damn thing anyone says about it. We don't analyze assembly or metadata, and we'll gleefully create programs riddled with Undefined Behaviour. We're here to learn not lecture.

This design is based on a fundamental belief that ABIs exist only through sheer force of will. The spec if often "read GCC's source code", and damn if that ain't an error-prone process. Also GCC doesn't even know you exist, and you're only going to keep interoperating with them if you check and maintain your work. So here's a tool for checking and maintaining your work!

Cross-compilation

This fork has support for cross-compilation. For instance to compare clang and gcc for a custom target:

QEMU_LD_PREFIX=/usr/i686-linux-gnu \
cargo run --release -- \
    --target i686-unknown-linux-gnu \
    --linker i686-linux-gnu-gcc \
    --add-cc-toolchain gcc:distro-gcc:/usr/bin/i686-linux-gnu-gcc \
    --conventions c --reprs c \
    -l clang,distro-gcc \
    -p clang_calls_distro-gcc,distro-gcc_calls_clang

Or compare rustc and clang:

QEMU_LD_PREFIX=/usr/riscv64-linux-gnu \
cargo run --release -- \
    --target riscv64gc-unknown-linux-gnu \
    --linker riscv64-linux-gnu-gcc \
    --conventions c --reprs c \
    -l rustc,clang-nightly \
    -p rustc_calls_clang,clang_calls_rustc

When rust is involved, a std for the target is required, e.g. using rustup target add riscv64gc-unknown-linux-gnu.

Finally, for development and for tier 3 targets, we can compare a custom rustc with a custom clang:

cargo build --release

RUSTUP_TOOLCHAIN=stage1 \
QEMU_LD_PREFIX=/usr/mips-linux-gnu \
./target/release/abi-cafe \
    --target mips-unknown-linux-gnu \
    --linker mips-linux-gnu-gcc \
    --add-cc-toolchain clang:clang-nightly:/path/to/llvm-project/build/bin/clang \
    --conventions c --reprs c \
    -l rustc,clang-nightly \
    -p rustc_calls_clang-nightly,clang-nightly_calls_rustc

Here the std has to be in that toolchain's sysroot, e.g. using ./x build library --target mips-unknown-linux-gnu.

Choose Your Own Adventure

About

Pair your compilers up at The ABI Cafe!

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages