Skip to content

Commit 9e2e17c

Browse files
linkage: Add a note about symbol visibility and unused sections to the paragraph about staticlibs
Fixes rust-lang/rust#111593
1 parent a2a3b05 commit 9e2e17c

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
@@ -47,6 +47,16 @@ be ignored in favor of only building the artifacts specified by command line.
4747
linking Rust code into an existing non-Rust application
4848
because it will not have dynamic dependencies on other Rust code.
4949

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

0 commit comments

Comments
 (0)