Skip to content

Commit 0cd078d

Browse files
authored
Merge pull request #1210 from petrochenkov/linkmod
Document native library modifier `bundle`
2 parents 683bfe5 + 1c78b74 commit 0cd078d

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/items/external-blocks.md

+29-2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ this to satisfy the linking requirements of extern blocks elsewhere in your
162162
code (including upstream crates) instead of adding the attribute to each extern
163163
block.
164164

165+
#### Linking modifiers: `bundle`
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+
When building a rlib or staticlib `+bundle` means that all object files from the native static
171+
library will be added to the rlib or staticlib archive, and then used from it during linking of
172+
the final binary.
173+
174+
When building a rlib `-bundle` means that the native static library is registered as a dependency
175+
of that rlib "by name", and object files from it are included only during linking of the final
176+
binary, the file search by that name is also performed during final linking. \
177+
When building a staticlib `-bundle` means that the native static library is simply not included
178+
into the archive and some higher level build system will need to add it later during linking of
179+
the final binary.
180+
181+
This modifier has no effect when building other targets like executables or dynamic libraries.
182+
183+
The default for this modifier is `+bundle`.
184+
185+
More implementation details about this modifier can be found in
186+
[`bundle` documentation for rustc].
187+
165188
#### Linking modifiers: `whole-archive`
166189

167190
This modifier is only compatible with the `static` linking kind.
@@ -170,7 +193,10 @@ Using any other kind will result in a compiler error.
170193
`+whole-archive` means that the static library is linked as a whole archive
171194
without throwing any object files away.
172195

173-
More implementation details about this modifier can be found in [documentation for rustc].
196+
The default for this modifier is `-whole-archive`.
197+
198+
More implementation details about this modifier can be found in
199+
[`whole-archive` documentation for rustc].
174200

175201
### The `link_name` attribute
176202

@@ -205,4 +231,5 @@ restrictions as [regular function parameters].
205231
[_Visibility_]: ../visibility-and-privacy.md
206232
[attributes]: ../attributes.md
207233
[regular function parameters]: functions.md#attributes-on-function-parameters
208-
[documentation for rustc]: ../../rustc/command-line-arguments.html#linking-modifiers-whole-archive
234+
[`bundle` documentation for rustc]: ../../rustc/command-line-arguments.html#linking-modifiers-bundle
235+
[`whole-archive` documentation for rustc]: ../../rustc/command-line-arguments.html#linking-modifiers-whole-archive

0 commit comments

Comments
 (0)