]> git.lizzy.rs Git - rust.git/blob - src/librustc_trans/lib.rs
Refactor symbol export list generation.
[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(associated_consts)]
27 #![feature(box_patterns)]
28 #![feature(box_syntax)]
29 #![feature(cell_extras)]
30 #![feature(const_fn)]
31 #![feature(custom_attribute)]
32 #![allow(unused_attributes)]
33 #![feature(libc)]
34 #![feature(quote)]
35 #![feature(rustc_diagnostic_macros)]
36 #![feature(rustc_private)]
37 #![feature(slice_patterns)]
38 #![feature(staged_api)]
39 #![feature(unicode)]
40
41 use rustc::dep_graph::WorkProduct;
42
43 extern crate arena;
44 extern crate flate;
45 extern crate getopts;
46 extern crate graphviz;
47 extern crate libc;
48 #[macro_use] extern crate rustc;
49 extern crate rustc_back;
50 extern crate rustc_data_structures;
51 extern crate rustc_incremental;
52 pub extern crate rustc_llvm as llvm;
53 extern crate rustc_platform_intrinsics as intrinsics;
54 extern crate serialize;
55 extern crate rustc_const_math;
56 extern crate rustc_const_eval;
57 #[macro_use]
58 #[no_link]
59 extern crate rustc_bitflags;
60
61 #[macro_use] extern crate log;
62 #[macro_use] extern crate syntax;
63 extern crate syntax_pos;
64 extern crate rustc_errors as errors;
65
66 pub use rustc::session;
67 pub use rustc::middle;
68 pub use rustc::lint;
69 pub use rustc::util;
70
71 pub use base::trans_crate;
72 pub use disr::Disr;
73
74 pub mod back {
75     pub use rustc::hir::svh;
76
77     pub mod archive;
78     pub mod linker;
79     pub mod link;
80     pub mod lto;
81     pub mod symbol_export;
82     pub mod symbol_names;
83     pub mod write;
84     pub mod msvc;
85     pub mod rpath;
86 }
87
88 pub mod diagnostics;
89
90 #[macro_use]
91 mod macros;
92
93 mod abi;
94 mod adt;
95 mod asm;
96 mod assert_module_sources;
97 mod attributes;
98 mod base;
99 mod basic_block;
100 mod build;
101 mod builder;
102 mod cabi_aarch64;
103 mod cabi_arm;
104 mod cabi_asmjs;
105 mod cabi_mips;
106 mod cabi_mips64;
107 mod cabi_msp430;
108 mod cabi_powerpc;
109 mod cabi_powerpc64;
110 mod cabi_s390x;
111 mod cabi_x86;
112 mod cabi_x86_64;
113 mod cabi_x86_win64;
114 mod callee;
115 mod cleanup;
116 mod collector;
117 mod common;
118 mod consts;
119 mod context;
120 mod debuginfo;
121 mod declare;
122 mod disr;
123 mod glue;
124 mod intrinsic;
125 mod machine;
126 mod meth;
127 mod mir;
128 mod monomorphize;
129 mod partitioning;
130 mod symbol_map;
131 mod symbol_names_test;
132 mod trans_item;
133 mod tvec;
134 mod type_;
135 mod type_of;
136 mod value;
137
138 #[derive(Clone)]
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.
145     pub name: String,
146     pub symbol_name_hash: u64,
147     pub source: ModuleSource,
148 }
149
150 #[derive(Clone)]
151 pub enum ModuleSource {
152     /// Copy the `.o` files or whatever from the incr. comp. directory.
153     Preexisting(WorkProduct),
154
155     /// Rebuild from this LLVM module.
156     Translated(ModuleLlvm),
157 }
158
159 #[derive(Copy, Clone)]
160 pub struct ModuleLlvm {
161     pub llcx: llvm::ContextRef,
162     pub llmod: llvm::ModuleRef,
163 }
164
165 unsafe impl Send for ModuleTranslation { }
166 unsafe impl Sync for ModuleTranslation { }
167
168 pub struct CrateTranslation {
169     pub modules: Vec<ModuleTranslation>,
170     pub metadata_module: ModuleTranslation,
171     pub link: middle::cstore::LinkMeta,
172     pub metadata: Vec<u8>,
173     pub exported_symbols: back::symbol_export::ExportedSymbols,
174     pub no_builtins: bool,
175     pub windows_subsystem: Option<String>,
176     pub linker_info: back::linker::LinkerInfo
177 }
178
179 __build_diagnostic_array! { librustc_trans, DIAGNOSTICS }