Skip to content

Commit a9f12e2

Browse files
committed
wip
1 parent a5f518a commit a9f12e2

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3952,6 +3952,7 @@ dependencies = [
39523952
"libc",
39533953
"rustc_ast",
39543954
"rustc_ast_pretty",
3955+
"rustc_codegen_llvm",
39553956
"rustc_codegen_ssa",
39563957
"rustc_data_structures",
39573958
"rustc_error_codes",

compiler/rustc_codegen_llvm/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern crate tracing;
2323
use back::write::{create_informational_target_machine, create_target_machine};
2424

2525
use errors::FailParsingTargetMachineConfigToTargetMachine;
26-
pub use llvm_util::target_features;
26+
pub use llvm_util::{get_version, target_features};
2727
use rustc_ast::expand::allocator::AllocatorKind;
2828
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
2929
use rustc_codegen_ssa::back::write::{

compiler/rustc_driver/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ rustc_parse = { path = "../rustc_parse" }
2828
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
2929
rustc_save_analysis = { path = "../rustc_save_analysis" }
3030
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
31+
rustc_codegen_llvm = { path = "../rustc_codegen_llvm" }
3132
rustc_session = { path = "../rustc_session" }
3233
rustc_error_codes = { path = "../rustc_error_codes" }
3334
rustc_interface = { path = "../rustc_interface" }

compiler/rustc_driver/src/lib.rs

+25-21
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub const EXIT_SUCCESS: i32 = 0;
7676
pub const EXIT_FAILURE: i32 = 1;
7777

7878
const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust/issues/new\
79-
?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md";
79+
?labels=C-bug%2CI-ICE%2CT-compiler&template=ice.yaml";
8080

8181
const ICE_REPORT_COMPILER_FLAGS: &[&str] = &["-Z", "-C", "--crate-type"];
8282

@@ -1199,21 +1199,25 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<(String, String), Ic
11991199
let now = chrono::UTC::now();
12001200
let file_now = now.format("%Y-%m-%d_%H:%M:%S");
12011201
let now = now.format("%Y-%m-%d %H:%M:%S");
1202-
let path = format!("rustc-ice-context-{file_now}.txt");
1202+
let mut path = std::env::current_dir()?;
1203+
path.push(format!("rustc-ice-context-{file_now}.txt"));
12031204
let mut file = std::fs::File::create(&path)?;
1204-
writeln!(
1205-
file,
1206-
"rustc {}{} running on {} at {now}",
1205+
let (llvm_major, llvm_minor, llvm_dot) = rustc_codegen_llvm::get_version();
1206+
let version = format!(
1207+
"rustc {}{} running on {} at {now} with LLVM {llvm_major}.{llvm_minor}.{llvm_dot}",
12071208
util::version_str!().unwrap_or("unknown_version"),
12081209
match (option_env!("CFG_VER_HASH"), option_env!("CFG_VER_DATE")) {
12091210
(Some(hash), Some(date)) => format!(" ({hash} - {date})"),
12101211
(Some(val), None) | (None, Some(val)) => format!(" ({val})"),
12111212
(None, None) => String::new(),
12121213
},
12131214
config::host_triple(),
1214-
)?;
1215-
args.push(("version", util::version_str!().unwrap_or("unknown_version")));
1216-
args.push(("platform", config::host_triple()));
1215+
);
1216+
1217+
writeln!(file, "{}", version)?;
1218+
args.push(("version", version.as_str()));
1219+
let backtrace_msg = format!("please include the contents of `{}` here", path.display());
1220+
args.push(("backtrace", &backtrace_msg));
12171221

12181222
if let Some((flags, excluded_cargo_defaults)) = extra_compiler_flags() {
12191223
writeln!(file, "compiler flags:")?;
@@ -1243,15 +1247,7 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<(String, String), Ic
12431247
}
12441248

12451249
writeln!(file, "")?;
1246-
let capture = capture.frames().iter().map(|frame| {
1247-
format!("{:?}", frame)
1248-
}).collect::<String>();
12491250
writeln!(file, "{capture}")?;
1250-
text.push_str(&format!("{capture}"));
1251-
args.push(("backtrace", &text));
1252-
1253-
println!("{}", text);
1254-
println!("{}", urlqstring::QueryParams::from(args).stringify());
12551251

12561252
// Be careful relying on global state here: this code is called from
12571253
// a panic hook, which means that the global `Handler` may be in a weird
@@ -1280,7 +1276,10 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<(String, String), Ic
12801276
writeln!(file, "end of query stack")?;
12811277
Ok(())
12821278
})?;
1283-
Ok((path, String::new()))
1279+
Ok((
1280+
path.display().to_string(),
1281+
format!("{BUG_REPORT_URL}&{}", urlqstring::QueryParams::from(args).stringify()),
1282+
))
12841283
}
12851284

12861285
static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
@@ -1327,7 +1326,11 @@ static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send +
13271326
///
13281327
/// When `install_ice_hook` is called, this function will be called as the panic
13291328
/// hook.
1330-
pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, reported_ice: Option<(String, String)>) {
1329+
pub fn report_ice(
1330+
info: &panic::PanicInfo<'_>,
1331+
bug_report_url: &str,
1332+
reported_ice: Option<(String, String)>,
1333+
) {
13311334
let fallback_bundle =
13321335
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
13331336
let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
@@ -1355,11 +1358,12 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, reported_ic
13551358
handler.emit_diagnostic(&mut d);
13561359
}
13571360

1358-
let xs: Vec<Cow<'static, str>> = if let Some((path, url)) = &reported_ice {
1361+
let xs: Vec<Cow<'static, str>> = if let Some((path, custom_url)) = &reported_ice {
1362+
let link = format!("\x1b]8;;{custom_url}\x1b\\{bug_report_url}\x1b]8;;\x1b\\");
1363+
let path = format!("\x1b]8;;file://{path}\x1b\\{path}\x1b]8;;\x1b\\");
13591364
vec![
13601365
format!("all necessary context about this bug was written to `{path}`").into(),
1361-
format!("we would appreciate a bug report with this context at <{url}>")
1362-
.into(),
1366+
format!("we would appreciate a bug report with this context at {link}").into(),
13631367
]
13641368
} else {
13651369
let mut xs = vec![

0 commit comments

Comments
 (0)