Tracking Issue for BTF relocations (btf_relocations)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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.
Public API
// 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>.
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- Lang experiment championed by @traviscross: https://github.com/rust-lang/rfcs/pull/3966#issuecomment-5190984186
- RFC: rust-lang/rfcs#3966
- ACP: rust-lang/libs-team#846
- Implementation: #...
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- How should non-LLVM codegen backends expose equivalent relocation support?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with rust-lang/rfcs#3966 and the linked libs-team ACP, then review the current btf_relocations implementation against the core::btf macros and LLVM BPF/debug-info constraints. There is no single defined completion point: the checklist still covers RFC, ACP, implementation, FCP, and stabilization, with non-LLVM backend support unresolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100