rust-lang / rust-lang/rust

Tracking Issue for BTF relocations (btf_relocations)

Open
#160,616 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue I-lang-radar S-tracking-unimplemented T-lang T-libs
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.)

Unresolved Questions
  • How should non-LLVM codegen backends expose equivalent relocation support?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.