2014-11-15 20:30:33 -05: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-25 21:17:11 -05:00
|
|
|
//! The Rust compiler.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
2014-11-15 20:30:33 -05:00
|
|
|
|
2015-08-09 14:15:05 -07:00
|
|
|
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
2015-05-15 16:04:01 -07:00
|
|
|
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
|
2015-08-09 14:15:05 -07:00
|
|
|
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2014-11-15 20:30:33 -05:00
|
|
|
|
2015-02-10 22:52:44 +01:00
|
|
|
#![feature(box_patterns)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(box_syntax)]
|
2015-09-28 09:20:49 +13:00
|
|
|
#![feature(custom_attribute)]
|
2018-01-10 08:58:39 -08:00
|
|
|
#![feature(fs_read_write)]
|
2015-09-28 09:20:49 +13:00
|
|
|
#![allow(unused_attributes)]
|
2015-01-22 18:22:03 -08:00
|
|
|
#![feature(libc)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(quote)]
|
2018-04-22 18:40:54 +02:00
|
|
|
#![feature(range_contains)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2018-03-30 10:23:27 +01:00
|
|
|
#![feature(slice_sort_by_cached_key)]
|
2017-10-30 18:42:21 +01:00
|
|
|
#![feature(optin_builtin_traits)]
|
2014-11-15 20:30:33 -05:00
|
|
|
|
2016-07-25 10:51:14 -04:00
|
|
|
use rustc::dep_graph::WorkProduct;
|
2017-04-13 14:58:20 -04:00
|
|
|
use syntax_pos::symbol::Symbol;
|
2016-07-21 12:49:59 -04:00
|
|
|
|
2018-05-11 12:26:32 +02:00
|
|
|
#[macro_use] extern crate bitflags;
|
2017-06-08 14:10:36 -07:00
|
|
|
extern crate flate2;
|
2014-11-15 20:30:33 -05:00
|
|
|
extern crate libc;
|
2016-03-29 01:46:02 +02:00
|
|
|
#[macro_use] extern crate rustc;
|
2017-10-22 20:01:00 -07:00
|
|
|
extern crate jobserver;
|
|
|
|
extern crate num_cpus;
|
2017-10-25 15:39:54 +02:00
|
|
|
extern crate rustc_mir;
|
2017-06-03 14:54:08 -07:00
|
|
|
extern crate rustc_allocator;
|
2017-10-09 02:14:00 +02:00
|
|
|
extern crate rustc_apfloat;
|
2017-12-08 21:18:21 +02:00
|
|
|
extern crate rustc_target;
|
2018-03-03 06:17:06 +01:00
|
|
|
#[macro_use] extern crate rustc_data_structures;
|
2017-10-22 20:01:00 -07:00
|
|
|
extern crate rustc_demangle;
|
2016-03-28 17:36:56 -04:00
|
|
|
extern crate rustc_incremental;
|
2017-08-19 03:09:55 +03:00
|
|
|
extern crate rustc_llvm as llvm;
|
2015-07-16 16:46:36 -07:00
|
|
|
extern crate rustc_platform_intrinsics as intrinsics;
|
2018-05-08 16:10:16 +03:00
|
|
|
extern crate rustc_codegen_utils;
|
2014-11-15 20:30:33 -05:00
|
|
|
|
2015-01-06 09:24:46 -08:00
|
|
|
#[macro_use] extern crate log;
|
|
|
|
#[macro_use] extern crate syntax;
|
2016-06-21 18:08:13 -04:00
|
|
|
extern crate syntax_pos;
|
|
|
|
extern crate rustc_errors as errors;
|
2017-02-03 14:58:13 +00:00
|
|
|
extern crate serialize;
|
2017-09-22 21:34:27 -07:00
|
|
|
extern crate cc; // Used to locate MSVC
|
2017-11-27 17:21:13 +02:00
|
|
|
extern crate tempdir;
|
2014-12-31 20:43:46 -08:00
|
|
|
|
2017-10-19 18:44:33 -07:00
|
|
|
use back::bytecode::RLIB_BYTECODE_EXTENSION;
|
2016-03-22 19:23:36 +02:00
|
|
|
|
2018-01-22 07:29:24 -08:00
|
|
|
pub use llvm_util::target_features;
|
2017-04-26 23:22:45 +02:00
|
|
|
|
2017-07-23 08:14:38 -07:00
|
|
|
use std::any::Any;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::sync::mpsc;
|
2018-03-09 09:26:15 -08:00
|
|
|
use std::collections::BTreeMap;
|
2018-02-27 17:11:14 +01:00
|
|
|
use rustc_data_structures::sync::Lrc;
|
2017-08-28 17:06:03 -07:00
|
|
|
|
2017-07-23 08:14:38 -07:00
|
|
|
use rustc::dep_graph::DepGraph;
|
2017-09-13 13:22:20 -07:00
|
|
|
use rustc::hir::def_id::CrateNum;
|
2017-07-23 08:14:38 -07:00
|
|
|
use rustc::middle::cstore::MetadataLoader;
|
2017-08-31 12:08:29 -07:00
|
|
|
use rustc::middle::cstore::{NativeLibrary, CrateSource, LibSource};
|
2018-03-23 14:33:22 -07:00
|
|
|
use rustc::middle::lang_items::LangItem;
|
2017-10-30 18:42:21 +01:00
|
|
|
use rustc::session::{Session, CompileIncomplete};
|
|
|
|
use rustc::session::config::{OutputFilenames, OutputType, PrintRequest};
|
2017-07-23 08:14:38 -07:00
|
|
|
use rustc::ty::{self, TyCtxt};
|
2017-09-12 09:32:37 -07:00
|
|
|
use rustc::util::nodemap::{FxHashSet, FxHashMap};
|
2017-10-25 16:14:51 +02:00
|
|
|
use rustc_mir::monomorphize;
|
2018-05-08 16:10:16 +03:00
|
|
|
use rustc_codegen_utils::codegen_backend::CodegenBackend;
|
2017-10-19 11:01:31 +02:00
|
|
|
|
2017-09-12 12:18:11 -07:00
|
|
|
mod diagnostics;
|
|
|
|
|
2017-12-27 19:03:48 +01:00
|
|
|
mod back {
|
2018-05-08 16:10:16 +03:00
|
|
|
pub use rustc_codegen_utils::symbol_names;
|
2017-05-27 20:13:32 +02:00
|
|
|
mod archive;
|
2017-10-19 18:44:33 -07:00
|
|
|
pub mod bytecode;
|
2017-08-25 20:16:51 -07:00
|
|
|
mod command;
|
2017-12-27 19:03:48 +01:00
|
|
|
pub mod linker;
|
2014-11-15 20:30:33 -05:00
|
|
|
pub mod link;
|
2017-05-27 20:13:32 +02:00
|
|
|
mod lto;
|
2017-12-27 19:03:48 +01:00
|
|
|
pub mod symbol_export;
|
2014-11-15 20:30:33 -05:00
|
|
|
pub mod write;
|
2017-08-19 03:09:55 +03:00
|
|
|
mod rpath;
|
2018-03-09 09:26:15 -08:00
|
|
|
mod wasm;
|
2014-11-15 20:30:33 -05:00
|
|
|
}
|
|
|
|
|
2016-03-22 19:23:36 +02:00
|
|
|
mod abi;
|
2017-06-03 14:54:08 -07:00
|
|
|
mod allocator;
|
2016-03-22 19:23:36 +02:00
|
|
|
mod asm;
|
|
|
|
mod attributes;
|
|
|
|
mod base;
|
|
|
|
mod builder;
|
|
|
|
mod callee;
|
|
|
|
mod common;
|
|
|
|
mod consts;
|
|
|
|
mod context;
|
|
|
|
mod debuginfo;
|
|
|
|
mod declare;
|
|
|
|
mod glue;
|
|
|
|
mod intrinsic;
|
2017-04-30 20:33:25 +02:00
|
|
|
mod llvm_util;
|
2017-04-26 23:22:45 +02:00
|
|
|
mod metadata;
|
2016-03-22 19:23:36 +02:00
|
|
|
mod meth;
|
|
|
|
mod mir;
|
2017-07-27 13:02:31 +02:00
|
|
|
mod time_graph;
|
2018-05-08 16:10:16 +03:00
|
|
|
mod mono_item;
|
2016-03-22 19:23:36 +02:00
|
|
|
mod type_;
|
|
|
|
mod type_of;
|
|
|
|
mod value;
|
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
pub struct LlvmCodegenBackend(());
|
2017-09-16 17:27:29 +02:00
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
impl !Send for LlvmCodegenBackend {} // Llvm is on a per-thread basis
|
|
|
|
impl !Sync for LlvmCodegenBackend {}
|
2017-10-30 18:42:21 +01:00
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
impl LlvmCodegenBackend {
|
|
|
|
pub fn new() -> Box<CodegenBackend> {
|
|
|
|
box LlvmCodegenBackend(())
|
2017-09-16 17:27:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
impl CodegenBackend for LlvmCodegenBackend {
|
2018-01-22 07:29:24 -08:00
|
|
|
fn init(&self, sess: &Session) {
|
|
|
|
llvm_util::init(sess); // Make sure llvm is inited
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:42:21 +01: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 17:27:29 +02:00
|
|
|
|
2018-01-22 07:29:24 -08: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 18:42:21 +01:00
|
|
|
fn target_features(&self, sess: &Session) -> Vec<Symbol> {
|
|
|
|
target_features(sess)
|
|
|
|
}
|
|
|
|
|
2018-03-03 06:26:48 +01:00
|
|
|
fn metadata_loader(&self) -> Box<MetadataLoader + Sync> {
|
2017-09-16 17:27:29 +02:00
|
|
|
box metadata::LlvmMetadataLoader
|
|
|
|
}
|
|
|
|
|
2017-10-30 18:42:21 +01:00
|
|
|
fn provide(&self, providers: &mut ty::maps::Providers) {
|
2017-11-12 18:00:18 +02:00
|
|
|
back::symbol_names::provide(providers);
|
|
|
|
back::symbol_export::provide(providers);
|
|
|
|
base::provide(providers);
|
2018-01-05 13:26:26 -08:00
|
|
|
attributes::provide(providers);
|
2017-09-23 14:46:15 +02:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:42:21 +01:00
|
|
|
fn provide_extern(&self, providers: &mut ty::maps::Providers) {
|
2017-11-12 18:00:18 +02:00
|
|
|
back::symbol_export::provide_extern(providers);
|
2018-02-10 14:28:17 -08:00
|
|
|
base::provide_extern(providers);
|
|
|
|
attributes::provide_extern(providers);
|
2017-09-16 17:27:29 +02:00
|
|
|
}
|
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
fn codegen_crate<'a, 'tcx>(
|
2017-10-30 18:42:21 +01:00
|
|
|
&self,
|
2017-09-16 17:27:29 +02:00
|
|
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
2017-09-23 14:46:15 +02:00
|
|
|
rx: mpsc::Receiver<Box<Any + Send>>
|
2017-10-30 18:42:21 +01:00
|
|
|
) -> Box<Any> {
|
2018-05-08 16:10:16 +03:00
|
|
|
box base::codegen_crate(tcx, rx)
|
2017-09-16 17:27:29 +02:00
|
|
|
}
|
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
fn join_codegen_and_link(
|
2017-10-30 18:42:21 +01:00
|
|
|
&self,
|
2018-05-08 16:10:16 +03:00
|
|
|
ongoing_codegen: Box<Any>,
|
2017-09-16 17:27:29 +02:00
|
|
|
sess: &Session,
|
2017-10-30 18:42:21 +01:00
|
|
|
dep_graph: &DepGraph,
|
|
|
|
outputs: &OutputFilenames,
|
|
|
|
) -> Result<(), CompileIncomplete>{
|
|
|
|
use rustc::util::common::time;
|
2018-05-08 16:10:16 +03: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 18:42:21 +01:00
|
|
|
if sess.opts.debugging_opts.incremental_info {
|
2018-05-08 16:10:16 +03:00
|
|
|
back::write::dump_incremental_data(&ongoing_codegen);
|
2017-10-30 18:42:21 +01:00
|
|
|
}
|
2017-09-16 17:27:29 +02:00
|
|
|
|
2017-12-03 14:21:23 +01:00
|
|
|
time(sess,
|
2017-10-30 18:42:21 +01:00
|
|
|
"serialize work products",
|
2018-05-09 08:16:08 -07:00
|
|
|
move || rustc_incremental::save_work_product_index(sess, &dep_graph, work_products));
|
2017-10-30 18:42:21 +01: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 14:21:23 +01:00
|
|
|
time(sess, "linking", || {
|
2018-05-08 16:10:16 +03:00
|
|
|
back::link::link_binary(sess, &ongoing_codegen,
|
|
|
|
outputs, &ongoing_codegen.crate_name.as_str());
|
2017-10-30 18:42:21 +01: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 16:10:16 +03:00
|
|
|
rustc_incremental::finalize_session_directory(sess, ongoing_codegen.link.crate_hash);
|
2017-09-16 17:27:29 +02:00
|
|
|
|
2017-10-30 18:42:21 +01:00
|
|
|
Ok(())
|
2017-09-16 17:27:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
/// This is the entrypoint for a hot plugged rustc_codegen_llvm
|
2018-01-04 12:40:11 +01:00
|
|
|
#[no_mangle]
|
2018-05-08 16:10:16 +03:00
|
|
|
pub fn __rustc_codegen_backend() -> Box<CodegenBackend> {
|
|
|
|
LlvmCodegenBackend::new()
|
2018-01-04 12:40:11 +01:00
|
|
|
}
|
2018-01-01 12:17:07 +01:00
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
struct ModuleCodegen {
|
2016-07-25 10:51:14 -04: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 03:09:55 +03:00
|
|
|
name: String,
|
2017-07-23 08:14:38 -07:00
|
|
|
llmod_id: String,
|
2017-12-27 19:03:48 +01:00
|
|
|
source: ModuleSource,
|
|
|
|
kind: ModuleKind,
|
2017-07-25 17:26:24 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 08:14:38 -07:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
2017-12-28 10:11:26 +01:00
|
|
|
enum ModuleKind {
|
2017-07-25 17:26:24 +02:00
|
|
|
Regular,
|
|
|
|
Metadata,
|
|
|
|
Allocator,
|
|
|
|
}
|
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
impl ModuleCodegen {
|
2017-12-27 19:03:48 +01:00
|
|
|
fn llvm(&self) -> Option<&ModuleLlvm> {
|
2017-07-23 08:14:38 -07:00
|
|
|
match self.source {
|
2018-05-08 16:10:16 +03:00
|
|
|
ModuleSource::Codegened(ref llvm) => Some(llvm),
|
2017-07-23 08:14:38 -07:00
|
|
|
ModuleSource::Preexisting(_) => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-27 19:03:48 +01:00
|
|
|
fn into_compiled_module(self,
|
2017-07-23 08:14:38 -07:00
|
|
|
emit_obj: bool,
|
|
|
|
emit_bc: bool,
|
2017-10-19 18:44:33 -07:00
|
|
|
emit_bc_compressed: bool,
|
2017-07-23 08:14:38 -07:00
|
|
|
outputs: &OutputFilenames) -> CompiledModule {
|
2017-07-25 17:26:24 +02:00
|
|
|
let pre_existing = match self.source {
|
|
|
|
ModuleSource::Preexisting(_) => true,
|
2018-05-08 16:10:16 +03:00
|
|
|
ModuleSource::Codegened(_) => false,
|
2017-07-25 17:26:24 +02:00
|
|
|
};
|
2017-10-19 18:44:33 -07: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 17:26:24 +02:00
|
|
|
|
|
|
|
CompiledModule {
|
2017-07-23 08:14:38 -07:00
|
|
|
llmod_id: self.llmod_id,
|
2017-07-25 17:26:24 +02:00
|
|
|
name: self.name.clone(),
|
|
|
|
kind: self.kind,
|
|
|
|
pre_existing,
|
2017-07-23 08:14:38 -07:00
|
|
|
object,
|
2017-10-19 18:44:33 -07:00
|
|
|
bytecode,
|
|
|
|
bytecode_compressed,
|
2017-07-25 17:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2017-12-28 10:11:26 +01:00
|
|
|
struct CompiledModule {
|
2017-12-27 19:03:48 +01:00
|
|
|
name: String,
|
|
|
|
llmod_id: String,
|
|
|
|
kind: ModuleKind,
|
|
|
|
pre_existing: bool,
|
|
|
|
object: Option<PathBuf>,
|
|
|
|
bytecode: Option<PathBuf>,
|
|
|
|
bytecode_compressed: Option<PathBuf>,
|
2016-07-21 12:49:59 -04:00
|
|
|
}
|
|
|
|
|
2017-12-27 19:03:48 +01:00
|
|
|
enum ModuleSource {
|
2016-07-25 10:51:14 -04:00
|
|
|
/// Copy the `.o` files or whatever from the incr. comp. directory.
|
|
|
|
Preexisting(WorkProduct),
|
|
|
|
|
|
|
|
/// Rebuild from this LLVM module.
|
2018-05-08 16:10:16 +03:00
|
|
|
Codegened(ModuleLlvm),
|
2016-07-21 12:49:59 -04:00
|
|
|
}
|
|
|
|
|
2017-07-23 08:14:38 -07:00
|
|
|
#[derive(Debug)]
|
2017-12-28 10:11:26 +01:00
|
|
|
struct ModuleLlvm {
|
2017-08-19 03:09:55 +03:00
|
|
|
llcx: llvm::ContextRef,
|
2017-12-27 19:03:48 +01:00
|
|
|
llmod: llvm::ModuleRef,
|
2017-07-23 08:14:38 -07:00
|
|
|
tm: llvm::TargetMachineRef,
|
2016-03-22 19:23:36 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 08:14:38 -07: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-15 20:30:33 -05:00
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
struct CodegenResults {
|
2017-12-27 19:03:48 +01:00
|
|
|
crate_name: Symbol,
|
|
|
|
modules: Vec<CompiledModule>,
|
2017-08-19 03:09:55 +03:00
|
|
|
allocator_module: Option<CompiledModule>,
|
2017-10-19 18:44:33 -07:00
|
|
|
metadata_module: CompiledModule,
|
2017-12-27 19:03:48 +01:00
|
|
|
link: rustc::middle::cstore::LinkMeta,
|
|
|
|
metadata: rustc::middle::cstore::EncodedMetadata,
|
2017-08-19 03:09:55 +03:00
|
|
|
windows_subsystem: Option<String>,
|
2017-08-28 15:55:32 -07:00
|
|
|
linker_info: back::linker::LinkerInfo,
|
|
|
|
crate_info: CrateInfo,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Misc info we load from metadata to persist beyond the tcx
|
2017-12-28 10:11:26 +01:00
|
|
|
struct CrateInfo {
|
2017-08-28 15:55:32 -07: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 17:11:14 +01:00
|
|
|
native_libraries: FxHashMap<CrateNum, Lrc<Vec<NativeLibrary>>>,
|
2017-08-31 08:07:39 -07:00
|
|
|
crate_name: FxHashMap<CrateNum, String>,
|
2018-02-27 17:11:14 +01:00
|
|
|
used_libraries: Lrc<Vec<NativeLibrary>>,
|
|
|
|
link_args: Lrc<Vec<String>>,
|
|
|
|
used_crate_source: FxHashMap<CrateNum, Lrc<CrateSource>>,
|
2017-08-31 12:08:29 -07:00
|
|
|
used_crates_static: Vec<(CrateNum, LibSource)>,
|
|
|
|
used_crates_dynamic: Vec<(CrateNum, LibSource)>,
|
2018-03-09 09:26:15 -08:00
|
|
|
wasm_custom_sections: BTreeMap<String, Vec<u8>>,
|
2018-02-10 14:28:17 -08:00
|
|
|
wasm_imports: FxHashMap<String, String>,
|
2018-03-23 14:33:22 -07:00
|
|
|
lang_item_to_crate: FxHashMap<LangItem, CrateNum>,
|
2018-04-04 16:54:30 -07:00
|
|
|
missing_lang_items: FxHashMap<CrateNum, Vec<LangItem>>,
|
2014-11-15 20:30:33 -05:00
|
|
|
}
|
2015-11-22 10:22:25 +05:30
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
__build_diagnostic_array! { librustc_codegen_llvm, DIAGNOSTICS }
|