Skip to content

Commit d64a8bd

Browse files
committed
emit an error if we can't find a path to the self-contained linker
1 parent fab28f2 commit d64a8bd

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

compiler/rustc_codegen_ssa/messages.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ codegen_ssa_rlib_only_rmeta_found = could not find rlib for: `{$crate_name}`, fo
212212
213213
codegen_ssa_select_cpp_build_tool_workload = in the Visual Studio installer, ensure the "C++ build tools" workload is selected
214214
215+
codegen_ssa_self_contained_linker_missing = the self-contained linker was requested, but it wasn't found in the target's sysroot, or in rustc's sysroot
216+
215217
codegen_ssa_shuffle_indices_evaluation = could not evaluate shuffle_indices at compile time
216218
217219
codegen_ssa_specify_libraries_to_link = use the `-l` flag to specify native libraries to link

compiler/rustc_codegen_ssa/src/back/link.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3127,9 +3127,9 @@ fn add_lld_args(
31273127
});
31283128
}
31293129
if !linker_path_exists {
3130-
// As an additional sanity check, we do nothing if the sysroot doesn't contain the
3131-
// linker path at all.
3132-
return;
3130+
// As a sanity check, we emit an error if none of these paths exist: we want
3131+
// self-contained linking and have no linker.
3132+
sess.dcx().emit_fatal(errors::SelfContainedLinkerMissing);
31333133
}
31343134
}
31353135

compiler/rustc_codegen_ssa/src/errors.rs

+4
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ pub struct UnableToExeLinker {
413413
#[diag(codegen_ssa_msvc_missing_linker)]
414414
pub struct MsvcMissingLinker;
415415

416+
#[derive(Diagnostic)]
417+
#[diag(codegen_ssa_self_contained_linker_missing)]
418+
pub struct SelfContainedLinkerMissing;
419+
416420
#[derive(Diagnostic)]
417421
#[diag(codegen_ssa_check_installed_visual_studio)]
418422
pub struct CheckInstalledVisualStudio;

0 commit comments

Comments
 (0)