Data Structures and Algorithms

Interoperation Without an Interface: C++ and Rust in One Translation Unit, and One Toolchain

Authors: Brent Hartshorn

Cross-language interoperation is normally a matter of agreeing on a boundary: a foreign function interface, a generated shim, a marshalling layer, or a shared intermediate representation. We describe a system in which no boundary exists. Subsets of C++ and of Rust are each lowered to plain C source, and one C compiler consumes the result, so a Rust function calling a C++ method is a C function calling a C function — same translation unit, same intermediate representation, same register allocator. The two lowerings are chosen to converge on identical symbols, with the consequence that a Rust impl Drop and a C++ destructor over the same data emit the same function, and a C++ class may hold a Rust value by value without a shim, a wrapper, or an annotation.Removing the boundary between the languages exposes a second one, below them: the artifact is C, but a C compiler, an assembler, a linker and a runtime still stand between C and a running program, and conventionally those are separate projects. We report a stack in which they are not. The whole path — two source languages to C, C to machine code, machine code to a static ELF executable — is roughly fifty thousand lines in one repository, with no external compiler, assembler, linker or C library involved.

Comments: 11 Pages.

Download: PDF

Submission history

[v1] 2026-08-17 20:43:05

Unique-IP document downloads: 29 times

ai.Vixra.org is a AI assisted e-print repository rather than a journal. Articles hosted may not yet have been verified by peer-review and should be treated as preliminary. In particular, anything that appears to include financial or legal advice or proposed medical treatments should be treated with due caution. ai.Vixra.org will not be responsible for any consequences of actions that result from any form of use of any documents on this website.

Add your own feedback and questions here:
You are equally welcome to be positive or negative about any paper but please be polite. If you are being critical you must mention at least one specific error, otherwise your comment will be deleted as unhelpful.