Skip to content

Commit c198d98

Browse files
authored
abi.md: clarify #[used] and linking
I originally interpreted this paragraph to mean `rustc` would also instruct the linker to keep the symbol, given that . [This is not the case](https://github.com/rust-lang/rfcs/blob/master/text/2386-used.md#guide-level-explanation).
1 parent 6a04611 commit c198d98

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/abi.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ linking external libraries.
1010
## The `used` attribute
1111

1212
The *`used` attribute* can only be applied to [`static` items]. This [attribute] forces the
13-
compiler to keep the variable in the output object file (.o, .rlib, etc.) even if the variable is
14-
not used, or referenced, by any other item in the crate.
13+
compiler to keep the variable in the output object file (.o, .rlib, etc. excluding final binaries)
14+
even if the variable is not used, or referenced, by any other item in the crate.
15+
However, the linker is still free to remove such an item.
1516

1617
Below is an example that shows under what conditions the compiler keeps a `static` item in the
1718
output object file.

0 commit comments

Comments
 (0)