`#[used(linker)]` is broken on illumos
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
On illumos, #[used(linker)] generates the section flag 0x100000, which is known as SHF_SUNW_NODISCARD on Solaris, but unknown to illumos. This causes incorrect behavior when used in combination with .init_array, for example by inventory.
This regressed in https://github.com/rust-lang/rust/pull/140872 which made #[used] mean #[used(linker)] on all ELF targets, including illumos.
See
- Original investigation by @MarceColl on this issue: https://system-illumination.org/01-rustler.html
- discussed on lobste.rs: https://lobste.rs/s/nr8kkd/debugging_rustler_on_illumos
- Attempt to work-around in the
inventorycrate: https://github.com/dtolnay/inventory/pull/84
- LLVM change to start using
SHF_SUNW_NODISCARDon Solaris: https://reviews.llvm.org/D107955#:~:text=One,them - LLVM change related to retained section behavior: https://reviews.llvm.org/D97448
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing rust-lang/rust#140872 and the handling of #[used(linker)] for ELF targets, then compare illumos with Solaris and the LLVM changes linked in the issue. Check the inventory workaround and retained-section behavior; done means #[used(linker)] no longer produces incorrect .init_array behavior on illumos.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100