@@ -245,9 +245,16 @@ It is also possible to enable or disable specific self-contained components in a
245
245
You can pass a comma-separated list of self-contained components, individually enabled
246
246
(` +component ` ) or disabled (` -component ` ).
247
247
248
- Currently, only the ` linker ` granular option is stabilized:
248
+ Currently, only the ` linker ` granular option is stabilized, and only on the ` x86_64-unknown-linux-gnu ` target :
249
249
- ` linker ` : toggle the usage of self-contained linker binaries (linker, dlltool, and their necessary libraries)
250
250
251
+ #### Implementation notes
252
+
253
+ On the ` x86_64-unknown-linux-gnu ` target, when using the default linker flavor (using ` cc ` as the
254
+ linker driver) and linker features (to try using ` lld ` ), ` rustc ` will try to use the self-contained
255
+ linker by passing a ` -B /path/to/sysroot/ ` link argument to the driver to find ` rust-lld ` in the
256
+ sysroot.
257
+
251
258
## linker
252
259
253
260
This flag controls which linker ` rustc ` invokes to link your code. It takes a
@@ -267,13 +274,24 @@ The flag accepts a comma-separated list of features, individually enabled (`+fea
267
274
(` -feature ` ).
268
275
269
276
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).
277
+ - ` lld ` : to toggle trying to use the lld linker, either the system-installed binary, or the self-contained
278
+ ` rust-lld ` linker (via the [ ` -Clink-self-contained=+linker ` ] [ #link-self-contained ] flag).
272
279
273
280
For example, use:
274
- - ` -Clinker-features=+lld ` to opt in to using the ` lld ` linker
281
+ - ` -Clinker-features=+lld ` to opt into using the ` lld ` linker, when possible (see the Implementation notes below)
275
282
- ` -Clinker-features=-lld ` to opt out instead, for targets where it is configured as the default linker
276
283
284
+ #### Implementation notes
285
+
286
+ On the ` x86_64-unknown-linux-gnu ` target, when using the default linker flavor (using ` cc ` as the
287
+ linker driver), ` rustc ` will try to use lld by passing a ` -fuse-ld=lld ` link argument to the driver.
288
+ ` rustc ` will also try to detect if that _ causes_ an error during linking (for example, if GCC is too
289
+ old to understand the flag, and returns an error) and will then retry linking without this argument,
290
+ as a fallback.
291
+
292
+ If the user _ also_ passes a ` -Clink-arg=-fuse-ld=$value ` , both will be given to the linker
293
+ driver but the user's will be passed last, and would generally have priority over ` rustc ` 's.
294
+
277
295
## linker-flavor
278
296
279
297
This flag controls the linker flavor used by ` rustc ` . If a linker is given with
0 commit comments