Folkert de Vriesfolkertdev@hachyderm.io
Apr 15, 2026, 12:24 PMOn rust nightly you can now cfg on the current object format
https://github.com/rust-lang/rust/pull/155126
This is useful for e.g. selecting the right section name for #[link_section = "..."] and more generally for inline assembly and linker shenanigans.
![a code snippet using target_object_format:
#[unsafe(link_section = cfg_select!(
target_object_format = "mach-o" => "__TEXT,foobar",
_ => ".foobar",
))]
#[unsafe(no_mangle)]
extern "C" fn foo() {}](https://techdon.dev/system/cache/media_attachments/files/116/409/420/050/312/892/small/78dd935913d9a6c9.png)