mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
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.
This commit is contained in:
commit
77e24f90f5
@ -1,7 +1,8 @@
|
|||||||
codegen_llvm_copy_bitcode = failed to copy bitcode to object file: {$err}
|
codegen_llvm_copy_bitcode = failed to copy bitcode to object file: {$err}
|
||||||
|
|
||||||
codegen_llvm_dlltool_fail_import_library =
|
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}
|
{$stderr}
|
||||||
|
|
||||||
codegen_llvm_dynamic_linking_with_lto =
|
codegen_llvm_dynamic_linking_with_lto =
|
||||||
|
@ -198,25 +198,24 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
|
|||||||
"arm" => ("arm", "--32"),
|
"arm" => ("arm", "--32"),
|
||||||
_ => panic!("unsupported arch {}", sess.target.arch),
|
_ => panic!("unsupported arch {}", sess.target.arch),
|
||||||
};
|
};
|
||||||
let result = std::process::Command::new(&dlltool)
|
let mut dlltool_cmd = std::process::Command::new(&dlltool);
|
||||||
.args([
|
dlltool_cmd.args([
|
||||||
"-d",
|
"-d",
|
||||||
def_file_path.to_str().unwrap(),
|
def_file_path.to_str().unwrap(),
|
||||||
"-D",
|
"-D",
|
||||||
lib_name,
|
lib_name,
|
||||||
"-l",
|
"-l",
|
||||||
output_path.to_str().unwrap(),
|
output_path.to_str().unwrap(),
|
||||||
"-m",
|
"-m",
|
||||||
dlltool_target_arch,
|
dlltool_target_arch,
|
||||||
"-f",
|
"-f",
|
||||||
dlltool_target_bitness,
|
dlltool_target_bitness,
|
||||||
"--no-leading-underscore",
|
"--no-leading-underscore",
|
||||||
"--temp-prefix",
|
"--temp-prefix",
|
||||||
temp_prefix.to_str().unwrap(),
|
temp_prefix.to_str().unwrap(),
|
||||||
])
|
]);
|
||||||
.output();
|
|
||||||
|
|
||||||
match result {
|
match dlltool_cmd.output() {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
sess.emit_fatal(ErrorCallingDllTool {
|
sess.emit_fatal(ErrorCallingDllTool {
|
||||||
dlltool_path: dlltool.to_string_lossy(),
|
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.
|
// dlltool returns '0' on failure, so check for error output instead.
|
||||||
Ok(output) if !output.stderr.is_empty() => {
|
Ok(output) if !output.stderr.is_empty() => {
|
||||||
sess.emit_fatal(DlltoolFailImportLibrary {
|
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),
|
stdout: String::from_utf8_lossy(&output.stdout),
|
||||||
stderr: String::from_utf8_lossy(&output.stderr),
|
stderr: String::from_utf8_lossy(&output.stderr),
|
||||||
})
|
})
|
||||||
|
@ -81,6 +81,8 @@ pub(crate) struct ErrorCallingDllTool<'a> {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_llvm_dlltool_fail_import_library)]
|
#[diag(codegen_llvm_dlltool_fail_import_library)]
|
||||||
pub(crate) struct DlltoolFailImportLibrary<'a> {
|
pub(crate) struct DlltoolFailImportLibrary<'a> {
|
||||||
|
pub dlltool_path: Cow<'a, str>,
|
||||||
|
pub dlltool_args: String,
|
||||||
pub stdout: Cow<'a, str>,
|
pub stdout: Cow<'a, str>,
|
||||||
pub stderr: Cow<'a, str>,
|
pub stderr: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
// compile-flags: --crate-type lib --emit link
|
// compile-flags: --crate-type lib --emit link
|
||||||
// normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL"
|
// normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL"
|
||||||
// normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE"
|
// normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE"
|
||||||
|
// normalize-stderr-test: "[^ ]*/foo.lib" -> "$$LIB_FILE"
|
||||||
|
// normalize-stderr-test: "-m [^ ]*" -> "$$TARGET_MACHINE"
|
||||||
|
// normalize-stderr-test: "-f [^ ]*" -> "$$ASM_FLAGS"
|
||||||
|
// normalize-stderr-test: "--temp-prefix [^ ]*/foo.dll" -> "$$TEMP_PREFIX"
|
||||||
#[link(name = "foo", kind = "raw-dylib")]
|
#[link(name = "foo", kind = "raw-dylib")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// `@1` is an invalid name to export, as it usually indicates that something
|
// `@1` is an invalid name to export, as it usually indicates that something
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
error: Dlltool could not create import library:
|
error: Dlltool could not create import library with $DLLTOOL -d $DEF_FILE -D foo.dll -l $LIB_FILE $TARGET_MACHINE $ASM_FLAGS --no-leading-underscore $TEMP_PREFIX:
|
||||||
|
|
||||||
$DLLTOOL: Syntax error in def file $DEF_FILE:1
|
$DLLTOOL: Syntax error in def file $DEF_FILE:1
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
Loading…
Reference in New Issue
Block a user