]> git.lizzy.rs Git - rust.git/blob - src/librustc_trans/lib.rs
6acd10cb887f8e615a63b76d3a383bc737b1daf4
[rust.git] / src / librustc_trans / lib.rs
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.
4 //
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.
10
11 //! The Rust compiler.
12 //!
13 //! # Note
14 //!
15 //! This API is completely unstable and subject to change.
16
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/")]
23 #![deny(warnings)]
24
25 #![feature(associated_consts)]
26 #![feature(box_patterns)]
27 #![feature(box_syntax)]
28 #![feature(const_fn)]
29 #![feature(custom_attribute)]
30 #![allow(unused_attributes)]
31 #![feature(i128_type)]
32 #![feature(libc)]
33 #![feature(quote)]
34 #![feature(rustc_diagnostic_macros)]
35 #![feature(slice_patterns)]
36 #![feature(conservative_impl_trait)]
37
38 use rustc::dep_graph::WorkProduct;
39 use syntax_pos::symbol::Symbol;
40
41 extern crate flate2;
42 extern crate crossbeam;
43 extern crate libc;
44 extern crate owning_ref;
45 #[macro_use] extern crate rustc;
46 extern crate rustc_back;
47 extern crate rustc_data_structures;
48 extern crate rustc_incremental;
49 pub extern crate rustc_llvm as llvm;
50 extern crate rustc_platform_intrinsics as intrinsics;
51 extern crate rustc_const_math;
52 #[macro_use]
53 #[no_link]
54 extern crate rustc_bitflags;
55 extern crate rustc_demangle;
56 extern crate jobserver;
57
58 #[macro_use] extern crate log;
59 #[macro_use] extern crate syntax;
60 extern crate syntax_pos;
61 extern crate rustc_errors as errors;
62 extern crate serialize;
63 #[cfg(windows)]
64 extern crate gcc; // Used to locate MSVC, not gcc :)
65
66 pub use base::trans_crate;
67 pub use back::symbol_names::provide;
68
69 pub use metadata::LlvmMetadataLoader;
70 pub use llvm_util::{init, target_features, print_version, print_passes, print, enable_llvm_debug};
71
72 pub mod back {
73     mod archive;
74     pub(crate) mod linker;
75     pub mod link;
76     mod lto;
77     pub(crate) mod symbol_export;
78     pub(crate) mod symbol_names;
79     pub mod write;
80     pub mod rpath;
81 }
82
83 mod diagnostics;
84
85 mod abi;
86 mod adt;
87 mod asm;
88 mod assert_module_sources;
89 mod attributes;
90 mod base;
91 mod builder;
92 mod cabi_aarch64;
93 mod cabi_arm;
94 mod cabi_asmjs;
95 mod cabi_hexagon;
96 mod cabi_mips;
97 mod cabi_mips64;
98 mod cabi_msp430;
99 mod cabi_nvptx;
100 mod cabi_nvptx64;
101 mod cabi_powerpc;
102 mod cabi_powerpc64;
103 mod cabi_s390x;
104 mod cabi_sparc;
105 mod cabi_sparc64;
106 mod cabi_x86;
107 mod cabi_x86_64;
108 mod cabi_x86_win64;
109 mod callee;
110 mod collector;
111 mod common;
112 mod consts;
113 mod context;
114 mod debuginfo;
115 mod declare;
116 mod glue;
117 mod intrinsic;
118 mod llvm_util;
119 mod machine;
120 mod metadata;
121 mod meth;
122 mod mir;
123 mod monomorphize;
124 mod partitioning;
125 mod symbol_names_test;
126 mod trans_item;
127 mod tvec;
128 mod type_;
129 mod type_of;
130 mod value;
131
132 #[derive(Clone)]
133 pub struct ModuleTranslation {
134     /// The name of the module. When the crate may be saved between
135     /// compilations, incremental compilation requires that name be
136     /// unique amongst **all** crates.  Therefore, it should contain
137     /// something unique to this crate (e.g., a module path) as well
138     /// as the crate name and disambiguator.
139     pub name: String,
140     pub symbol_name_hash: u64,
141     pub source: ModuleSource,
142 }
143
144 #[derive(Clone)]
145 pub enum ModuleSource {
146     /// Copy the `.o` files or whatever from the incr. comp. directory.
147     Preexisting(WorkProduct),
148
149     /// Rebuild from this LLVM module.
150     Translated(ModuleLlvm),
151 }
152
153 #[derive(Copy, Clone)]
154 pub struct ModuleLlvm {
155     pub llcx: llvm::ContextRef,
156     pub llmod: llvm::ModuleRef,
157 }
158
159 unsafe impl Send for ModuleTranslation { }
160 unsafe impl Sync for ModuleTranslation { }
161
162 pub struct CrateTranslation {
163     pub crate_name: Symbol,
164     pub modules: Vec<ModuleTranslation>,
165     pub metadata_module: ModuleTranslation,
166     pub link: rustc::middle::cstore::LinkMeta,
167     pub metadata: rustc::middle::cstore::EncodedMetadata,
168     pub exported_symbols: back::symbol_export::ExportedSymbols,
169     pub no_builtins: bool,
170     pub windows_subsystem: Option<String>,
171     pub linker_info: back::linker::LinkerInfo
172 }
173
174 __build_diagnostic_array! { librustc_trans, DIAGNOSTICS }