Skip to content

Tracking Issue for used_with_arg #93798

Open
@nikic

Description

@nikic

The feature gate for the issue is #![feature(used_with_arg)].

This extends the existing #[used] attribute with two variants #[used(compiler)] and #[used(linker)]:

  • The #[used(compiler)] attribute indicates that the symbol should be considered used at the compiler level. It should not be eliminated by the compiler even if it appears unreferenced. This attribute guarantees that the symbol will make it to the linker.
  • The #[used(linker)] attribute indicates that the symbol should additionally be considered used at the linker level. The linker should not eliminate the symbol even if it appears unreferenced.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

  • What should #[used] default to? It is currently specified to only guarantee #[used(compiler)] but has historically acted like #[used(linker)] on non-ELF platforms. See no_mangle/used static is only present in output when in reachable module #47384 for extended discussion on the topic.
  • #[used(linker)] currently uses SHF_RETAIN on ELF platforms, which is a relatively new flag. This means that the symbol may not actually be retained if an old linker is used.
  • Does #[used(linker)] imply #[used(compiler)] or does it mean the symbol is only considered used if it actually makes it past the compiler?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-used_with_arg`#![feature(used_with_arg)]`S-tracking-design-concernsStatus: There are blocking design concerns.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions