Skip to content

Commit e731c4e

Browse files
lqdKobzol
authored andcommitted
Update documentation
1 parent dea2019 commit e731c4e

File tree

3 files changed

+32
-41
lines changed

3 files changed

+32
-41
lines changed

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

+30-4
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,22 @@ coverage measurement. Its use is not recommended.
231231

232232
## link-self-contained
233233

234-
On `windows-gnu`, `linux-musl`, and `wasi` targets, this flag controls whether the
235-
linker will use libraries and objects shipped with Rust instead of those in the system.
236-
It takes one of the following values:
234+
This flag controls whether the linker will use libraries and objects shipped with Rust instead
235+
of those in the system. This allows overriding cases when detection fails or user wants to use shipped
236+
libraries.
237+
238+
You can enable or disable the usage of any self-contained objects using one of the following values:
237239

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

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

244251
## linker
245252

@@ -248,6 +255,25 @@ path to the linker executable. If this flag is not specified, the linker will
248255
be inferred based on the target. See also the [linker-flavor](#linker-flavor)
249256
flag for another way to specify the linker.
250257

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

253279
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

+2-2
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

-35
This file was deleted.

0 commit comments

Comments
 (0)