@@ -244,18 +244,35 @@ flag for another way to specify the linker.
244
244
245
245
## linker-features
246
246
247
- This flag allows enabling or disabling specific features used during linking.
247
+ The ` -Clinker-features ` flag allows enabling or disabling specific features used during linking.
248
248
249
- The flag accepts a comma-separated list of features, individually enabled (` +feature ` ) or disabled
250
- (` -feature ` ).
249
+ These feature flags are a flexible extension mechanism that is complementary to linker flavors,
250
+ designed to avoid the combinatorial explosion of having to create a new set of flavors for each
251
+ linker feature we'd want to use.
251
252
252
- Currently, only one such feature is stable:
253
- - ` lld ` : toggles the usage of the lld linker, either the system-installed binary, or the self-contained
254
- ` rust-lld ` linker.
253
+ The flag accepts a comma-separated list of features, individually enabled (` +features ` ) or disabled
254
+ (` -features ` ).
255
255
256
- If you want to opt out of the usage of the ` lld ` linker (for targets where it is configured as the default linker),
256
+ Currently only one is stable, and only on the ` x86_64-unknown-linux-gnu ` target:
257
+ - ` lld ` : to toggle using the lld linker, either the system-installed binary, or the self-contained
258
+ ` rust-lld ` linker (via the ` -Clink-self-contained=+linker ` flag).
259
+
260
+ To opt out of using the ` lld ` linker (for targets where it is configured as the default linker),
257
261
use ` -Clinker-features=-lld ` .
258
262
263
+ In general, this design allows:
264
+ - default feature sets for principal flavors, or for specific targets.
265
+ - flavor-specific features: for example, clang offers automatic cross-linking with ` --target ` , which
266
+ gcc-style compilers don't support. The * flavor* is still a C/C++ compiler, and we don't want to
267
+ multiply the number of flavors for this use-case. Instead, we can have a single ` +target ` feature.
268
+ - umbrella features: for example, if clang accumulates more features in the future than just the
269
+ ` +target ` above. That could be modeled as ` +clang ` .
270
+ - niche features for resolving specific issues: for example, on Apple targets the linker flag
271
+ implementing the ` as-needed ` native link modifier ([ #99424 ] ( https://github.com/rust-lang/rust/issues/99424 ) )
272
+ is only possible on sufficiently recent linker versions.
273
+ - still allows for discovery and automation, for example via feature detection. This can be useful
274
+ in exotic environments/build systems.
275
+
259
276
## linker-flavor
260
277
261
278
This flag controls the linker flavor used by ` rustc ` . If a linker is given with
0 commit comments