diff options
| author | bors <bors@rust-lang.org> | 2023-07-19 07:27:50 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-19 07:27:50 +0000 | 
| commit | 77e24f90f599070af2d8051ef9adad7fe528dd78 (patch) | |
| tree | d5dc97aa3d249794d5835db939ac309fee5604be /compiler | |
| parent | b657dc555b1ecf837cc4ea471fbae6a731529d55 (diff) | |
| parent | c59b82353d70122b59f5bc428be9464f49a99326 (diff) | |
| download | rust-77e24f90f599070af2d8051ef9adad7fe528dd78.tar.gz rust-77e24f90f599070af2d8051ef9adad7fe528dd78.zip | |
Auto merge of #112591 - jfgoog:better-dlltool-diagnostics, r=WaffleLapkin
Better diagnostics for dlltool errors. When dlltool fails, show the full command that was executed. In particular, llvm-dlltool is not very helpful, printing a generic usage message rather than what actually went wrong, so stdout and stderr aren't of much use when troubleshooting.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_codegen_llvm/messages.ftl | 3 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/archive.rs | 43 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/errors.rs | 2 | 
3 files changed, 28 insertions, 20 deletions
| diff --git a/compiler/rustc_codegen_llvm/messages.ftl b/compiler/rustc_codegen_llvm/messages.ftl index de1622951fe..aed4a8f3c85 100644 --- a/compiler/rustc_codegen_llvm/messages.ftl +++ b/compiler/rustc_codegen_llvm/messages.ftl @@ -1,7 +1,8 @@ codegen_llvm_copy_bitcode = failed to copy bitcode to object file: {$err} codegen_llvm_dlltool_fail_import_library = - Dlltool could not create import library: {$stdout} + Dlltool could not create import library with {$dlltool_path} {$dlltool_args}: + {$stdout} {$stderr} codegen_llvm_dynamic_linking_with_lto = diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index a6416e9540c..10bf954d242 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -198,25 +198,24 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder { "arm" => ("arm", "--32"), _ => panic!("unsupported arch {}", sess.target.arch), }; - let result = std::process::Command::new(&dlltool) - .args([ - "-d", - def_file_path.to_str().unwrap(), - "-D", - lib_name, - "-l", - output_path.to_str().unwrap(), - "-m", - dlltool_target_arch, - "-f", - dlltool_target_bitness, - "--no-leading-underscore", - "--temp-prefix", - temp_prefix.to_str().unwrap(), - ]) - .output(); - - match result { + let mut dlltool_cmd = std::process::Command::new(&dlltool); + dlltool_cmd.args([ + "-d", + def_file_path.to_str().unwrap(), + "-D", + lib_name, + "-l", + output_path.to_str().unwrap(), + "-m", + dlltool_target_arch, + "-f", + dlltool_target_bitness, + "--no-leading-underscore", + "--temp-prefix", + temp_prefix.to_str().unwrap(), + ]); + + match dlltool_cmd.output() { Err(e) => { sess.emit_fatal(ErrorCallingDllTool { dlltool_path: dlltool.to_string_lossy(), @@ -226,6 +225,12 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder { // dlltool returns '0' on failure, so check for error output instead. Ok(output) if !output.stderr.is_empty() => { sess.emit_fatal(DlltoolFailImportLibrary { + dlltool_path: dlltool.to_string_lossy(), + dlltool_args: dlltool_cmd + .get_args() + .map(|arg| arg.to_string_lossy()) + .collect::<Vec<_>>() + .join(" "), stdout: String::from_utf8_lossy(&output.stdout), stderr: String::from_utf8_lossy(&output.stderr), }) diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index 44869ced1ae..fced6d504d2 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -81,6 +81,8 @@ pub(crate) struct ErrorCallingDllTool<'a> { #[derive(Diagnostic)] #[diag(codegen_llvm_dlltool_fail_import_library)] pub(crate) struct DlltoolFailImportLibrary<'a> { + pub dlltool_path: Cow<'a, str>, + pub dlltool_args: String, pub stdout: Cow<'a, str>, pub stderr: Cow<'a, str>, } | 
