1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! The Rust compiler.
15 //! This API is completely unstable and subject to change.
17 #![crate_name = "rustc_trans"]
18 #![crate_type = "dylib"]
19 #![crate_type = "rlib"]
20 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
21 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
22 html_root_url = "https://doc.rust-lang.org/nightly/")]
25 #![feature(associated_consts)]
26 #![feature(box_patterns)]
27 #![feature(box_syntax)]
29 #![feature(custom_attribute)]
30 #![allow(unused_attributes)]
31 #![feature(i128_type)]
34 #![feature(rustc_diagnostic_macros)]
35 #![feature(slice_patterns)]
37 #![feature(conservative_impl_trait)]
39 #![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
40 #![cfg_attr(stage0, feature(rustc_private))]
41 #![cfg_attr(stage0, feature(staged_api))]
43 use rustc::dep_graph::WorkProduct;
44 use syntax_pos::symbol::Symbol;
48 extern crate owning_ref;
49 #[macro_use] extern crate rustc;
50 extern crate rustc_back;
51 extern crate rustc_data_structures;
52 extern crate rustc_incremental;
53 pub extern crate rustc_llvm as llvm;
54 extern crate rustc_platform_intrinsics as intrinsics;
55 extern crate rustc_const_math;
58 extern crate rustc_bitflags;
60 #[macro_use] extern crate log;
61 #[macro_use] extern crate syntax;
62 extern crate syntax_pos;
63 extern crate rustc_errors as errors;
64 extern crate serialize;
66 pub use rustc::session;
67 pub use rustc::middle;
71 pub use base::trans_crate;
72 pub use back::symbol_names::provide;
74 pub use metadata::LlvmMetadataLoader;
77 pub use rustc::hir::svh;
83 pub mod symbol_export;
95 mod assert_module_sources;
131 mod symbol_names_test;
139 pub struct ModuleTranslation {
140 /// The name of the module. When the crate may be saved between
141 /// compilations, incremental compilation requires that name be
142 /// unique amongst **all** crates. Therefore, it should contain
143 /// something unique to this crate (e.g., a module path) as well
144 /// as the crate name and disambiguator.
146 pub symbol_name_hash: u64,
147 pub source: ModuleSource,
151 pub enum ModuleSource {
152 /// Copy the `.o` files or whatever from the incr. comp. directory.
153 Preexisting(WorkProduct),
155 /// Rebuild from this LLVM module.
156 Translated(ModuleLlvm),
159 #[derive(Copy, Clone)]
160 pub struct ModuleLlvm {
161 pub llcx: llvm::ContextRef,
162 pub llmod: llvm::ModuleRef,
165 unsafe impl Send for ModuleTranslation { }
166 unsafe impl Sync for ModuleTranslation { }
168 pub struct CrateTranslation {
169 pub crate_name: Symbol,
170 pub modules: Vec<ModuleTranslation>,
171 pub metadata_module: ModuleTranslation,
172 pub link: middle::cstore::LinkMeta,
173 pub metadata: middle::cstore::EncodedMetadata,
174 pub exported_symbols: back::symbol_export::ExportedSymbols,
175 pub no_builtins: bool,
176 pub windows_subsystem: Option<String>,
177 pub linker_info: back::linker::LinkerInfo
180 __build_diagnostic_array! { librustc_trans, DIAGNOSTICS }