summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_llvm/src/back/archive.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /compiler/rustc_codegen_llvm/src/back/archive.rs
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back/archive.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/back/archive.rs53
1 files changed, 29 insertions, 24 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs
index a6416e954..a82d2c577 100644
--- a/compiler/rustc_codegen_llvm/src/back/archive.rs
+++ b/compiler/rustc_codegen_llvm/src/back/archive.rs
@@ -56,7 +56,7 @@ fn llvm_machine_type(cpu: &str) -> LLVMMachineType {
"x86" => LLVMMachineType::I386,
"aarch64" => LLVMMachineType::ARM64,
"arm" => LLVMMachineType::ARM,
- _ => panic!("unsupported cpu type {}", cpu),
+ _ => panic!("unsupported cpu type {cpu}"),
}
}
@@ -128,7 +128,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" };
let output_path = {
let mut output_path: PathBuf = tmpdir.to_path_buf();
- output_path.push(format!("{}{}", lib_name, name_suffix));
+ output_path.push(format!("{lib_name}{name_suffix}"));
output_path.with_extension("lib")
};
@@ -156,7 +156,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
// functions. Therefore, use binutils to create the import library instead,
// by writing a .DEF file to the temp dir and calling binutils's dlltool.
let def_file_path =
- tmpdir.join(format!("{}{}", lib_name, name_suffix)).with_extension("def");
+ tmpdir.join(format!("{lib_name}{name_suffix}")).with_extension("def");
let def_file_content = format!(
"EXPORTS\n{}",
@@ -164,7 +164,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
.into_iter()
.map(|(name, ordinal)| {
match ordinal {
- Some(n) => format!("{} @{} NONAME", name, n),
+ Some(n) => format!("{name} @{n} NONAME"),
None => name,
}
})
@@ -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),
})
@@ -430,7 +435,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
}
fn string_to_io_error(s: String) -> io::Error {
- io::Error::new(io::ErrorKind::Other, format!("bad archive: {}", s))
+ io::Error::new(io::ErrorKind::Other, format!("bad archive: {s}"))
}
fn find_binutils_dlltool(sess: &Session) -> OsString {