@@ -2596,6 +2596,17 @@ fn handle_cli_linker_flavors(
2596
2596
}
2597
2597
2598
2598
let cg = & sess. opts . cg ;
2599
+ let unstable_self_contained_linker = cg. link_self_contained . linker . is_on ( ) ;
2600
+
2601
+ // Sanity check for distro-builds: they don't distribute `rust-lld`, and the `-C
2602
+ // link-self-contained=linker` flag cannot be used there: the `rust.lld` flag has to be enabled
2603
+ // in `config.toml` so that `#[cfg(rust_lld_enabled)] applies.
2604
+ if unstable_self_contained_linker && !cfg ! ( rust_lld_enabled) {
2605
+ sess. fatal (
2606
+ "Using `-Clink-self-contained=linker` requires the \
2607
+ compiler to be built with the `rust.lld` flag enabled",
2608
+ ) ;
2609
+ }
2599
2610
2600
2611
// The `-C linker-flavor` CLI flag can optionally enrich linker-flavors. Check whether that's
2601
2612
// applicable, and emit errors if sanity checks fail. There's currently only one enrichment:
@@ -2660,12 +2671,10 @@ fn handle_cli_linker_flavors(
2660
2671
2661
2672
// Now, handle `rust-lld`. If both the `-Clink-self-contained=linker` and
2662
2673
// `-Clinker-flavor=gcc:lld` flags were provided, we use `rust-lld`, the rustup-distributed
2663
- // version of `lld` (when applicable, i.e. not in distro-builds) by:
2674
+ // version of `lld` (when applicable` , i.e. not in distro-builds) by:
2664
2675
// - checking the `lld-wrapper`s exist in the sysroot
2665
2676
// - adding their folder as a search path, or requesting to use a wrapper directly
2666
- //
2667
- // FIXME: make sure rust.lld config flag is turned on before adding the sysroot magic handling
2668
- if sess. opts . cg . link_self_contained . linker . is_on ( ) || unstable_gcc_lld {
2677
+ if unstable_self_contained_linker || unstable_gcc_lld {
2669
2678
// A `gcc-ld` folder (containing the `lld-wrapper`s that will run `rust-lld`) is present in
2670
2679
// the sysroot's target-specific tool binaries folder.
2671
2680
let tools_path = sess. get_tools_search_paths ( false ) ;
0 commit comments