Skip to content

Commit 23c438d

Browse files
committed
update documentation
1 parent 23a9fa6 commit 23c438d

File tree

3 files changed

+32
-41
lines changed

3 files changed

+32
-41
lines changed

src/doc/rustc/src/codegen-options/index.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,22 @@ coverage measurement. Its use is not recommended.
235235

236236
## link-self-contained
237237

238-
On `windows-gnu`, `linux-musl`, and `wasi` targets, this flag controls whether the
239-
linker will use libraries and objects shipped with Rust instead of those in the system.
240-
It takes one of the following values:
238+
This flag controls whether the linker will use libraries and objects shipped with Rust instead of
239+
those in the system. It also controls which binary is used for the linker itself. This allows
240+
overriding cases when detection fails or the user wants to use shipped libraries.
241+
242+
You can enable or disable the usage of any self-contained components using one of the following values:
241243

242244
* no value: rustc will use heuristic to disable self-contained mode if system has necessary tools.
243245
* `y`, `yes`, `on`, `true`: use only libraries/objects shipped with Rust.
244246
* `n`, `no`, `off` or `false`: rely on the user or the linker to provide non-Rust libraries/objects.
245247

246-
This allows overriding cases when detection fails or user wants to use shipped libraries.
248+
It is also possible to enable or disable specific self-contained components in a more granular way.
249+
You can pass a comma-separated list of self-contained components, individually enabled
250+
(`+component`) or disabled (`-component`).
251+
252+
Currently, only the `linker` granular option is stabilized:
253+
- `linker`: toggle the usage of self-contained linker binaries (linker, dlltool, and their necessary libraries)
247254

248255
## linker
249256

@@ -256,6 +263,25 @@ Note that on Unix-like targets (for example, `*-unknown-linux-gnu` or `*-unknown
256263
the C compiler (for example `cc` or `clang`) is used as the "linker" here, serving as a linker driver.
257264
It will invoke the actual linker with all the necessary flags to be able to link against the system libraries like libc.
258265

266+
## linker-features
267+
268+
The `-Clinker-features` flag allows enabling or disabling specific features used during linking.
269+
270+
These feature flags are a flexible extension mechanism that is complementary to linker flavors,
271+
designed to avoid the combinatorial explosion of having to create a new set of flavors for each
272+
linker feature we'd want to use.
273+
274+
The flag accepts a comma-separated list of features, individually enabled (`+feature`) or disabled
275+
(`-feature`).
276+
277+
Currently only one is stable, and only on the `x86_64-unknown-linux-gnu` target:
278+
- `lld`: to toggle using the lld linker, either the system-installed binary, or the self-contained
279+
`rust-lld` linker (via the `-Clink-self-contained=+linker` flag).
280+
281+
For example, use:
282+
- `-Clinker-features=+lld` to opt in to using the `lld` linker
283+
- `-Clinker-features=-lld` to opt out instead, for targets where it is configured as the default linker
284+
259285
## linker-flavor
260286

261287
This flag controls the linker flavor used by `rustc`. If a linker is given with

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ instead of those in the system. The stable boolean values for this flag are coar
5151
- `mingw`: other MinGW libs and Windows import libs
5252

5353
Out of the above self-contained linking components, `linker` is the only one currently implemented
54-
(beyond parsing the CLI options).
54+
(beyond parsing the CLI options) and stabilized.
5555

5656
It refers to the LLD linker, built from the same LLVM revision used by rustc (named `rust-lld` to
5757
avoid naming conflicts), that is distributed via `rustup` with the compiler (and is used by default
58-
for the wasm targets). One can also opt-in to use it by combining this flag with an appropriate
58+
for the wasm targets). One can also opt in to use it by combining this flag with an appropriate
5959
linker flavor: for example, `-Clinker-flavor=gnu-lld-cc -Clink-self-contained=+linker` will use the
6060
toolchain's `rust-lld` as the linker.

src/doc/unstable-book/src/compiler-flags/linker-features.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)