CodegenContext::create_diag_handler
CodegenContext::create_dcx
Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.