bjorn3 opened issue #10758:
Feature
See title.
Benefit
This is required for implementing
#[used(linker)]in cg_clif. This attribute is equivalent toattribute((used))in C. And on all non-ELF platforms it is the default. when#[used]is used. On ELF platforms it may become the default in the future.Implementation
Add a flag to DataDescription and then set the right symbol flag for the given object file format.
alexcrichton added the cranelift label to Issue #10758.
Noratrieb commented on issue #10758:
Note that
#[used(linker)]is__attribute__((used,retain)), not__attribute__((used)), which is just#[used(compiler)].
| | Compiler | Linker |
|------|-------------------------|-----------------------------------------------------|
| C |__attribute__((used))|__attribute__((retain))(note that you need both) |
| Rust |#[used(compiler)]|#[used(linker)]|
| LLVM |@llvm.compiler.used|@llvm.used|
| ELF | - |SHT_GNU_RETAIN("R"in Assembly) |
Noratrieb edited a comment on issue #10758:
Note that
#[used(linker)]is__attribute__((used,retain)), not__attribute__((used)), which is just#[used(compiler)].
| | Compiler | Linker |
|------|-------------------------|-----------------------------------------------------|
| GCC C |__attribute__((used))|__attribute__((retain))(note that you need both) |
| Rust |#[used(compiler)]|#[used(linker)]|
| LLVM |@llvm.compiler.used|@llvm.used|
| ELF | - |SHT_GNU_RETAIN("R"in Assembly) |
bjorn3 commented on issue #10758:
https://github.com/bytecodealliance/wasmtime/pull/11206 implements this on the Cranelift side and https://github.com/rust-lang/rustc_codegen_cranelift/tree/used_static has the cg_clif changes.
abrown closed issue #10758:
Feature
See title.
Benefit
This is required for implementing
#[used(linker)]in cg_clif. This attribute is equivalent toattribute((used))in C. And on all non-ELF platforms it is the default. when#[used]is used. On ELF platforms it may become the default in the future.Implementation
Add a flag to DataDescription and then set the right symbol flag for the given object file format.
Last updated: Dec 06 2025 at 07:03 UTC