Skip to content

Commit d39324b

Browse files
committed
describe unstable self-contained linking components in the unstable book
1 parent 8560c67 commit d39324b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/doc/unstable-book/src/compiler-flags/codegen-options.md

+24
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,27 @@ the goal is for them to become stable, and preferred in practice over the existi
3030
- `unix-cc`: `unix` using a C/C++ compiler as the linker driver
3131
- `msvc-lld`: MSVC-style linker for Windows and UEFI, with LLD
3232
- `em-cc`: emscripten compiler frontend, similar to `wasm-lld-cc` with a different interface
33+
34+
## link-self-contained
35+
36+
This flag generally controls whether the linker will use libraries and objects shipped with Rust
37+
instead of those in the system. The stable boolean values for this flag are coarse-grained
38+
(everything or nothing), but there exists a set of unstable values with finer-grained control,
39+
`-Clink-self-contained` can accept a comma-separated list of components, individually enabled
40+
(`+component`) or disabled (`-component`):
41+
- `crto`: CRT objects (e.g. on `windows-gnu`, `musl`, `wasi` targets)
42+
- `libc`: libc static library (e.g. on `musl`, `wasi` targets)
43+
- `unwind`: libgcc/libunwind (e.g. on `windows-gnu`, `fuchsia`, `fortanix`, `gnullvm` targets)
44+
- `linker`: linker, dlltool, and their necessary libraries (e.g. on `windows-gnu` and for
45+
`rust-lld`)
46+
- `sanitizers`: sanitizer runtime libraries
47+
- `mingw`: other MinGW libs and Windows import libs
48+
49+
Out of the above self-contained linking components, `linker` is the only one currently implemented
50+
(beyond parsing the CLI options).
51+
52+
It refers to the LLD linker, built from the same LLVM revision used by rustc (named `rust-lld` to
53+
avoid naming conflicts), that is distributed via `rustup` with the compiler (and is used by default
54+
for the wasm targets). One can also opt-in to use it by combining this flag with an appropriate
55+
linker flavor: for example, `-Clinker-flavor=gnu-lld-cc -Clink-self-contained=+linker` will use the
56+
toolchain's `rust-lld` as the linker.

0 commit comments

Comments
 (0)