GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

Codegen compiles extern types as C void

Rust extern types are compiled to C void, aligning with RFC 1861 for FFI safety.

This change modifies the GCC Rust frontend to compile extern types as C’s void type. RFC 1861 specifies that extern types are dynamically sized and FFI-safe, requiring them to be treated as C void. This ensures correct handling and compatibility for these types when interacting with C code.

In Details

The Rust frontend's codegen for extern types has been updated to emit the void type node instead of an empty struct. This aligns with RFC 1861, which mandates that extern types (dynamically sized, FFI-safe) are represented like C's void. This change is primarily in rust-compile-type.cc and impacts how extern types are translated into LLVM IR.

For Context
extern types
Rust types that are opaque to the Rust compiler, meaning their size and layout are not known at compile time. They are primarily used for Foreign Function Interface (FFI) purposes and are often dynamically sized.
RFC 1861
A Rust language proposal (Request for Comments) that defines the semantics and behavior of extern types, including their FFI compatibility and compilation model.
C void
In C, the void type represents the absence of a type. It's often used for functions that do not return a value or for generic pointers. In this context, it's used as a representation for dynamically sized types.
FFI
Foreign Function Interface. A mechanism that allows a program written in one language to call functions or use data defined in another language. In this case, it refers to Rust interacting with C code.
Filed Under: rustcodegenffitypes