-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Tracking Issue for used_with_arg
#93798
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
Comments
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 |
Does |
How can I help bringing this forward? |
Just an experience report: we use Because this is an OS, we don't use the standard Rust test runner, but implement our own. The macro used to generate test cases uses |
Make #[used(linker)] the default on ELF too `#[used]` currently is an alias for `#[used(linker)]` on all platforms except ELF based ones where it is an alias for `#[used(compiler)]`. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." [^2] The reason `#[used]` still was an alias to `#[used(compiler)]` on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold. This would also allow re-enabling start-stop-gc with lld. cc #93798 Likely fixes #85045 [^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html [^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable [^3]: #139425
Make #[used(linker)] the default on ELF too `#[used]` currently is an alias for `#[used(linker)]` on all platforms except ELF based ones where it is an alias for `#[used(compiler)]`. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." [^2] The reason `#[used]` still was an alias to `#[used(compiler)]` on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold. This would also allow re-enabling start-stop-gc with lld. cc rust-lang/rust#93798 Likely fixes rust-lang/rust#85045 [^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html [^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable [^3]: rust-lang/rust#139425
Make #[used(linker)] the default on ELF too `#[used]` currently is an alias for `#[used(linker)]` on all platforms except ELF based ones where it is an alias for `#[used(compiler)]`. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." [^2] The reason `#[used]` still was an alias to `#[used(compiler)]` on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold. This would also allow re-enabling start-stop-gc with lld. cc rust-lang/rust#93798 Likely fixes rust-lang/rust#85045 [^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html [^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable [^3]: rust-lang/rust#139425
Make #[used(linker)] the default on ELF too `#[used]` currently is an alias for `#[used(linker)]` on all platforms except ELF based ones where it is an alias for `#[used(compiler)]`. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." [^2] The reason `#[used]` still was an alias to `#[used(compiler)]` on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold. This would also allow re-enabling start-stop-gc with lld. cc rust-lang/rust#93798 Likely fixes rust-lang/rust#85045 [^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html [^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable [^3]: rust-lang/rust#139425
Uh oh!
There was an error while loading. Please reload this page.
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)]
:#[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.#[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
#[used(linker)]
attribute #91504Unresolved Questions
#[used]
default to? It is currently specified to only guarantee#[used(compiler)]
but has historically acted like#[used(linker)]
on non-ELF platforms. Seeno_mangle
/used
static is only present in output when in reachable module #47384 for extended discussion on the topic.#[used(linker)]
currently uses SHF_GNU_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.#[used(linker)]
imply#[used(compiler)]
or does it mean the symbol is only considered used if it actually makes it past the compiler?The text was updated successfully, but these errors were encountered: