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