Skip to content

Commit 58e6599

Browse files
committed
display note to increase debuginfo level when build deps fail
it's only displayed when backtraces are requested
1 parent ccd7deb commit 58e6599

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/cargo/core/compiler/custom_build.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,21 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
405405
},
406406
true,
407407
)
408-
.with_context(|| format!("failed to run custom build command for `{}`", pkg_descr));
408+
.with_context(|| {
409+
let mut build_error_context = format!("failed to run custom build command for `{}`", pkg_descr);
410+
411+
// If we're opting into backtraces, mention that build dependencies' backtraces can
412+
// be improved by setting a higher debuginfo level.
413+
if let Ok(show_backtraces) = std::env::var("RUST_BACKTRACE") {
414+
if show_backtraces != "0" {
415+
build_error_context.push_str("\n\
416+
note: To improve backtraces for build dependencies, make sure full debug info is turned on. \
417+
More details at https://doc.rust-lang.org/cargo/reference/profiles.html#build-dependencies");
418+
}
419+
}
420+
421+
build_error_context
422+
});
409423

410424
if let Err(error) = output {
411425
insert_warnings_in_build_outputs(

0 commit comments

Comments
 (0)