@@ -235,15 +235,22 @@ coverage measurement. Its use is not recommended.
235
235
236
236
## link-self-contained
237
237
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:
241
243
242
244
* no value: rustc will use heuristic to disable self-contained mode if system has necessary tools.
243
245
* ` y ` , ` yes ` , ` on ` , ` true ` : use only libraries/objects shipped with Rust.
244
246
* ` n ` , ` no ` , ` off ` or ` false ` : rely on the user or the linker to provide non-Rust libraries/objects.
245
247
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)
247
254
248
255
## linker
249
256
@@ -256,6 +263,25 @@ Note that on Unix-like targets (for example, `*-unknown-linux-gnu` or `*-unknown
256
263
the C compiler (for example ` cc ` or ` clang ` ) is used as the "linker" here, serving as a linker driver.
257
264
It will invoke the actual linker with all the necessary flags to be able to link against the system libraries like libc.
258
265
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
+
259
285
## linker-flavor
260
286
261
287
This flag controls the linker flavor used by ` rustc ` . If a linker is given with
0 commit comments