Skip to content

Commit 0b18ee6

Browse files
authored
Merge pull request #1361 from sdroege/staticlib-gc-sections-symbol-visibility
linkage: Add a note about symbol visibility and unused sections to the paragraph about staticlibs
2 parents da188bd + a4dd053 commit 0b18ee6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/linkage.md

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ be ignored in favor of only building the artifacts specified by command line.
5252
compiled as dynamic libraries) will have to be specified manually when
5353
linking that static library from somewhere. The `--print=native-static-libs` flag may help with this.
5454

55+
Note that, because the resulting static library contains the code of all the
56+
dependencies, including the standard library, and also exports all public
57+
symbols of them, linking the static library into an executable or shared
58+
library may need special care. In case of a shared library the list of
59+
exported symbols will have to be limited via e.g. a linker or symbol version
60+
script, exported symbols list (macOS), or module definition file (Windows).
61+
Additionally, unused sections can be removed to remove all code of
62+
dependencies that is not actually used (e.g. `--gc-sections` or `-dead_strip`
63+
for macOS).
64+
5565
* `--crate-type=cdylib`, `#![crate_type = "cdylib"]` - A dynamic system
5666
library will be produced. This is used when compiling
5767
a dynamic library to be loaded from another language. This output type will

0 commit comments

Comments
 (0)