Change:
Self-hosted compiler will require bindings to LLVM.
This is part-way done, but needs more work. Pretty straightforward semi-mechanical translation from llvm-c/Core.h and friends.
Done long ago

Discussion:
use std::fs::File; use std::path::{Path, PathBuf}; <del> use rustc_session::Session; </del> use rustc_codegen_ssa::back::archive::ArchiveBuilder; <ins> use rustc_session::Session; </ins> use rustc_data_structures::temp_dir::MaybeTempDir; <del> use rustc_middle::middle::cstore::DllImport; </del> <ins> use rustc_session::cstore::DllImport; </ins> struct ArchiveConfig<'a> { sess: &'a Session,

GlobalKind, }; use rustc_middle::dep_graph; <del> use rustc_middle::middle::cstore::EncodedMetadata; </del> use rustc_middle::middle::exported_symbols; use rustc_middle::ty::TyCtxt; use rustc_middle::mir::mono::Linkage;

use rustc_codegen_ssa::base::maybe_create_entry_wrapper; use rustc_codegen_ssa::mono_item::MonoItemExt; use rustc_codegen_ssa::traits::DebugInfoMethods; <ins> use rustc_metadata::EncodedMetadata; </ins> use rustc_session::config::DebugInfo; use rustc_span::Symbol;

let context = &gcc_module.context; let mut compressed = rustc_metadata::METADATA_HEADER.to_vec(); <del> FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap(); </del> <ins> FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data()).unwrap(); </ins> let name = exported_symbols::metadata_symbol_name(tcx); let typ = context.new_array_type(None, context.new_type::<u8>(), compressed.len() as i32);

// TODO(antoyo) } <ins> fn type_metadata(&mut self, _function: RValue<'gcc>, _typeid: String) { // Unsupported. } fn typeid_metadata(&mut self, _typeid: String) -> RValue<'gcc> { // Unsupported. self.context.new_rvalue_from_int(self.int_type, 0) } </ins> fn store(&mut self, val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> { self.store_with_flags(val, ptr, align, MemFlags::empty()) }

use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, VariableKind}; use rustc_codegen_ssa::traits::{DebugInfoBuilderMethods, DebugInfoMethods}; use rustc_middle::mir; <del> use rustc_middle::ty::{Instance, Ty}; </del> <ins> use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty}; </ins> use rustc_span::{SourceFile, Span, Symbol}; use rustc_target::abi::Size; use rustc_target::abi::call::FnAbi;

} impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> { <del> fn create_vtable_metadata(&self, _ty: Ty<'tcx>, _vtable: Self::Value) { </del> <ins> fn create_vtable_metadata(&self, _ty: Ty<'tcx>, _trait_ref: Option<PolyExistentialTraitRef<'tcx>>, _vtable: Self::Value) { </ins> // TODO(antoyo) }

// TODO(antoyo) } <ins> fn type_test(&mut self, _pointer: Self::Value, _typeid: Self::Value) -> Self::Value { // Unsupported. self.context.new_rvalue_from_int(self.int_type, 0) } </ins> fn va_start(&mut self, _va_list: RValue<'gcc>) -> RValue<'gcc> { unimplemented!(); }

use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{ErrorReported, Handler}; <ins> use rustc_metadata::EncodedMetadata; </ins> use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; <del> use rustc_middle::middle::cstore::EncodedMetadata; </del> use rustc_middle::ty::TyCtxt; use rustc_session::config::{Lto, OptLevel, OutputFilenames}; use rustc_session::Session;