Crubit can emit bindings for Rust or C++ libraries so that they can be called from the other language, but these bindings require strict ABI compatibility. To accomplish this, Crubit uses clang
and rustc
as libraries to discover the public APIs of the wrapped libraries, and the ABI that they expose when built (e.g. their function calling conventions, and the memory layout of their structs).
To ensure that the generated bindings are ABI-compatible with the built libraries, Crubit needs to see exactly what the real compiler sees:
-DSOME_DEFINE
or a new version of the compiler can completely change the ABI, or even the API, of a given library. If the compiler sees it, but Crubit does not, the generated bindings will be incorrect...._cc_api.h
or ..._rs_api.rs
) in a source code repository, as they will go out of date. Crubit comes with Bazel integration support to invoke it at build time.-Zrandomize-layout
flag cannot be used without a fixed seed.