Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for used_with_arg #93798

Open
1 of 5 tasks
nikic opened this issue Feb 9, 2022 · 2 comments
Open
1 of 5 tasks

Tracking Issue for used_with_arg #93798

nikic opened this issue Feb 9, 2022 · 2 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikic
Copy link
Contributor

nikic commented Feb 9, 2022

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.
@nikic nikic added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC labels Feb 9, 2022
@joshtriplett
Copy link
Member

An addition to the unresolved questions: should we add both of these, or only add one of them? It may make sense to only have #[used] and #[retain], for instance.

@jsgf
Copy link
Contributor

jsgf commented Oct 27, 2023

Does #[used(linker)] imply #[used(compiler)] or does it mean the symbol is only considered used if it actually makes it past the compiler?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants