{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreicqt3deszcnhqql6ifuo76ic4phwgwb6kucgc52h5sf7e6wydaqvu",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mj6mkddrori2"
  },
  "path": "/t/pre-rfc-btf-relocations/24161#post_13",
  "publishedAt": "2026-04-10T23:52:23.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "https://github.com/rust-lang/rfcs/pull/3762",
    "one of the posts you linked",
    "Swift stable ABI"
  ],
  "textContent": "vad:\n\n> Because the `offset_of` intrinsic is `const`:\n>\n>\n>     pub const fn offset_of<T: PointeeSized>(variant: u32, field: u32) -> usize;\n>\n>\n> and I'm under the impression that we want to treat BTF-relocatable field access as non-`const`.\n\nPresumably, the intrinsic would become conditionally `const` (leveraging https://github.com/rust-lang/rfcs/pull/3762).\n\nvad:\n\n> It's not strictly necessary, because matching container type, its name and matching field name are sufficient for the relocation to work.\n\nIn one of the posts you linked, I see mention of version suffixes in the names, which are ignored for relocations. Should that mechanism work in Rust as well? (If not, then an alternative mechanism, e.g. attribute, is presumably necessary.)\n\nvad:\n\n> Jules-Bertholet:\n>\n>> Is there any connection to/similarity with Swift stable ABI?\n>\n> Not really. Actually I don't even think Rust ABI should be used for BTF relocatable types. `#[repr(btf)]` should enforce the C ABI, I'm going to update the RFC and examples accordingly.\n\nTo clarify the point I was driving at: Swift's ABI supports making limited changes to struct layouts while preserving compatibility, so it's conceptually similar to BTF relocations. I was wondering if any new syntax or high-level language APIs we add to support BTF relocations, could also be leveraged to support Swift interop—even if the backend implementation is very different.\n\nvad:\n\n> But if the relocated access still stays within some valid memory region while pointing to the wrong field, then this can become a silent logic bug instead.\n\nLogic bug, or UB?",
  "title": "[Pre-RFC] BTF relocations"
}