session: diagnostic migration lint on more fns
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
d45004806d
commit
2575b1abc9
33 changed files with 510 additions and 162 deletions
|
@ -1,5 +1,7 @@
|
|||
use crate::back::write::{self, save_temp_bitcode, DiagnosticHandlers};
|
||||
use crate::errors::DynamicLinkingWithLTO;
|
||||
use crate::errors::{
|
||||
DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib,
|
||||
};
|
||||
use crate::llvm::{self, build_string};
|
||||
use crate::{LlvmCodegenBackend, ModuleLlvm};
|
||||
use object::read::archive::ArchiveFile;
|
||||
|
@ -77,15 +79,12 @@ fn prepare_lto(
|
|||
// Make sure we actually can run LTO
|
||||
for crate_type in cgcx.crate_types.iter() {
|
||||
if !crate_type_allows_lto(*crate_type) {
|
||||
let e = diag_handler.fatal(
|
||||
"lto can only be run for executables, cdylibs and \
|
||||
static library outputs",
|
||||
);
|
||||
return Err(e);
|
||||
diag_handler.emit_err(LtoDisallowed);
|
||||
return Err(FatalError);
|
||||
} else if *crate_type == CrateType::Dylib {
|
||||
if !cgcx.opts.unstable_opts.dylib_lto {
|
||||
return Err(diag_handler
|
||||
.fatal("lto cannot be used for `dylib` crate type without `-Zdylib-lto`"));
|
||||
diag_handler.emit_err(LtoDylib);
|
||||
return Err(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +126,10 @@ fn prepare_lto(
|
|||
let module = SerializedModule::FromRlib(data.to_vec());
|
||||
upstream_modules.push((module, CString::new(name).unwrap()));
|
||||
}
|
||||
Err(msg) => return Err(diag_handler.fatal(&msg)),
|
||||
Err(e) => {
|
||||
diag_handler.emit_err(e);
|
||||
return Err(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +142,7 @@ fn prepare_lto(
|
|||
Ok((symbols_below_threshold, upstream_modules))
|
||||
}
|
||||
|
||||
fn get_bitcode_slice_from_object_data(obj: &[u8]) -> Result<&[u8], String> {
|
||||
fn get_bitcode_slice_from_object_data(obj: &[u8]) -> Result<&[u8], LtoBitcodeFromRlib> {
|
||||
let mut len = 0;
|
||||
let data =
|
||||
unsafe { llvm::LLVMRustGetBitcodeSliceFromObjectData(obj.as_ptr(), obj.len(), &mut len) };
|
||||
|
@ -155,8 +157,9 @@ fn get_bitcode_slice_from_object_data(obj: &[u8]) -> Result<&[u8], String> {
|
|||
Ok(bc)
|
||||
} else {
|
||||
assert!(len == 0);
|
||||
let msg = llvm::last_error().unwrap_or_else(|| "unknown LLVM error".to_string());
|
||||
Err(format!("failed to get bitcode from object file for LTO ({})", msg))
|
||||
Err(LtoBitcodeFromRlib {
|
||||
llvm_err: llvm::last_error().unwrap_or_else(|| "unknown LLVM error".to_string()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,10 +331,9 @@ fn fat_lto(
|
|||
});
|
||||
info!("linking {:?}", name);
|
||||
let data = bc_decoded.data();
|
||||
linker.add(data).map_err(|()| {
|
||||
let msg = format!("failed to load bitcode of module {:?}", name);
|
||||
write::llvm_err(diag_handler, &msg)
|
||||
})?;
|
||||
linker
|
||||
.add(data)
|
||||
.map_err(|()| write::llvm_err(diag_handler, LlvmError::LoadBitcode { name }))?;
|
||||
serialized_bitcode.push(bc_decoded);
|
||||
}
|
||||
drop(linker);
|
||||
|
@ -489,7 +491,7 @@ fn thin_lto(
|
|||
symbols_below_threshold.as_ptr(),
|
||||
symbols_below_threshold.len() as u32,
|
||||
)
|
||||
.ok_or_else(|| write::llvm_err(diag_handler, "failed to prepare thin LTO context"))?;
|
||||
.ok_or_else(|| write::llvm_err(diag_handler, LlvmError::PrepareThinLtoContext))?;
|
||||
|
||||
let data = ThinData(data);
|
||||
|
||||
|
@ -562,8 +564,7 @@ fn thin_lto(
|
|||
// session, overwriting the previous serialized data (if any).
|
||||
if let Some(path) = key_map_path {
|
||||
if let Err(err) = curr_key_map.save_to_file(&path) {
|
||||
let msg = format!("Error while writing ThinLTO key data: {}", err);
|
||||
return Err(write::llvm_err(diag_handler, &msg));
|
||||
return Err(write::llvm_err(diag_handler, LlvmError::WriteThinLtoKey { err }));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -689,8 +690,7 @@ pub unsafe fn optimize_thin_module(
|
|||
|
||||
let module_name = &thin_module.shared.module_names[thin_module.idx];
|
||||
let tm_factory_config = TargetMachineFactoryConfig::new(cgcx, module_name.to_str().unwrap());
|
||||
let tm =
|
||||
(cgcx.tm_factory)(tm_factory_config).map_err(|e| write::llvm_err(&diag_handler, &e))?;
|
||||
let tm = (cgcx.tm_factory)(tm_factory_config).map_err(|e| write::llvm_err(&diag_handler, e))?;
|
||||
|
||||
// Right now the implementation we've got only works over serialized
|
||||
// modules, so we create a fresh new LLVM context and parse the module
|
||||
|
@ -717,8 +717,7 @@ pub unsafe fn optimize_thin_module(
|
|||
let mut cu2 = ptr::null_mut();
|
||||
llvm::LLVMRustThinLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
|
||||
if !cu2.is_null() {
|
||||
let msg = "multiple source DICompileUnits found";
|
||||
return Err(write::llvm_err(&diag_handler, msg));
|
||||
return Err(write::llvm_err(&diag_handler, LlvmError::MultipleSourceDiCompileUnit));
|
||||
}
|
||||
|
||||
// Up next comes the per-module local analyses that we do for Thin LTO.
|
||||
|
@ -733,8 +732,7 @@ pub unsafe fn optimize_thin_module(
|
|||
let _timer =
|
||||
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
|
||||
if !llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) {
|
||||
let msg = "failed to prepare thin LTO module";
|
||||
return Err(write::llvm_err(&diag_handler, msg));
|
||||
return Err(write::llvm_err(&diag_handler, LlvmError::PrepareThinLtoModule));
|
||||
}
|
||||
save_temp_bitcode(cgcx, &module, "thin-lto-after-rename");
|
||||
}
|
||||
|
@ -744,8 +742,7 @@ pub unsafe fn optimize_thin_module(
|
|||
.prof
|
||||
.generic_activity_with_arg("LLVM_thin_lto_resolve_weak", thin_module.name());
|
||||
if !llvm::LLVMRustPrepareThinLTOResolveWeak(thin_module.shared.data.0, llmod) {
|
||||
let msg = "failed to prepare thin LTO module";
|
||||
return Err(write::llvm_err(&diag_handler, msg));
|
||||
return Err(write::llvm_err(&diag_handler, LlvmError::PrepareThinLtoModule));
|
||||
}
|
||||
save_temp_bitcode(cgcx, &module, "thin-lto-after-resolve");
|
||||
}
|
||||
|
@ -755,8 +752,7 @@ pub unsafe fn optimize_thin_module(
|
|||
.prof
|
||||
.generic_activity_with_arg("LLVM_thin_lto_internalize", thin_module.name());
|
||||
if !llvm::LLVMRustPrepareThinLTOInternalize(thin_module.shared.data.0, llmod) {
|
||||
let msg = "failed to prepare thin LTO module";
|
||||
return Err(write::llvm_err(&diag_handler, msg));
|
||||
return Err(write::llvm_err(&diag_handler, LlvmError::PrepareThinLtoModule));
|
||||
}
|
||||
save_temp_bitcode(cgcx, &module, "thin-lto-after-internalize");
|
||||
}
|
||||
|
@ -765,8 +761,7 @@ pub unsafe fn optimize_thin_module(
|
|||
let _timer =
|
||||
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_import", thin_module.name());
|
||||
if !llvm::LLVMRustPrepareThinLTOImport(thin_module.shared.data.0, llmod, target) {
|
||||
let msg = "failed to prepare thin LTO module";
|
||||
return Err(write::llvm_err(&diag_handler, msg));
|
||||
return Err(write::llvm_err(&diag_handler, LlvmError::PrepareThinLtoModule));
|
||||
}
|
||||
save_temp_bitcode(cgcx, &module, "thin-lto-after-import");
|
||||
}
|
||||
|
@ -886,11 +881,7 @@ pub fn parse_module<'a>(
|
|||
diag_handler: &Handler,
|
||||
) -> Result<&'a llvm::Module, FatalError> {
|
||||
unsafe {
|
||||
llvm::LLVMRustParseBitcodeForLTO(cx, data.as_ptr(), data.len(), name.as_ptr()).ok_or_else(
|
||||
|| {
|
||||
let msg = "failed to parse bitcode for LTO module";
|
||||
write::llvm_err(diag_handler, msg)
|
||||
},
|
||||
)
|
||||
llvm::LLVMRustParseBitcodeForLTO(cx, data.as_ptr(), data.len(), name.as_ptr())
|
||||
.ok_or_else(|| write::llvm_err(diag_handler, LlvmError::ParseBitcode))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ use crate::back::profiling::{
|
|||
use crate::base;
|
||||
use crate::common;
|
||||
use crate::consts;
|
||||
use crate::errors::{
|
||||
CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, WithLlvmError, WriteBytecode,
|
||||
};
|
||||
use crate::llvm::{self, DiagnosticInfo, PassManager};
|
||||
use crate::llvm_util;
|
||||
use crate::type_::Type;
|
||||
|
@ -37,10 +40,10 @@ use std::slice;
|
|||
use std::str;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn llvm_err(handler: &rustc_errors::Handler, msg: &str) -> FatalError {
|
||||
pub fn llvm_err<'a>(handler: &rustc_errors::Handler, err: LlvmError<'a>) -> FatalError {
|
||||
match llvm::last_error() {
|
||||
Some(err) => handler.fatal(&format!("{}: {}", msg, err)),
|
||||
None => handler.fatal(msg),
|
||||
Some(llvm_err) => handler.emit_almost_fatal(WithLlvmError(err, llvm_err)),
|
||||
None => handler.emit_almost_fatal(err),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,10 +88,9 @@ pub fn write_output_file<'ll>(
|
|||
}
|
||||
}
|
||||
|
||||
result.into_result().map_err(|()| {
|
||||
let msg = format!("could not write output to {}", output.display());
|
||||
llvm_err(handler, &msg)
|
||||
})
|
||||
result
|
||||
.into_result()
|
||||
.map_err(|()| llvm_err(handler, LlvmError::WriteOutput { path: output }))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,7 +100,7 @@ pub fn create_informational_target_machine(sess: &Session) -> &'static mut llvm:
|
|||
// system/tcx is set up.
|
||||
let features = llvm_util::global_llvm_features(sess, false);
|
||||
target_machine_factory(sess, config::OptLevel::No, &features)(config)
|
||||
.unwrap_or_else(|err| llvm_err(sess.diagnostic(), &err).raise())
|
||||
.unwrap_or_else(|err| llvm_err(sess.diagnostic(), err).raise())
|
||||
}
|
||||
|
||||
pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> &'static mut llvm::TargetMachine {
|
||||
|
@ -117,7 +119,7 @@ pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> &'static mut ll
|
|||
tcx.backend_optimization_level(()),
|
||||
tcx.global_backend_features(()),
|
||||
)(config)
|
||||
.unwrap_or_else(|err| llvm_err(tcx.sess.diagnostic(), &err).raise())
|
||||
.unwrap_or_else(|err| llvm_err(tcx.sess.diagnostic(), err).raise())
|
||||
}
|
||||
|
||||
pub fn to_llvm_opt_settings(
|
||||
|
@ -240,9 +242,7 @@ pub fn target_machine_factory(
|
|||
)
|
||||
};
|
||||
|
||||
tm.ok_or_else(|| {
|
||||
format!("Could not create LLVM TargetMachine for triple: {}", triple.to_str().unwrap())
|
||||
})
|
||||
tm.ok_or_else(|| LlvmError::CreateTargetMachine { triple: triple.clone() })
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -355,25 +355,28 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void
|
|||
};
|
||||
|
||||
if enabled {
|
||||
diag_handler.note_without_error(&format!(
|
||||
"{}:{}:{}: {}: {}",
|
||||
opt.filename, opt.line, opt.column, opt.pass_name, opt.message,
|
||||
));
|
||||
diag_handler.emit_note(FromLlvmOptimizationDiag {
|
||||
filename: &opt.filename,
|
||||
line: opt.line,
|
||||
column: opt.column,
|
||||
pass_name: &opt.pass_name,
|
||||
message: &opt.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
llvm::diagnostic::PGO(diagnostic_ref) | llvm::diagnostic::Linker(diagnostic_ref) => {
|
||||
let msg = llvm::build_string(|s| {
|
||||
let message = llvm::build_string(|s| {
|
||||
llvm::LLVMRustWriteDiagnosticInfoToString(diagnostic_ref, s)
|
||||
})
|
||||
.expect("non-UTF8 diagnostic");
|
||||
diag_handler.warn(&msg);
|
||||
diag_handler.emit_warning(FromLlvmDiag { message });
|
||||
}
|
||||
llvm::diagnostic::Unsupported(diagnostic_ref) => {
|
||||
let msg = llvm::build_string(|s| {
|
||||
let message = llvm::build_string(|s| {
|
||||
llvm::LLVMRustWriteDiagnosticInfoToString(diagnostic_ref, s)
|
||||
})
|
||||
.expect("non-UTF8 diagnostic");
|
||||
diag_handler.err(&msg);
|
||||
diag_handler.emit_err(FromLlvmDiag { message });
|
||||
}
|
||||
llvm::diagnostic::UnknownDiagnostic(..) => {}
|
||||
}
|
||||
|
@ -494,7 +497,7 @@ pub(crate) unsafe fn llvm_optimize(
|
|||
llvm_plugins.as_ptr().cast(),
|
||||
llvm_plugins.len(),
|
||||
);
|
||||
result.into_result().map_err(|()| llvm_err(diag_handler, "failed to run LLVM passes"))
|
||||
result.into_result().map_err(|()| llvm_err(diag_handler, LlvmError::RunLlvmPasses))
|
||||
}
|
||||
|
||||
// Unsafe due to LLVM calls.
|
||||
|
@ -547,8 +550,7 @@ pub(crate) fn link(
|
|||
let _timer = cgcx.prof.generic_activity_with_arg("LLVM_link_module", &*module.name);
|
||||
let buffer = ModuleBuffer::new(module.module_llvm.llmod());
|
||||
linker.add(buffer.data()).map_err(|()| {
|
||||
let msg = format!("failed to serialize module {:?}", module.name);
|
||||
llvm_err(diag_handler, &msg)
|
||||
llvm_err(diag_handler, LlvmError::SerializeModule { name: &module.name })
|
||||
})?;
|
||||
}
|
||||
drop(linker);
|
||||
|
@ -626,9 +628,8 @@ pub(crate) unsafe fn codegen(
|
|||
let _timer = cgcx
|
||||
.prof
|
||||
.generic_activity_with_arg("LLVM_module_codegen_emit_bitcode", &*module.name);
|
||||
if let Err(e) = fs::write(&bc_out, data) {
|
||||
let msg = format!("failed to write bytecode to {}: {}", bc_out.display(), e);
|
||||
diag_handler.err(&msg);
|
||||
if let Err(err) = fs::write(&bc_out, data) {
|
||||
diag_handler.emit_err(WriteBytecode { path: &bc_out, err });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -678,10 +679,9 @@ pub(crate) unsafe fn codegen(
|
|||
record_artifact_size(&cgcx.prof, "llvm_ir", &out);
|
||||
}
|
||||
|
||||
result.into_result().map_err(|()| {
|
||||
let msg = format!("failed to write LLVM IR to {}", out.display());
|
||||
llvm_err(diag_handler, &msg)
|
||||
})?;
|
||||
result
|
||||
.into_result()
|
||||
.map_err(|()| llvm_err(diag_handler, LlvmError::WriteIr { path: &out }))?;
|
||||
}
|
||||
|
||||
if config.emit_asm {
|
||||
|
@ -749,8 +749,8 @@ pub(crate) unsafe fn codegen(
|
|||
|
||||
EmitObj::Bitcode => {
|
||||
debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out);
|
||||
if let Err(e) = link_or_copy(&bc_out, &obj_out) {
|
||||
diag_handler.err(&format!("failed to copy bitcode to object file: {}", e));
|
||||
if let Err(err) = link_or_copy(&bc_out, &obj_out) {
|
||||
diag_handler.emit_err(CopyBitcode { err });
|
||||
}
|
||||
|
||||
if !config.emit_bc {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use std::borrow::Cow;
|
||||
use std::ffi::CString;
|
||||
use std::path::Path;
|
||||
|
||||
use rustc_errors::fluent;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_errors::Handler;
|
||||
use rustc_errors::IntoDiagnostic;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_errors::{
|
||||
fluent, DiagnosticBuilder, EmissionGuarantee, ErrorGuaranteed, Handler, IntoDiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -81,10 +82,18 @@ pub(crate) struct DlltoolFailImportLibrary<'a> {
|
|||
#[note]
|
||||
pub(crate) struct DynamicLinkingWithLTO;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_fail_parsing_target_machine_config_to_target_machine)]
|
||||
pub(crate) struct FailParsingTargetMachineConfigToTargetMachine {
|
||||
pub error: String,
|
||||
pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>);
|
||||
|
||||
impl<EM: EmissionGuarantee> IntoDiagnostic<'_, EM> for ParseTargetMachineConfig<'_> {
|
||||
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, EM> {
|
||||
let diag: DiagnosticBuilder<'_, EM> = self.0.into_diagnostic(sess);
|
||||
let (message, _) = diag.styled_message().first().expect("`LlvmError` with no message");
|
||||
let message = sess.eagerly_translate_to_string(message.clone(), diag.args());
|
||||
|
||||
let mut diag = sess.struct_diagnostic(fluent::codegen_llvm_parse_target_machine_config);
|
||||
diag.set_arg("error", message);
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct TargetFeatureDisableOrEnable<'a> {
|
||||
|
@ -110,3 +119,99 @@ impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
|
|||
diag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_lto_disallowed)]
|
||||
pub(crate) struct LtoDisallowed;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_lto_dylib)]
|
||||
pub(crate) struct LtoDylib;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_lto_bitcode_from_rlib)]
|
||||
pub(crate) struct LtoBitcodeFromRlib {
|
||||
pub llvm_err: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
pub enum LlvmError<'a> {
|
||||
#[diag(codegen_llvm_write_output)]
|
||||
WriteOutput { path: &'a Path },
|
||||
#[diag(codegen_llvm_target_machine)]
|
||||
CreateTargetMachine { triple: SmallCStr },
|
||||
#[diag(codegen_llvm_run_passes)]
|
||||
RunLlvmPasses,
|
||||
#[diag(codegen_llvm_serialize_module)]
|
||||
SerializeModule { name: &'a str },
|
||||
#[diag(codegen_llvm_write_ir)]
|
||||
WriteIr { path: &'a Path },
|
||||
#[diag(codegen_llvm_prepare_thin_lto_context)]
|
||||
PrepareThinLtoContext,
|
||||
#[diag(codegen_llvm_load_bitcode)]
|
||||
LoadBitcode { name: CString },
|
||||
#[diag(codegen_llvm_write_thinlto_key)]
|
||||
WriteThinLtoKey { err: std::io::Error },
|
||||
#[diag(codegen_llvm_multiple_source_dicompileunit)]
|
||||
MultipleSourceDiCompileUnit,
|
||||
#[diag(codegen_llvm_prepare_thin_lto_module)]
|
||||
PrepareThinLtoModule,
|
||||
#[diag(codegen_llvm_parse_bitcode)]
|
||||
ParseBitcode,
|
||||
}
|
||||
|
||||
pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String);
|
||||
|
||||
impl<EM: EmissionGuarantee> IntoDiagnostic<'_, EM> for WithLlvmError<'_> {
|
||||
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, EM> {
|
||||
use LlvmError::*;
|
||||
let msg_with_llvm_err = match &self.0 {
|
||||
WriteOutput { .. } => fluent::codegen_llvm_write_output_with_llvm_err,
|
||||
CreateTargetMachine { .. } => fluent::codegen_llvm_target_machine_with_llvm_err,
|
||||
RunLlvmPasses => fluent::codegen_llvm_run_passes_with_llvm_err,
|
||||
SerializeModule { .. } => fluent::codegen_llvm_serialize_module_with_llvm_err,
|
||||
WriteIr { .. } => fluent::codegen_llvm_write_ir_with_llvm_err,
|
||||
PrepareThinLtoContext => fluent::codegen_llvm_prepare_thin_lto_context_with_llvm_err,
|
||||
LoadBitcode { .. } => fluent::codegen_llvm_load_bitcode_with_llvm_err,
|
||||
WriteThinLtoKey { .. } => fluent::codegen_llvm_write_thinlto_key_with_llvm_err,
|
||||
MultipleSourceDiCompileUnit => {
|
||||
fluent::codegen_llvm_multiple_source_dicompileunit_with_llvm_err
|
||||
}
|
||||
PrepareThinLtoModule => fluent::codegen_llvm_prepare_thin_lto_module_with_llvm_err,
|
||||
ParseBitcode => fluent::codegen_llvm_parse_bitcode_with_llvm_err,
|
||||
};
|
||||
let mut diag = self.0.into_diagnostic(sess);
|
||||
diag.set_primary_message(msg_with_llvm_err);
|
||||
diag.set_arg("llvm_err", self.1);
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_from_llvm_optimization_diag)]
|
||||
pub(crate) struct FromLlvmOptimizationDiag<'a> {
|
||||
pub filename: &'a str,
|
||||
pub line: std::ffi::c_uint,
|
||||
pub column: std::ffi::c_uint,
|
||||
pub pass_name: &'a str,
|
||||
pub message: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_from_llvm_diag)]
|
||||
pub(crate) struct FromLlvmDiag {
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_write_bytecode)]
|
||||
pub(crate) struct WriteBytecode<'a> {
|
||||
pub path: &'a Path,
|
||||
pub err: std::io::Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_llvm_copy_bitcode)]
|
||||
pub(crate) struct CopyBitcode {
|
||||
pub err: std::io::Error,
|
||||
}
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(hash_raw_entry)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(extern_types)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(hash_raw_entry)]
|
||||
#![feature(iter_intersperse)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(never_type)]
|
||||
#![feature(once_cell)]
|
||||
#![recursion_limit = "256"]
|
||||
#![allow(rustc::potential_query_instability)]
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
|
@ -22,7 +23,7 @@ extern crate tracing;
|
|||
|
||||
use back::write::{create_informational_target_machine, create_target_machine};
|
||||
|
||||
use errors::FailParsingTargetMachineConfigToTargetMachine;
|
||||
use errors::ParseTargetMachineConfig;
|
||||
pub use llvm_util::target_features;
|
||||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
|
||||
|
@ -169,6 +170,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
|
|||
type Module = ModuleLlvm;
|
||||
type ModuleBuffer = back::lto::ModuleBuffer;
|
||||
type TargetMachine = &'static mut llvm::TargetMachine;
|
||||
type TargetMachineError = crate::errors::LlvmError<'static>;
|
||||
type ThinData = back::lto::ThinData;
|
||||
type ThinBuffer = back::lto::ThinBuffer;
|
||||
fn print_pass_timings(&self) {
|
||||
|
@ -416,8 +418,7 @@ impl ModuleLlvm {
|
|||
let tm = match (cgcx.tm_factory)(tm_factory_config) {
|
||||
Ok(m) => m,
|
||||
Err(e) => {
|
||||
handler.emit_err(FailParsingTargetMachineConfigToTargetMachine { error: e });
|
||||
return Err(FatalError);
|
||||
return Err(handler.emit_almost_fatal(ParseTargetMachineConfig(e)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue