@@ -125,6 +125,13 @@ 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 ` key 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. The last boolean value specified for a given modifier wins. \
133+ Example: ` #[link(name = "mylib", kind = "static", modifiers = "+whole-archive") ` .
134+
128135The ` wasm_import_module ` key may be used to specify the [ WebAssembly module]
129136name for the items within an ` extern ` block when importing symbols from the
130137host environment. The default module name is ` env ` if ` wasm_import_module ` is
@@ -153,6 +160,22 @@ this to satisfy the linking requirements of extern blocks elsewhere in your
153160code (including upstream crates) instead of adding the attribute to each extern
154161block.
155162
163+ #### Linking modifiers: ` whole-archive `
164+
165+ This modifier is only compatible with the ` static ` linking kind.
166+ Using any other kind will result in a compiler error.
167+
168+ ` +whole-archive ` means that the static library is linked as a whole archive
169+ without throwing any object files away.
170+
171+ This modifier translates to ` --whole-archive ` for ` ld ` -like linkers,
172+ to ` /WHOLEARCHIVE ` for ` link.exe ` , and to ` -force_load ` for ` ld64 ` .
173+ The modifier does nothing for linkers that don't support it.
174+
175+ The default for this modifier is ` -whole-archive ` . \
176+ NOTE: The default may currently be different when building dylibs for some targets,
177+ but it is not guaranteed.
178+
156179### The ` link_name ` attribute
157180
158181The ` link_name ` attribute may be specified on declarations inside an ` extern `
0 commit comments