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/")]
|
2016-12-29 17:47:34 +00:00
|
|
|
#![deny(warnings)]
|
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)]
|
2017-02-01 23:57:50 +00:00
|
|
|
#![feature(i128_type)]
|
2017-10-09 00:14:00 +00:00
|
|
|
#![feature(i128)]
|
2017-09-16 20:12:39 +00:00
|
|
|
#![feature(inclusive_range)]
|
2017-09-26 11:41:06 +00:00
|
|
|
#![feature(inclusive_range_syntax)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(libc)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(quote)]
|
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2015-10-21 21:20:00 +00:00
|
|
|
#![feature(slice_patterns)]
|
2016-12-17 15:24:17 +00:00
|
|
|
#![feature(conservative_impl_trait)]
|
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
|
|
|
|
2017-09-08 19:08:01 +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;
|
2014-11-16 01:30:33 +00:00
|
|
|
extern crate rustc_back;
|
2017-10-23 03:01:00 +00:00
|
|
|
extern crate rustc_binaryen;
|
|
|
|
extern crate rustc_const_math;
|
2015-11-02 14:39:59 +00:00
|
|
|
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;
|
2017-08-26 15:31:32 +00:00
|
|
|
extern crate rustc_trans_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-05-24 02:02:23 +00:00
|
|
|
#[cfg(windows)]
|
2017-09-23 04:34:27 +00:00
|
|
|
extern crate cc; // Used to locate MSVC
|
2017-11-27 15:21:13 +00:00
|
|
|
extern crate tempdir;
|
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};
|
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};
|
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;
|
2017-10-30 17:42:21 +00:00
|
|
|
use rustc_trans_utils::trans_crate::TransCrate;
|
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 {
|
|
|
|
pub use rustc_trans_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;
|
2017-05-27 18:13:32 +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;
|
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 cabi_aarch64;
|
|
|
|
mod cabi_arm;
|
|
|
|
mod cabi_asmjs;
|
2017-04-09 06:03:31 +00:00
|
|
|
mod cabi_hexagon;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod cabi_mips;
|
2016-08-26 22:06:13 +00:00
|
|
|
mod cabi_mips64;
|
2016-11-13 16:03:44 +00:00
|
|
|
mod cabi_msp430;
|
2016-12-22 21:24:29 +00:00
|
|
|
mod cabi_nvptx;
|
|
|
|
mod cabi_nvptx64;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod cabi_powerpc;
|
|
|
|
mod cabi_powerpc64;
|
2016-09-09 21:00:23 +00:00
|
|
|
mod cabi_s390x;
|
2016-12-12 17:41:45 +00:00
|
|
|
mod cabi_sparc;
|
2016-12-03 16:55:50 +00:00
|
|
|
mod cabi_sparc64;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod cabi_x86;
|
|
|
|
mod cabi_x86_64;
|
|
|
|
mod cabi_x86_win64;
|
|
|
|
mod callee;
|
|
|
|
mod common;
|
|
|
|
mod consts;
|
|
|
|
mod context;
|
|
|
|
mod debuginfo;
|
|
|
|
mod declare;
|
|
|
|
mod glue;
|
|
|
|
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;
|
2017-07-27 11:02:31 +00:00
|
|
|
mod time_graph;
|
2016-05-09 17:37:14 +00:00
|
|
|
mod trans_item;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod type_;
|
|
|
|
mod type_of;
|
|
|
|
mod value;
|
|
|
|
|
2017-09-16 15:27:29 +00:00
|
|
|
pub struct LlvmTransCrate(());
|
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
impl !Send for LlvmTransCrate {} // Llvm is on a per-thread basis
|
|
|
|
impl !Sync for LlvmTransCrate {}
|
|
|
|
|
2017-09-16 15:27:29 +00:00
|
|
|
impl LlvmTransCrate {
|
2018-01-22 15:29:24 +00:00
|
|
|
pub fn new() -> Box<TransCrate> {
|
2017-10-30 17:42:21 +00:00
|
|
|
box LlvmTransCrate(())
|
2017-09-16 15:27:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
impl TransCrate for LlvmTransCrate {
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn metadata_loader(&self) -> Box<MetadataLoader> {
|
2017-09-16 15:27:29 +00:00
|
|
|
box metadata::LlvmMetadataLoader
|
|
|
|
}
|
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
fn provide(&self, providers: &mut ty::maps::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
|
|
|
}
|
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
fn provide_extern(&self, providers: &mut ty::maps::Providers) {
|
2017-11-12 16:00:18 +00:00
|
|
|
back::symbol_export::provide_extern(providers);
|
2017-09-16 15:27:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn trans_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>,
|
2017-09-23 12:46:15 +00:00
|
|
|
rx: mpsc::Receiver<Box<Any + Send>>
|
2017-10-30 17:42:21 +00:00
|
|
|
) -> Box<Any> {
|
|
|
|
box base::trans_crate(tcx, rx)
|
2017-09-16 15:27:29 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
fn join_trans_and_link(
|
|
|
|
&self,
|
|
|
|
trans: Box<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;
|
|
|
|
let trans = trans.downcast::<::back::write::OngoingCrateTranslation>()
|
|
|
|
.expect("Expected LlvmTransCrate's OngoingCrateTranslation, found Box<Any>")
|
|
|
|
.join(sess, dep_graph);
|
|
|
|
if sess.opts.debugging_opts.incremental_info {
|
|
|
|
back::write::dump_incremental_data(&trans);
|
|
|
|
}
|
2017-09-16 15:27:29 +00:00
|
|
|
|
2017-10-30 17:42:21 +00:00
|
|
|
time(sess.time_passes(),
|
|
|
|
"serialize work products",
|
|
|
|
move || rustc_incremental::save_work_products(sess, &dep_graph));
|
|
|
|
|
|
|
|
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.
|
|
|
|
time(sess.time_passes(), "linking", || {
|
|
|
|
back::link::link_binary(sess, &trans, outputs, &trans.crate_name.as_str());
|
|
|
|
});
|
|
|
|
|
|
|
|
// Now that we won't touch anything in the incremental compilation directory
|
|
|
|
// any more, we can finalize it (which involves renaming it)
|
|
|
|
rustc_incremental::finalize_session_directory(sess, trans.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-01-04 11:40:11 +00:00
|
|
|
/// This is the entrypoint for a hot plugged rustc_trans
|
|
|
|
#[no_mangle]
|
2018-01-22 15:29:24 +00:00
|
|
|
pub fn __rustc_codegen_backend() -> Box<TransCrate> {
|
|
|
|
LlvmTransCrate::new()
|
2018-01-04 11:40:11 +00:00
|
|
|
}
|
2018-01-01 11:17:07 +00:00
|
|
|
|
2017-12-28 09:11:26 +00:00
|
|
|
struct ModuleTranslation {
|
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,
|
2017-07-23 15:14:38 +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,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ModuleTranslation {
|
2017-12-27 18:03:48 +00:00
|
|
|
fn llvm(&self) -> Option<&ModuleLlvm> {
|
2017-07-23 15:14:38 +00:00
|
|
|
match self.source {
|
|
|
|
ModuleSource::Translated(ref llvm) => Some(llvm),
|
|
|
|
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,
|
|
|
|
ModuleSource::Translated(_) => false,
|
|
|
|
};
|
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 {
|
2017-07-23 15:14:38 +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,
|
|
|
|
llmod_id: String,
|
|
|
|
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.
|
2016-07-21 16:49:59 +00:00
|
|
|
Translated(ModuleLlvm),
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2017-12-28 09:11:26 +00:00
|
|
|
struct CrateTranslation {
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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)>,
|
2014-11-16 01:30:33 +00:00
|
|
|
}
|
2015-11-22 04:52:25 +00:00
|
|
|
|
|
|
|
__build_diagnostic_array! { librustc_trans, DIAGNOSTICS }
|