]> git.lizzy.rs Git - rust.git/blob - src/librustc_trans/lib.rs
Changed issue number to 36105
[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 #![unstable(feature = "rustc_private", issue = "27812")]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23       html_root_url = "https://doc.rust-lang.org/nightly/")]
24 #![cfg_attr(not(stage0), deny(warnings))]
25
26 #![feature(box_patterns)]
27 #![feature(box_syntax)]
28 #![feature(const_fn)]
29 #![feature(custom_attribute)]
30 #![allow(unused_attributes)]
31 #![feature(libc)]
32 #![feature(quote)]
33 #![feature(rustc_diagnostic_macros)]
34 #![feature(rustc_private)]
35 #![feature(slice_patterns)]
36 #![feature(staged_api)]
37 #![feature(unicode)]
38 #![feature(question_mark)]
39
40 use rustc::dep_graph::WorkProduct;
41
42 extern crate arena;
43 extern crate flate;
44 extern crate getopts;
45 extern crate graphviz;
46 extern crate libc;
47 #[macro_use] extern crate rustc;
48 extern crate rustc_back;
49 extern crate rustc_data_structures;
50 extern crate rustc_incremental;
51 pub extern crate rustc_llvm as llvm;
52 extern crate rustc_platform_intrinsics as intrinsics;
53 extern crate serialize;
54 extern crate rustc_const_math;
55 extern crate rustc_const_eval;
56
57 #[macro_use] extern crate log;
58 #[macro_use] extern crate syntax;
59 extern crate syntax_pos;
60 extern crate rustc_errors as errors;
61
62 pub use rustc::session;
63 pub use rustc::middle;
64 pub use rustc::lint;
65 pub use rustc::util;
66
67 pub use base::trans_crate;
68 pub use disr::Disr;
69
70 pub mod back {
71     pub use rustc_back::rpath;
72     pub use rustc::hir::svh;
73
74     pub mod archive;
75     pub mod linker;
76     pub mod link;
77     pub mod lto;
78     pub mod symbol_names;
79     pub mod write;
80     pub mod msvc;
81 }
82
83 pub mod diagnostics;
84
85 #[macro_use]
86 mod macros;
87
88 mod abi;
89 mod adt;
90 mod asm;
91 mod assert_module_sources;
92 mod attributes;
93 mod base;
94 mod basic_block;
95 mod build;
96 mod builder;
97 mod cabi_aarch64;
98 mod cabi_arm;
99 mod cabi_asmjs;
100 mod cabi_mips;
101 mod cabi_powerpc;
102 mod cabi_powerpc64;
103 mod cabi_x86;
104 mod cabi_x86_64;
105 mod cabi_x86_win64;
106 mod callee;
107 mod cleanup;
108 mod closure;
109 mod collector;
110 mod common;
111 mod consts;
112 mod context;
113 mod controlflow;
114 mod datum;
115 mod debuginfo;
116 mod declare;
117 mod disr;
118 mod expr;
119 mod glue;
120 mod inline;
121 mod intrinsic;
122 mod machine;
123 mod _match;
124 mod meth;
125 mod mir;
126 mod monomorphize;
127 mod partitioning;
128 mod symbol_map;
129 mod symbol_names_test;
130 mod trans_item;
131 mod tvec;
132 mod type_;
133 mod type_of;
134 mod value;
135
136 #[derive(Clone)]
137 pub struct ModuleTranslation {
138     /// The name of the module. When the crate may be saved between
139     /// compilations, incremental compilation requires that name be
140     /// unique amongst **all** crates.  Therefore, it should contain
141     /// something unique to this crate (e.g., a module path) as well
142     /// as the crate name and disambiguator.
143     pub name: String,
144     pub symbol_name_hash: u64,
145     pub source: ModuleSource,
146 }
147
148 #[derive(Clone)]
149 pub enum ModuleSource {
150     /// Copy the `.o` files or whatever from the incr. comp. directory.
151     Preexisting(WorkProduct),
152
153     /// Rebuild from this LLVM module.
154     Translated(ModuleLlvm),
155 }
156
157 #[derive(Copy, Clone)]
158 pub struct ModuleLlvm {
159     pub llcx: llvm::ContextRef,
160     pub llmod: llvm::ModuleRef,
161 }
162
163 unsafe impl Send for ModuleTranslation { }
164 unsafe impl Sync for ModuleTranslation { }
165
166 pub struct CrateTranslation {
167     pub modules: Vec<ModuleTranslation>,
168     pub metadata_module: ModuleTranslation,
169     pub link: middle::cstore::LinkMeta,
170     pub metadata: Vec<u8>,
171     pub reachable: Vec<String>,
172     pub no_builtins: bool,
173     pub linker_info: back::linker::LinkerInfo
174 }
175
176 __build_diagnostic_array! { librustc_trans, DIAGNOSTICS }