Skip to content

Commit 03549d3

Browse files
committed
Ditch the fallback mechanism
It's better to emit a compile error.
1 parent 19baf0b commit 03549d3

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

text/0000-btf-relocations.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ The offset returned for a nested path is relative to the root carrier type,
229229

230230
On BPF targets with BTF-capable backend support and debug info enabled, these
231231
queries lower to CO-RE relocations. On targets or backends without BTF
232-
relocation support, they fall back to the current compilation unit's ordinary
233-
layout information.
232+
relocation support, they emit a compile error.
234233

235234
## Reference-level explanation
236235
[reference-level-explanation]: #reference-level-explanation
@@ -258,9 +257,7 @@ kinds.
258257

259258
A `#[repr(Btf)]` type uses C-compatible field layout. In compiler terms,
260259
`repr(Btf)` implies the layout constraints of `repr(C)` and also marks the type
261-
as BTF-relocatable. This gives the backend stable field ordering and offsets for
262-
the compile-time fallback while preserving a distinct marker for type checking
263-
and codegen.
260+
as BTF-relocatable.
264261

265262
Direct field projection from a `#[repr(Btf)]` ADT is rejected. This includes
266263
projections reached through autoderef:
@@ -334,18 +331,10 @@ The result of the LLVM intrinsic is an integer value. Offset and size queries
334331
are zero-extended to `usize`. Existence queries are compared against zero and
335332
return `bool`.
336333

337-
If the target, backend, or codegen mode cannot emit BTF field relocations, the
338-
field-info queries fall back to ordinary layout-computed values:
339-
340-
* `field_byte_offset!` returns the complete field-path offset from the
341-
current compilation layout.
342-
* `field_byte_size!` returns the field size from the current compilation
343-
layout.
344-
* `field_exists!` returns `true` for a field path present in the current
345-
compilation layout.
346-
347334
BTF CO-RE relocation emission is only meaningful for BPF targets, and it
348-
requires the debug metadata used to describe the relevant types.
335+
requires the debug metadata used to describe the relevant types. If the target,
336+
backend, or codegen mode cannot emit BTF field relocations, a compile error
337+
should be emitted.
349338

350339
## Drawbacks
351340
[drawbacks]: #drawbacks

0 commit comments

Comments
 (0)