@@ -125,6 +125,15 @@ specifies the kind of library with the following possible values:
125125
126126The ` name ` key must be included if ` kind ` is specified.
127127
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+
128137The ` wasm_import_module ` key may be used to specify the [ WebAssembly module]
129138name for the items within an ` extern ` block when importing symbols from the
130139host 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
153162code (including upstream crates) instead of adding the attribute to each extern
154163block.
155164
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+
156175### The ` link_name ` attribute
157176
158177The ` link_name ` attribute may be specified on declarations inside an ` extern `
@@ -186,3 +205,4 @@ restrictions as [regular function parameters].
186205[ _Visibility_ ] : ../visibility-and-privacy.md
187206[ attributes ] : ../attributes.md
188207[ regular function parameters ] : functions.md#attributes-on-function-parameters
208+ [ documentation for rustc ] : https://doc.rust-lang.org/rustc/command-line-arguments.html#-l-link-the-generated-crate-to-a-native-library
0 commit comments