Skip to content

Commit 835978b

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

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/cargo/core/compiler/custom_build.rs

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

404417
if let Err(error) = output {
405418
insert_warnings_in_build_outputs(

0 commit comments

Comments
 (0)