rust-lang / rust · Issue No. 160616
Feature gate: #![feature(btf_relocations)]
This is a tracking issue for experimental BPF Type Format (BTF) Compile Once, Run Everywhere (CO-RE) relocation support, as proposed in rust-lang/rfcs#3966.
The feature introduces #[btf_relocatable] for structs and unions that model external BTF types. Ordinary field projection and offset_of! are rejected for these types because they would produce fixed offsets without preserving the field identity needed for CO-RE relocation.
The feature also provides BTF-aware field metadata queries through core::btf. These queries return Option<usize> so programs can account for fields that do not exist in the target BTF.
The current implementation supports LLVM BPF targets and requires debug info. Unsupported targets, backends, and codegen configurations produce a compile error.
// core::btf
pub macro field_byte_offset($Carrier:ty, $($fields:expr)+ $(,)?);
pub macro field_byte_size($Carrier:ty, $($fields:expr)+ $(,)?);
Both macros expand to an expression of type Option<usize>.
(Remember to update the S-tracking-* label when checking boxes.)
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.