@@ -83,13 +83,16 @@ but it could be changed later on some future edition boundary.
83
83
84
84
### ` verbatim `
85
85
86
- ` +verbatim ` means that ` rustc ` won't add any target-specified library prefixes or suffixes
87
- (like ` lib ` or ` .a ` ) to the library name.
86
+ ` +verbatim ` means that ` rustc ` itself won't add any target-specified library prefixes or suffixes
87
+ (like ` lib ` or ` .a ` ) to the library name,
88
+ and will try its best to ask for the same thing from the linker.
88
89
89
90
For ` ld ` -like linkers ` rustc ` will use the ` -l:filename ` syntax (note the colon)
90
91
when passing the library, so the linker won't add any prefixes or suffixes as well. \
91
92
See [ ` -l namespec ` ] ( https://sourceware.org/binutils/docs/ld/Options.html ) in ` ld ` documentation
92
- for more details.
93
+ for more details. \
94
+ For linkers not supporting any verbatim modifiers (e.g. ` link.exe ` or ` ld64 ` )
95
+ the library name will be passed as is.
93
96
94
97
The default for this modifier is ` -verbatim ` .
95
98
@@ -107,23 +110,32 @@ Only compatible with the `static` linking kind.
107
110
without throwing any object files away.
108
111
109
112
This modifier translates to ` --whole-archive ` for ` ld ` -like linkers,
110
- and to ` /WHOLEARCHIVE ` for ` link.exe ` .
113
+ to ` /WHOLEARCHIVE ` for ` link.exe ` , and to ` -force_load ` for ` ld64 ` . \
114
+ The modifier does nothing for linkers that don't support it.
111
115
112
116
The default for this modifier is ` -whole-archive ` .
113
117
118
+ A motivating example for this modifier can be found in
119
+ [ issue #56306 ] ( https://github.com/rust-lang/rust/issues/56306 ) .
120
+
114
121
### ` as-needed `
115
122
116
- Only compatible with the ` dynamic ` linking kind .
123
+ Only compatible with the ` dynamic ` and ` framework ` linking kinds .
117
124
118
125
` +as-needed ` means that the library will be actually linked only if it satisfies some
119
126
undefined symbols at the point at which it is specified on the command line,
120
127
making it similar to static libraries in this regard.
121
128
122
- This modifier translates to ` --as-needed ` for ` ld ` -like linkers.
129
+ This modifier translates to ` --as-needed ` for ` ld ` -like linkers,
130
+ and to ` -dead_strip_dylibs ` / ` -needed_library ` / ` -needed_framework ` for ` ld64 ` . \
131
+ The modifier does nothing for linkers that don't support it (e.g. ` link.exe ` ).
123
132
124
133
The default for this modifier is unclear, some targets currently specify it as ` +as-needed ` ,
125
134
some do not. We may want to try making ` +as-needed ` a default for all targets.
126
135
136
+ A motivating example for this modifier can be found in
137
+ [ issue #57837 ] ( https://github.com/rust-lang/rust/issues/57837 ) .
138
+
127
139
## Stability story
128
140
129
141
The modifier syntax can be stabilized independently from any specific modifiers.
@@ -180,6 +192,14 @@ regarding this, see the `LINKER:` modifier for
180
192
Relying on raw linker options while linking with attributes will requires introducing
181
193
a new attribute, see the paragraph about ` #[link(arg = "string")] ` in "Future possibilities".
182
194
195
+ ## Alternative: merge modifiers into kind in attributes
196
+
197
+ ` #[link(kind = "static", modifiers = "+foo,-bar")] ` -> ` #[link(kind = "static:+foo,-bar")] ` .
198
+
199
+ This make attributes closer to command line, but it's unclear whether it's a goal we want to pursue.
200
+ For example, we already write ` kind=name ` on command line,
201
+ but ` kind = "...", name = "..." ` in attributes.
202
+
183
203
# Prior art
184
204
[ prior-art ] : #prior-art
185
205
@@ -195,7 +215,7 @@ so it is not as relevant to modifying behavior of specific libraries as with `ld
195
215
# Unresolved questions
196
216
[ unresolved-questions ] : #unresolved-questions
197
217
198
- What about the ` framework ` linking kind? What does it mean? What modifiers is it compatible with?
218
+ None currently.
199
219
200
220
# Future possibilities
201
221
[ future-possibilities ] : #future-possibilities
0 commit comments