1 // Copyright 2017 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.
13 //! This API is completely unstable and subject to change.
15 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
16 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
17 html_root_url = "https://doc.rust-lang.org/nightly/")]
19 #![feature(box_patterns)]
20 #![feature(box_syntax)]
21 #![feature(custom_attribute)]
23 #![allow(unused_attributes)]
26 #![feature(rustc_diagnostic_macros)]
28 #![recursion_limit="256"]
31 extern crate rustc_target;
32 extern crate rustc_mir;
34 extern crate syntax_pos;
35 extern crate rustc_data_structures;
37 use std::path::PathBuf;
38 use rustc::dep_graph::WorkProduct;
39 use rustc::session::config::{OutputFilenames, OutputType};
44 pub struct ModuleCodegen<M> {
45 /// The name of the module. When the crate may be saved between
46 /// compilations, incremental compilation requires that name be
47 /// unique amongst **all** crates. Therefore, it should contain
48 /// something unique to this crate (e.g., a module path) as well
49 /// as the crate name and disambiguator.
50 /// We currently generate these names via CodegenUnit::build_cgu_name().
56 pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z";
58 impl<M> ModuleCodegen<M> {
59 pub fn into_compiled_module(self,
62 emit_bc_compressed: bool,
63 outputs: &OutputFilenames) -> CompiledModule {
64 let object = if emit_obj {
65 Some(outputs.temp_path(OutputType::Object, Some(&self.name)))
69 let bytecode = if emit_bc {
70 Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)))
74 let bytecode_compressed = if emit_bc_compressed {
75 Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name))
76 .with_extension(RLIB_BYTECODE_EXTENSION))
82 name: self.name.clone(),
92 pub struct CompiledModule {
95 pub object: Option<PathBuf>,
96 pub bytecode: Option<PathBuf>,
97 pub bytecode_compressed: Option<PathBuf>,
100 pub struct CachedModuleCodegen {
102 pub source: WorkProduct,
105 #[derive(Copy, Clone, Debug, PartialEq)]
106 pub enum ModuleKind {
113 __build_diagnostic_array! { librustc_codegen_ssa, DIAGNOSTICS }