Skip to content

Commit 1e1c4d8

Browse files
authored
Rollup merge of rust-lang#127830 - tgross35:archive-failure-message, r=BoxyUwU
When an archive fails to build, print the path Currently the output on failure is as follows: Compiling block-buffer v0.10.4 Compiling crypto-common v0.1.6 Compiling digest v0.10.7 Compiling sha2 v0.10.8 Compiling xz2 v0.1.7 error: failed to build archive: No such file or directory error: could not compile `bootstrap` (lib) due to 1 previous error Change this to print which file is being constructed, to give some hint about what is going on. error: failed to build archive at `path/to/output`: No such file or directory
2 parents e447650 + e0af3c6 commit 1e1c4d8

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

compiler/rustc_codegen_llvm/src/back/archive.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ impl<'a> ArchiveBuilder for LlvmArchiveBuilder<'a> {
9797
fn build(mut self: Box<Self>, output: &Path) -> bool {
9898
match self.build_with_llvm(output) {
9999
Ok(any_members) => any_members,
100-
Err(e) => self.sess.dcx().emit_fatal(ArchiveBuildFailure { error: e }),
100+
Err(error) => {
101+
self.sess.dcx().emit_fatal(ArchiveBuildFailure { path: output.to_owned(), error })
102+
}
101103
}
102104
}
103105
}

compiler/rustc_codegen_ssa/messages.ftl

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ codegen_ssa_add_native_library = failed to add native library {$library_path}: {
44
55
codegen_ssa_apple_sdk_error_sdk_path = failed to get {$sdk_name} SDK path: {$error}
66
7-
codegen_ssa_archive_build_failure =
8-
failed to build archive: {$error}
7+
codegen_ssa_archive_build_failure = failed to build archive at `{$path}`: {$error}
98
109
codegen_ssa_atomic_compare_exchange = Atomic compare-exchange intrinsic missing failure memory ordering
1110
@@ -198,7 +197,7 @@ codegen_ssa_read_file = failed to read file: {$message}
198197
199198
codegen_ssa_repair_vs_build_tools = the Visual Studio build tools may need to be repaired using the Visual Studio installer
200199
201-
codegen_ssa_rlib_archive_build_failure = failed to build archive from rlib: {$error}
200+
codegen_ssa_rlib_archive_build_failure = failed to build archive from rlib at `{$path}`: {$error}
202201
203202
codegen_ssa_rlib_incompatible_dependency_formats = `{$ty1}` and `{$ty2}` do not have equivalent dependency formats (`{$list1}` vs `{$list2}`)
204203

compiler/rustc_codegen_ssa/src/back/archive.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ impl<'a> ArchiveBuilder for ArArchiveBuilder<'a> {
207207
let sess = self.sess;
208208
match self.build_inner(output) {
209209
Ok(any_members) => any_members,
210-
Err(e) => sess.dcx().emit_fatal(ArchiveBuildFailure { error: e }),
210+
Err(error) => {
211+
sess.dcx().emit_fatal(ArchiveBuildFailure { path: output.to_owned(), error })
212+
}
211213
}
212214
}
213215
}

compiler/rustc_codegen_ssa/src/back/link.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2911,7 +2911,8 @@ fn add_static_crate(
29112911
false
29122912
}),
29132913
) {
2914-
sess.dcx().emit_fatal(errors::RlibArchiveBuildFailure { error });
2914+
sess.dcx()
2915+
.emit_fatal(errors::RlibArchiveBuildFailure { path: cratepath.clone(), error });
29152916
}
29162917
if archive.build(&dst) {
29172918
link_upstream(&dst);

compiler/rustc_codegen_ssa/src/errors.rs

+2
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ pub struct UnableToWriteDebuggerVisualizer {
500500
#[derive(Diagnostic)]
501501
#[diag(codegen_ssa_rlib_archive_build_failure)]
502502
pub struct RlibArchiveBuildFailure {
503+
pub path: PathBuf,
503504
pub error: Error,
504505
}
505506

@@ -557,6 +558,7 @@ pub struct UnsupportedLinkSelfContained;
557558
#[diag(codegen_ssa_archive_build_failure)]
558559
// Public for rustc_codegen_llvm::back::archive
559560
pub struct ArchiveBuildFailure {
561+
pub path: PathBuf,
560562
pub error: std::io::Error,
561563
}
562564

0 commit comments

Comments
 (0)