2014-11-16 01:30:33 +00:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-11-26 02:17:11 +00:00
|
|
|
//! The Rust compiler.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2015-08-09 21:15:05 +00:00
|
|
|
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
2015-05-15 23:04:01 +00:00
|
|
|
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
|
2015-08-09 21:15:05 +00:00
|
|
|
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2015-02-10 21:52:44 +00:00
|
|
|
#![feature(box_patterns)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(box_syntax)]
|
2015-09-27 20:20:49 +00:00
|
|
|
#![feature(custom_attribute)]
|
2018-01-10 16:58:39 +00:00
|
|
|
#![feature(fs_read_write)]
|
2015-09-27 20:20:49 +00:00
|
|
|
#![allow(unused_attributes)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(libc)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(quote)]
|
2018-04-22 16:40:54 +00:00
|
|
|
#![feature(range_contains)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2018-03-30 09:23:27 +00:00
|
|
|
#![feature(slice_sort_by_cached_key)]
|
2017-10-30 17:42:21 +00:00
|
|
|
#![feature(optin_builtin_traits)]
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2016-07-25 14:51:14 +00:00
|
|
|
use rustc::dep_graph::WorkProduct;
|
2017-04-13 18:58:20 +00:00
|
|
|
use syntax_pos::symbol::Symbol;
|
2016-07-21 16:49:59 +00:00
|
|
|
|
2018-05-11 10:26:32 +00:00
|
|
|
#[macro_use] extern crate bitflags;
|
2017-06-08 21:10:36 +00:00
|
|
|
extern crate flate2;
|
2014-11-16 01:30:33 +00:00
|
|
|
extern crate libc;
|
2016-03-28 23:46:02 +00:00
|
|
|
#[macro_use] extern crate rustc;
|
2017-10-23 03:01:00 +00:00
|
|
|
extern crate jobserver;
|
|
|
|
extern crate num_cpus;
|
2017-10-25 13:39:54 +00:00
|
|
|
extern crate rustc_mir;
|
2017-06-03 21:54:08 +00:00
|
|
|
extern crate rustc_allocator;
|
2017-10-09 00:14:00 +00:00
|
|
|
extern crate rustc_apfloat;
|
2017-12-08 19:18:21 +00:00
|
|
|
extern crate rustc_target;
|
2018-03-03 05:17:06 +00:00
|
|
|
#[macro_use] extern crate rustc_data_structures;
|
2017-10-23 03:01:00 +00:00
|
|
|
extern crate rustc_demangle;
|
2016-03-28 21:36:56 +00:00
|
|
|
extern crate rustc_incremental;
|
2017-08-19 00:09:55 +00:00
|
|
|
extern crate rustc_llvm as llvm;
|
2015-07-16 23:46:36 +00:00
|
|
|
extern crate rustc_platform_intrinsics as intrinsics;
|
2018-05-08 13:10:16 +00:00
|
|
|
extern crate rustc_codegen_utils;
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2015-01-06 17:24:46 +00:00
|
|
|
#[macro_use] extern crate log;
|
|
|
|
#[macro_use] extern crate syntax;
|
2016-06-21 22:08:13 +00:00
|
|
|
extern crate syntax_pos;
|
|
|
|
extern crate rustc_errors as errors;
|
2017-02-03 14:58:13 +00:00
|
|
|
extern crate serialize;
|
2017-09-23 04:34:27 +00:00
|
|
|
extern crate cc; // Used to locate MSVC
|
2018-05-08 20:11:58 +00:00
|
|
|
extern crate tempfile;
|
2015-01-01 04:43:46 +00:00
|
|
|
|
2017-10-20 01:44:33 +00:00
|
|
|
use back::bytecode::RLIB_BYTECODE_EXTENSION;
|
2016-03-22 17:23:36 +00:00
|
|
|
|
2018-01-22 15:29:24 +00:00
|
|
|
pub use llvm_util::target_features;
|
2017-04-26 21:22:45 +00:00
|
|
|
|
2017-07-23 15:14:38 +00:00
|
|
|
use std::any::Any;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::sync::mpsc;
|
2018-02-27 16:11:14 +00:00
|
|
|
use rustc_data_structures::sync::Lrc;
|
2017-08-29 00:06:03 +00:00
|
|
|
|
2017-07-23 15:14:38 +00:00
|
|
|
use rustc::dep_graph::DepGraph;
|
2017-09-13 20:22:20 +00:00
|
|
|
use rustc::hir::def_id::CrateNum;
|
2017-07-23 15:14:38 +00:00
|
|
|
use rustc::middle::cstore::MetadataLoader;
|
2017-08-31 19:08:29 +00:00
|
|
|
use rustc::middle::cstore::{NativeLibrary, CrateSource, LibSource};
|
2018-03-23 21:33:22 +00:00
|
|
|
use rustc::middle::lang_items::LangItem;
|
2017-10-30 17:42:21 +00:00
|
|
|
use rustc::session::{Session, CompileIncomplete};
|
|
|
|
use rustc::session::config::{OutputFilenames, OutputType, PrintRequest};
|
2017-07-23 15:14:38 +00:00
|
|
|
use rustc::ty::{self, TyCtxt};
|
2018-06-23 11:52:52 +00:00
|
|
|
use rustc::util::time_graph;
|
2017-09-12 16:32:37 +00:00
|
|
|
use rustc::util::nodemap::{FxHashSet, FxHashMap};
|
2017-10-25 14:14:51 +00:00
|
|
|
use rustc_mir::monomorphize;
|
2018-05-08 13:10:16 +00:00
|
|
|
use rustc_codegen_utils::codegen_backend::CodegenBackend;
|
2017-10-19 09:01:31 +00:00
|
|
|
|
2017-09-12 19:18:11 +00:00
|
|
|
mod diagnostics;
|
|
|
|
|
2017-12-27 18:03:48 +00:00
|
|
|
mod back {
|
2018-05-08 13:10:16 +00:00
|
|
|
pub use rustc_codegen_utils::symbol_names;
|
2017-05-27 18:13:32 +00:00
|
|
|
mod archive;
|
2017-10-20 01:44:33 +00:00
|
|
|
pub mod bytecode;
|
2017-08-26 03:16:51 +00:00
|
|
|
mod command;
|
2017-12-27 18:03:48 +00:00
|
|
|
pub mod linker;
|
2014-11-16 01:30:33 +00:00
|
|
|
pub mod link;
|
2018-07-16 06:58:56 +00:00
|
|
|
mod lto;
|
2017-12-27 18:03:48 +00:00
|
|
|
pub mod symbol_export;
|
2014-11-16 01:30:33 +00:00
|
|
|
pub mod write;
|
2017-08-19 00:09:55 +00:00
|
|
|
mod rpath;
|
2018-06-01 17:20:00 +00:00
|
|
|
pub mod wasm;
|
2014-11-16 01:30:33 +00:00
|
|
|
}
|
|
|
|
|
2016-03-22 17:23:36 +00:00
|
|
|
mod abi;
|
2017-06-03 21:54:08 +00:00
|
|
|
mod allocator;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod asm;
|
|
|
|
mod attributes;
|
|
|
|
mod base;
|
|
|
|
mod builder;
|
|
|
|
mod callee;
|
|
|
|
mod common;
|
|
|
|
mod consts;
|
|
|
|
mod context;
|
|
|
|
mod debuginfo;
|
|
|
|
mod declare;
|
2018-06-22 17:28:06 +00:00
|
|
|
mod glue;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod intrinsic;
|
2017-04-30 18:33:25 +00:00
|
|
|
mod llvm_util;
|
2017-04-26 21:22:45 +00:00
|
|
|
mod metadata;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod meth;
|
|
|
|
mod mir;
|
2018-05-08 13:10:16 +00:00
|
|
|
mod mono_item;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod type_;
|
|
|
|
mod type_of;
|
|
|
|
mod value;
|
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
pub struct LlvmCodegenBackend(());
|
2017-09-16 15:27:29 +00:00
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
impl !Send for LlvmCodegenBackend {} // Llvm is on a per-thread basis
|
|
|
|
impl !Sync for LlvmCodegenBackend {}
|
2017-10-30 17:42:21 +00:00
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
impl LlvmCodegenBackend {
|
2018-07-11 10:49:11 +00:00
|
|
|
pub fn new() -> Box<dyn CodegenBackend> {
|
2018-05-08 13:10:16 +00:00
|
|
|
box LlvmCodegenBackend(())
|
2017-09-16 15:27:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
impl CodegenBackend for LlvmCodegenBackend {
|
2018-01-22 15:29:24 +00:00
|
|
|
fn init(&self, sess: &Session) {
|
|
|
|
llvm_util::init(sess); // Make sure llvm is inited
|
|
|
|
}
|
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
fn print(&self, req: PrintRequest, sess: &Session) {
|
|
|
|
match req {
|
|
|
|
PrintRequest::RelocationModels => {
|
|
|
|
println!("Available relocation models:");
|
|
|
|
for &(name, _) in back::write::RELOC_MODEL_ARGS.iter() {
|
|
|
|
println!(" {}", name);
|
|
|
|
}
|
|
|
|
println!("");
|
|
|
|
}
|
|
|
|
PrintRequest::CodeModels => {
|
|
|
|
println!("Available code models:");
|
|
|
|
for &(name, _) in back::write::CODE_GEN_MODEL_ARGS.iter(){
|
|
|
|
println!(" {}", name);
|
|
|
|
}
|
|
|
|
println!("");
|
|
|
|
}
|
|
|
|
PrintRequest::TlsModels => {
|
|
|
|
println!("Available TLS models:");
|
|
|
|
for &(name, _) in back::write::TLS_MODEL_ARGS.iter(){
|
|
|
|
println!(" {}", name);
|
|
|
|
}
|
|
|
|
println!("");
|
|
|
|
}
|
|
|
|
req => llvm_util::print(req, sess),
|
|
|
|
}
|
|
|
|
}
|
2017-09-16 15:27:29 +00:00
|
|
|
|
2018-01-22 15:29:24 +00:00
|
|
|
fn print_passes(&self) {
|
|
|
|
llvm_util::print_passes();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn print_version(&self) {
|
|
|
|
llvm_util::print_version();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn diagnostics(&self) -> &[(&'static str, &'static str)] {
|
|
|
|
&DIAGNOSTICS
|
|
|
|
}
|
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
fn target_features(&self, sess: &Session) -> Vec<Symbol> {
|
|
|
|
target_features(sess)
|
|
|
|
}
|
|
|
|
|
2018-07-11 10:49:11 +00:00
|
|
|
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
|
2017-09-16 15:27:29 +00:00
|
|
|
box metadata::LlvmMetadataLoader
|
|
|
|
}
|
|
|
|
|
2018-06-13 13:44:43 +00:00
|
|
|
fn provide(&self, providers: &mut ty::query::Providers) {
|
2017-11-12 16:00:18 +00:00
|
|
|
back::symbol_names::provide(providers);
|
|
|
|
back::symbol_export::provide(providers);
|
|
|
|
base::provide(providers);
|
2018-01-05 21:26:26 +00:00
|
|
|
attributes::provide(providers);
|
2017-09-23 12:46:15 +00:00
|
|
|
}
|
|
|
|
|
2018-06-13 13:44:43 +00:00
|
|
|
fn provide_extern(&self, providers: &mut ty::query::Providers) {
|
2017-11-12 16:00:18 +00:00
|
|
|
back::symbol_export::provide_extern(providers);
|
2018-02-10 22:28:17 +00:00
|
|
|
base::provide_extern(providers);
|
|
|
|
attributes::provide_extern(providers);
|
2017-09-16 15:27:29 +00:00
|
|
|
}
|
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
fn codegen_crate<'a, 'tcx>(
|
2017-10-30 17:42:21 +00:00
|
|
|
&self,
|
2017-09-16 15:27:29 +00:00
|
|
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
2018-07-11 10:49:11 +00:00
|
|
|
rx: mpsc::Receiver<Box<dyn Any + Send>>
|
|
|
|
) -> Box<dyn Any> {
|
2018-05-08 13:10:16 +00:00
|
|
|
box base::codegen_crate(tcx, rx)
|
2017-09-16 15:27:29 +00:00
|
|
|
}
|
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
fn join_codegen_and_link(
|
2017-10-30 17:42:21 +00:00
|
|
|
&self,
|
2018-07-11 10:49:11 +00:00
|
|
|
ongoing_codegen: Box<dyn Any>,
|
2017-09-16 15:27:29 +00:00
|
|
|
sess: &Session,
|
2017-10-30 17:42:21 +00:00
|
|
|
dep_graph: &DepGraph,
|
|
|
|
outputs: &OutputFilenames,
|
|
|
|
) -> Result<(), CompileIncomplete>{
|
|
|
|
use rustc::util::common::time;
|
2018-05-08 13:10:16 +00:00
|
|
|
let (ongoing_codegen, work_products) =
|
|
|
|
ongoing_codegen.downcast::<::back::write::OngoingCodegen>()
|
|
|
|
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
|
|
|
|
.join(sess);
|
2017-10-30 17:42:21 +00:00
|
|
|
if sess.opts.debugging_opts.incremental_info {
|
2018-05-08 13:10:16 +00:00
|
|
|
back::write::dump_incremental_data(&ongoing_codegen);
|
2017-10-30 17:42:21 +00:00
|
|
|
}
|
2017-09-16 15:27:29 +00:00
|
|
|
|
2017-12-03 13:21:23 +00:00
|
|
|
time(sess,
|
2017-10-30 17:42:21 +00:00
|
|
|
"serialize work products",
|
2018-05-09 15:16:08 +00:00
|
|
|
move || rustc_incremental::save_work_product_index(sess, &dep_graph, work_products));
|
2017-10-30 17:42:21 +00:00
|
|
|
|
|
|
|
sess.compile_status()?;
|
|
|
|
|
|
|
|
if !sess.opts.output_types.keys().any(|&i| i == OutputType::Exe ||
|
|
|
|
i == OutputType::Metadata) {
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run the linker on any artifacts that resulted from the LLVM run.
|
|
|
|
// This should produce either a finished executable or library.
|
2017-12-03 13:21:23 +00:00
|
|
|
time(sess, "linking", || {
|
2018-05-08 13:10:16 +00:00
|
|
|
back::link::link_binary(sess, &ongoing_codegen,
|
|
|
|
outputs, &ongoing_codegen.crate_name.as_str());
|
2017-10-30 17:42:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Now that we won't touch anything in the incremental compilation directory
|
|
|
|
// any more, we can finalize it (which involves renaming it)
|
2018-05-08 13:10:16 +00:00
|
|
|
rustc_incremental::finalize_session_directory(sess, ongoing_codegen.link.crate_hash);
|
2017-09-16 15:27:29 +00:00
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
Ok(())
|
2017-09-16 15:27:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
/// This is the entrypoint for a hot plugged rustc_codegen_llvm
|
2018-01-04 11:40:11 +00:00
|
|
|
#[no_mangle]
|
2018-07-11 10:49:11 +00:00
|
|
|
pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
|
2018-05-08 13:10:16 +00:00
|
|
|
LlvmCodegenBackend::new()
|
2018-01-04 11:40:11 +00:00
|
|
|
}
|
2018-01-01 11:17:07 +00:00
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
struct ModuleCodegen {
|
2016-07-25 14:51:14 +00:00
|
|
|
/// The name of the module. When the crate may be saved between
|
|
|
|
/// compilations, incremental compilation requires that name be
|
|
|
|
/// unique amongst **all** crates. Therefore, it should contain
|
|
|
|
/// something unique to this crate (e.g., a module path) as well
|
|
|
|
/// as the crate name and disambiguator.
|
2017-08-19 00:09:55 +00:00
|
|
|
name: String,
|
2018-07-16 06:58:29 +00:00
|
|
|
llmod_id: String,
|
2017-12-27 18:03:48 +00:00
|
|
|
source: ModuleSource,
|
|
|
|
kind: ModuleKind,
|
2017-07-25 15:26:24 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 15:14:38 +00:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
2017-12-28 09:11:26 +00:00
|
|
|
enum ModuleKind {
|
2017-07-25 15:26:24 +00:00
|
|
|
Regular,
|
|
|
|
Metadata,
|
|
|
|
Allocator,
|
|
|
|
}
|
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
impl ModuleCodegen {
|
2017-12-27 18:03:48 +00:00
|
|
|
fn llvm(&self) -> Option<&ModuleLlvm> {
|
2017-07-23 15:14:38 +00:00
|
|
|
match self.source {
|
2018-05-08 13:10:16 +00:00
|
|
|
ModuleSource::Codegened(ref llvm) => Some(llvm),
|
2017-07-23 15:14:38 +00:00
|
|
|
ModuleSource::Preexisting(_) => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-27 18:03:48 +00:00
|
|
|
fn into_compiled_module(self,
|
2017-07-23 15:14:38 +00:00
|
|
|
emit_obj: bool,
|
|
|
|
emit_bc: bool,
|
2017-10-20 01:44:33 +00:00
|
|
|
emit_bc_compressed: bool,
|
2017-07-23 15:14:38 +00:00
|
|
|
outputs: &OutputFilenames) -> CompiledModule {
|
2017-07-25 15:26:24 +00:00
|
|
|
let pre_existing = match self.source {
|
|
|
|
ModuleSource::Preexisting(_) => true,
|
2018-05-08 13:10:16 +00:00
|
|
|
ModuleSource::Codegened(_) => false,
|
2017-07-25 15:26:24 +00:00
|
|
|
};
|
2017-10-20 01:44:33 +00:00
|
|
|
let object = if emit_obj {
|
|
|
|
Some(outputs.temp_path(OutputType::Object, Some(&self.name)))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
|
|
|
let bytecode = if emit_bc {
|
|
|
|
Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
|
|
|
let bytecode_compressed = if emit_bc_compressed {
|
|
|
|
Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name))
|
|
|
|
.with_extension(RLIB_BYTECODE_EXTENSION))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
2017-07-25 15:26:24 +00:00
|
|
|
|
|
|
|
CompiledModule {
|
2018-07-16 06:58:29 +00:00
|
|
|
llmod_id: self.llmod_id,
|
2017-07-25 15:26:24 +00:00
|
|
|
name: self.name.clone(),
|
|
|
|
kind: self.kind,
|
|
|
|
pre_existing,
|
2017-07-23 15:14:38 +00:00
|
|
|
object,
|
2017-10-20 01:44:33 +00:00
|
|
|
bytecode,
|
|
|
|
bytecode_compressed,
|
2017-07-25 15:26:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2017-12-28 09:11:26 +00:00
|
|
|
struct CompiledModule {
|
2017-12-27 18:03:48 +00:00
|
|
|
name: String,
|
2018-07-16 06:58:29 +00:00
|
|
|
llmod_id: String,
|
2017-12-27 18:03:48 +00:00
|
|
|
kind: ModuleKind,
|
|
|
|
pre_existing: bool,
|
|
|
|
object: Option<PathBuf>,
|
|
|
|
bytecode: Option<PathBuf>,
|
|
|
|
bytecode_compressed: Option<PathBuf>,
|
2016-07-21 16:49:59 +00:00
|
|
|
}
|
|
|
|
|
2017-12-27 18:03:48 +00:00
|
|
|
enum ModuleSource {
|
2016-07-25 14:51:14 +00:00
|
|
|
/// Copy the `.o` files or whatever from the incr. comp. directory.
|
|
|
|
Preexisting(WorkProduct),
|
|
|
|
|
|
|
|
/// Rebuild from this LLVM module.
|
2018-05-08 13:10:16 +00:00
|
|
|
Codegened(ModuleLlvm),
|
2016-07-21 16:49:59 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 15:14:38 +00:00
|
|
|
#[derive(Debug)]
|
2017-12-28 09:11:26 +00:00
|
|
|
struct ModuleLlvm {
|
2017-08-19 00:09:55 +00:00
|
|
|
llcx: llvm::ContextRef,
|
2017-12-27 18:03:48 +00:00
|
|
|
llmod: llvm::ModuleRef,
|
2017-07-23 15:14:38 +00:00
|
|
|
tm: llvm::TargetMachineRef,
|
2016-03-22 17:23:36 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 15:14:38 +00:00
|
|
|
unsafe impl Send for ModuleLlvm { }
|
|
|
|
unsafe impl Sync for ModuleLlvm { }
|
|
|
|
|
|
|
|
impl Drop for ModuleLlvm {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
unsafe {
|
|
|
|
llvm::LLVMDisposeModule(self.llmod);
|
|
|
|
llvm::LLVMContextDispose(self.llcx);
|
|
|
|
llvm::LLVMRustDisposeTargetMachine(self.tm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
struct CodegenResults {
|
2017-12-27 18:03:48 +00:00
|
|
|
crate_name: Symbol,
|
|
|
|
modules: Vec<CompiledModule>,
|
2017-08-19 00:09:55 +00:00
|
|
|
allocator_module: Option<CompiledModule>,
|
2017-10-20 01:44:33 +00:00
|
|
|
metadata_module: CompiledModule,
|
2017-12-27 18:03:48 +00:00
|
|
|
link: rustc::middle::cstore::LinkMeta,
|
|
|
|
metadata: rustc::middle::cstore::EncodedMetadata,
|
2017-08-19 00:09:55 +00:00
|
|
|
windows_subsystem: Option<String>,
|
2017-08-28 22:55:32 +00:00
|
|
|
linker_info: back::linker::LinkerInfo,
|
|
|
|
crate_info: CrateInfo,
|
|
|
|
}
|
|
|
|
|
2018-06-15 17:02:41 +00:00
|
|
|
/// Misc info we load from metadata to persist beyond the tcx
|
2017-12-28 09:11:26 +00:00
|
|
|
struct CrateInfo {
|
2017-08-28 22:55:32 +00:00
|
|
|
panic_runtime: Option<CrateNum>,
|
|
|
|
compiler_builtins: Option<CrateNum>,
|
|
|
|
profiler_runtime: Option<CrateNum>,
|
|
|
|
sanitizer_runtime: Option<CrateNum>,
|
|
|
|
is_no_builtins: FxHashSet<CrateNum>,
|
2018-02-27 16:11:14 +00:00
|
|
|
native_libraries: FxHashMap<CrateNum, Lrc<Vec<NativeLibrary>>>,
|
2017-08-31 15:07:39 +00:00
|
|
|
crate_name: FxHashMap<CrateNum, String>,
|
2018-02-27 16:11:14 +00:00
|
|
|
used_libraries: Lrc<Vec<NativeLibrary>>,
|
|
|
|
link_args: Lrc<Vec<String>>,
|
|
|
|
used_crate_source: FxHashMap<CrateNum, Lrc<CrateSource>>,
|
2017-08-31 19:08:29 +00:00
|
|
|
used_crates_static: Vec<(CrateNum, LibSource)>,
|
|
|
|
used_crates_dynamic: Vec<(CrateNum, LibSource)>,
|
2018-02-10 22:28:17 +00:00
|
|
|
wasm_imports: FxHashMap<String, String>,
|
2018-03-23 21:33:22 +00:00
|
|
|
lang_item_to_crate: FxHashMap<LangItem, CrateNum>,
|
2018-04-04 23:54:30 +00:00
|
|
|
missing_lang_items: FxHashMap<CrateNum, Vec<LangItem>>,
|
2014-11-16 01:30:33 +00:00
|
|
|
}
|
2015-11-22 04:52:25 +00:00
|
|
|
|
2018-05-08 13:10:16 +00:00
|
|
|
__build_diagnostic_array! { librustc_codegen_llvm, DIAGNOSTICS }
|