rust-lang / rust-lang/rust

`#[used(linker)]` is broken on illumos

Open
#146,169 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug O-illumos T-compiler
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.