@@ -245,9 +245,17 @@ 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. For backwards-compatibility, and to limit name and ` PATH ` collisions, this is done using a
257
+ shim executable (the ` lld-wrapper ` tool) that forwards execution to the ` rust-lld ` executable itself.
258
+
251
259
## linker
252
260
253
261
This flag controls which linker ` rustc ` invokes to link your code. It takes a
@@ -267,13 +275,24 @@ The flag accepts a comma-separated list of features, individually enabled (`+fea
267
275
(` -feature ` ).
268
276
269
277
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).
278
+ - ` lld ` : to toggle trying to use the lld linker, either the system-installed binary, or the self-contained
279
+ ` rust-lld ` linker (via the [ ` -Clink-self-contained=+linker ` ] ( #link-self-contained ) flag).
272
280
273
281
For example, use:
274
- - ` -Clinker-features=+lld ` to opt in to using the ` lld ` linker
282
+ - ` -Clinker-features=+lld ` to opt into using the ` lld ` linker, when possible (see the Implementation notes below)
275
283
- ` -Clinker-features=-lld ` to opt out instead, for targets where it is configured as the default linker
276
284
285
+ #### Implementation notes
286
+
287
+ On the ` x86_64-unknown-linux-gnu ` target, when using the default linker flavor (using ` cc ` as the
288
+ linker driver), ` rustc ` will try to use lld by passing a ` -fuse-ld=lld ` link argument to the driver.
289
+ ` rustc ` will also try to detect if that _ causes_ an error during linking (for example, if GCC is too
290
+ old to understand the flag, and returns an error) and will then retry linking without this argument,
291
+ as a fallback.
292
+
293
+ If the user _ also_ passes a ` -Clink-arg=-fuse-ld=$value ` , both will be given to the linker
294
+ driver but the user's will be passed last, and would generally have priority over ` rustc ` 's.
295
+
277
296
## linker-flavor
278
297
279
298
This flag controls the linker flavor used by ` rustc ` . If a linker is given with
0 commit comments