Skip to content

Commit e0af3c6

Browse files
committed
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 Print which file is being constructed to give some hint about what is going on.
1 parent 5c84886 commit e0af3c6

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

compiler/rustc_codegen_llvm/src/back/archive.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ impl<'a> ArchiveBuilder for LlvmArchiveBuilder<'a> {
101101
fn build(mut self: Box<Self>, output: &Path) -> bool {
102102
match self.build_with_llvm(output) {
103103
Ok(any_members) => any_members,
104-
Err(e) => self.sess.dcx().emit_fatal(ArchiveBuildFailure { error: e }),
104+
Err(error) => {
105+
self.sess.dcx().emit_fatal(ArchiveBuildFailure { path: output.to_owned(), error })
106+
}
105107
}
106108
}
107109
}

compiler/rustc_codegen_ssa/messages.ftl

Lines changed: 2 additions & 3 deletions
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ impl<'a> ArchiveBuilder for ArArchiveBuilder<'a> {
220220
let sess = self.sess;
221221
match self.build_inner(output) {
222222
Ok(any_members) => any_members,
223-
Err(e) => sess.dcx().emit_fatal(ArchiveBuildFailure { error: e }),
223+
Err(error) => {
224+
sess.dcx().emit_fatal(ArchiveBuildFailure { path: output.to_owned(), error })
225+
}
224226
}
225227
}
226228
}

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ pub struct UnableToWriteDebuggerVisualizer {
497497
#[derive(Diagnostic)]
498498
#[diag(codegen_ssa_rlib_archive_build_failure)]
499499
pub struct RlibArchiveBuildFailure {
500+
pub path: PathBuf,
500501
pub error: Error,
501502
}
502503

@@ -554,6 +555,7 @@ pub struct UnsupportedLinkSelfContained;
554555
#[diag(codegen_ssa_archive_build_failure)]
555556
// Public for rustc_codegen_llvm::back::archive
556557
pub struct ArchiveBuildFailure {
558+
pub path: PathBuf,
557559
pub error: std::io::Error,
558560
}
559561

0 commit comments

Comments
 (0)