@@ -125,6 +125,15 @@ specifies the kind of library with the following possible values:
125
125
126
126
The ` name ` key must be included if ` kind ` is specified.
127
127
128
+ The optional ` modifiers ` argument is a way to specify linking modifiers for the
129
+ library to link.
130
+ Modifiers are specified as a comma-delimited string with each modifier prefixed
131
+ with either a ` + ` or ` - ` to indicate that the modifier is enabled or disabled,
132
+ respectively.
133
+ Specifying multiple ` modifiers ` arguments in a single ` link ` attribute,
134
+ or multiple identical modifiers in the same ` modifiers ` argument is not currently supported. \
135
+ Example: ` #[link(name = "mylib", kind = "static", modifiers = "+whole-archive") ` .
136
+
128
137
The ` wasm_import_module ` key may be used to specify the [ WebAssembly module]
129
138
name for the items within an ` extern ` block when importing symbols from the
130
139
host environment. The default module name is ` env ` if ` wasm_import_module ` is
@@ -153,6 +162,16 @@ this to satisfy the linking requirements of extern blocks elsewhere in your
153
162
code (including upstream crates) instead of adding the attribute to each extern
154
163
block.
155
164
165
+ #### Linking modifiers: ` whole-archive `
166
+
167
+ This modifier is only compatible with the ` static ` linking kind.
168
+ Using any other kind will result in a compiler error.
169
+
170
+ ` +whole-archive ` means that the static library is linked as a whole archive
171
+ without throwing any object files away.
172
+
173
+ More implementation details about this modifier can be found in [ documentation for rustc] .
174
+
156
175
### The ` link_name ` attribute
157
176
158
177
The ` link_name ` attribute may be specified on declarations inside an ` extern `
@@ -186,3 +205,4 @@ restrictions as [regular function parameters].
186
205
[ _Visibility_ ] : ../visibility-and-privacy.md
187
206
[ attributes ] : ../attributes.md
188
207
[ regular function parameters ] : functions.md#attributes-on-function-parameters
208
+ [ documentation for rustc ] : ../../rustc/command-line-arguments.html#linking-modifiers-whole-archive
0 commit comments