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
|
|
|
|
|
|
|
#![crate_name = "rustc_trans"]
|
|
|
|
#![crate_type = "dylib"]
|
|
|
|
#![crate_type = "rlib"]
|
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
|
|
|
|
2016-11-16 22:36:08 +00:00
|
|
|
#![feature(associated_consts)]
|
2015-02-10 21:52:44 +00:00
|
|
|
#![feature(box_patterns)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(box_syntax)]
|
2015-05-29 13:42:32 +00:00
|
|
|
#![feature(const_fn)]
|
2015-09-27 20:20:49 +00:00
|
|
|
#![feature(custom_attribute)]
|
|
|
|
#![allow(unused_attributes)]
|
2017-02-01 23:57:50 +00:00
|
|
|
#![feature(i128_type)]
|
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)]
|
2015-06-09 18:18:03 +00:00
|
|
|
#![feature(unicode)]
|
2016-12-17 15:24:17 +00:00
|
|
|
#![feature(conservative_impl_trait)]
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2017-05-08 21:36:44 +00:00
|
|
|
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
|
|
|
|
#![cfg_attr(stage0, feature(rustc_private))]
|
|
|
|
#![cfg_attr(stage0, feature(staged_api))]
|
|
|
|
|
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
|
|
|
|
2014-11-16 01:30:33 +00:00
|
|
|
extern crate flate;
|
|
|
|
extern crate libc;
|
2017-04-26 21:22:45 +00:00
|
|
|
extern crate owning_ref;
|
2016-03-28 23:46:02 +00:00
|
|
|
#[macro_use] extern crate rustc;
|
2014-11-16 01:30:33 +00:00
|
|
|
extern crate rustc_back;
|
2015-11-02 14:39:59 +00:00
|
|
|
extern crate rustc_data_structures;
|
2016-03-28 21:36:56 +00:00
|
|
|
extern crate rustc_incremental;
|
2016-02-02 09:39:59 +00:00
|
|
|
pub extern crate rustc_llvm as llvm;
|
2015-07-16 23:46:36 +00:00
|
|
|
extern crate rustc_platform_intrinsics as intrinsics;
|
2016-03-15 11:33:13 +00:00
|
|
|
extern crate rustc_const_math;
|
2016-11-16 22:36:08 +00:00
|
|
|
#[macro_use]
|
|
|
|
#[no_link]
|
|
|
|
extern crate rustc_bitflags;
|
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;
|
2015-01-01 04:43:46 +00:00
|
|
|
|
2017-05-27 18:13:32 +00:00
|
|
|
use rustc::session;
|
|
|
|
use rustc::middle;
|
|
|
|
use rustc::util;
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2016-03-22 17:23:36 +00:00
|
|
|
pub use base::trans_crate;
|
2017-04-24 16:35:47 +00:00
|
|
|
pub use back::symbol_names::provide;
|
2016-03-22 17:23:36 +00:00
|
|
|
|
2017-04-26 21:22:45 +00:00
|
|
|
pub use metadata::LlvmMetadataLoader;
|
2017-04-30 18:33:25 +00:00
|
|
|
pub use llvm_util::{init, target_features, print_version, print_passes, print, enable_llvm_debug};
|
2017-04-26 21:22:45 +00:00
|
|
|
|
2014-11-16 01:30:33 +00:00
|
|
|
pub mod back {
|
2017-05-27 18:13:32 +00:00
|
|
|
mod archive;
|
|
|
|
pub(crate) mod linker;
|
2014-11-16 01:30:33 +00:00
|
|
|
pub mod link;
|
2017-05-27 18:13:32 +00:00
|
|
|
mod lto;
|
|
|
|
pub(crate) mod symbol_export;
|
|
|
|
pub(crate) mod symbol_names;
|
2014-11-16 01:30:33 +00:00
|
|
|
pub mod write;
|
2017-05-27 18:13:32 +00:00
|
|
|
mod msvc;
|
|
|
|
mod rpath;
|
2014-11-16 01:30:33 +00:00
|
|
|
}
|
|
|
|
|
2017-05-27 18:13:32 +00:00
|
|
|
mod diagnostics;
|
2015-09-18 22:42:57 +00:00
|
|
|
|
2016-03-22 17:23:36 +00:00
|
|
|
mod abi;
|
|
|
|
mod adt;
|
|
|
|
mod asm;
|
2016-07-21 16:50:15 +00:00
|
|
|
mod assert_module_sources;
|
2016-03-22 17:23:36 +00:00
|
|
|
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;
|
2016-03-24 15:40:49 +00:00
|
|
|
mod collector;
|
2016-03-22 17:23:36 +00:00
|
|
|
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;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod machine;
|
2017-04-26 21:22:45 +00:00
|
|
|
mod metadata;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod meth;
|
|
|
|
mod mir;
|
|
|
|
mod monomorphize;
|
2016-03-24 15:40:49 +00:00
|
|
|
mod partitioning;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod symbol_names_test;
|
2016-05-09 17:37:14 +00:00
|
|
|
mod trans_item;
|
2016-03-22 17:23:36 +00:00
|
|
|
mod tvec;
|
|
|
|
mod type_;
|
|
|
|
mod type_of;
|
|
|
|
mod value;
|
|
|
|
|
2016-05-14 00:48:32 +00:00
|
|
|
#[derive(Clone)]
|
2016-03-22 17:23:36 +00:00
|
|
|
pub 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.
|
2016-05-14 00:48:32 +00:00
|
|
|
pub name: String,
|
2016-07-21 16:49:59 +00:00
|
|
|
pub symbol_name_hash: u64,
|
|
|
|
pub source: ModuleSource,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub 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),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct ModuleLlvm {
|
2016-03-22 17:23:36 +00:00
|
|
|
pub llcx: llvm::ContextRef,
|
|
|
|
pub llmod: llvm::ModuleRef,
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl Send for ModuleTranslation { }
|
|
|
|
unsafe impl Sync for ModuleTranslation { }
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2016-03-22 17:23:36 +00:00
|
|
|
pub struct CrateTranslation {
|
2017-04-13 18:58:20 +00:00
|
|
|
pub crate_name: Symbol,
|
2016-03-22 17:23:36 +00:00
|
|
|
pub modules: Vec<ModuleTranslation>,
|
|
|
|
pub metadata_module: ModuleTranslation,
|
|
|
|
pub link: middle::cstore::LinkMeta,
|
2017-04-05 21:39:02 +00:00
|
|
|
pub metadata: middle::cstore::EncodedMetadata,
|
2016-11-30 15:03:42 +00:00
|
|
|
pub exported_symbols: back::symbol_export::ExportedSymbols,
|
2016-03-22 17:23:36 +00:00
|
|
|
pub no_builtins: bool,
|
2016-10-31 16:36:30 +00:00
|
|
|
pub windows_subsystem: Option<String>,
|
2016-05-24 22:45:25 +00:00
|
|
|
pub linker_info: back::linker::LinkerInfo
|
2014-11-16 01:30:33 +00:00
|
|
|
}
|
2015-11-22 04:52:25 +00:00
|
|
|
|
|
|
|
__build_diagnostic_array! { librustc_trans, DIAGNOSTICS }
|