diff --git a/src/Cargo.lock b/src/Cargo.lock index 7297d8a8299a8..d91a165e5373c 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -57,11 +57,6 @@ dependencies = [ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ar" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "arena" version = "0.0.0" @@ -2031,7 +2026,6 @@ dependencies = [ name = "rustc_codegen_utils" version = "0.0.0" dependencies = [ - "ar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", @@ -2072,7 +2066,6 @@ dependencies = [ name = "rustc_driver" version = "0.0.0" dependencies = [ - "ar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "arena 0.0.0", "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "graphviz 0.0.0", @@ -3077,7 +3070,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aho-corasick 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f0ba20154ea1f47ce2793322f049c5646cc6d0fa9759d5f333f286e507bf8080" "checksum ammonia 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd4c682378117e4186a492b2252b9537990e1617f44aed9788b9a1149de45477" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35c7a5669cb64f085739387e1308b74e6d44022464b7f1b63bbd4ceb6379ec31" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" "checksum assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98589b0e465a6c510d95fceebd365bb79bedece7f6e18a480897f2015f85ec51" "checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index d8efb582eaa8b..8050522d06643 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -162,6 +162,7 @@ pub mod util { pub mod ppaux; pub mod nodemap; pub mod fs; + pub mod time_graph; } // A private module so that macro-expanded idents like diff --git a/src/librustc_codegen_llvm/time_graph.rs b/src/librustc/util/time_graph.rs similarity index 100% rename from src/librustc_codegen_llvm/time_graph.rs rename to src/librustc/util/time_graph.rs diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index a4709739a23dd..f9d8431943378 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -56,6 +56,7 @@ use builder::{Builder, MemFlags}; use callee; use common::{C_bool, C_bytes_in_context, C_i32, C_usize}; use rustc_mir::monomorphize::collector::{self, MonoItemCollectionMode}; +use rustc_mir::monomorphize::item::DefPathBasedNames; use common::{self, C_struct_in_context, C_array, val_ty}; use consts; use context::{self, CodegenCx}; @@ -67,7 +68,7 @@ use monomorphize::Instance; use monomorphize::partitioning::{self, PartitioningStrategy, CodegenUnit, CodegenUnitExt}; use rustc_codegen_utils::symbol_names_test; use time_graph; -use mono_item::{MonoItem, BaseMonoItemExt, MonoItemExt, DefPathBasedNames}; +use mono_item::{MonoItem, BaseMonoItemExt, MonoItemExt}; use type_::Type; use type_of::LayoutLlvmExt; use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet}; @@ -92,7 +93,7 @@ use syntax::ast; use mir::operand::OperandValue; -pub use rustc_codegen_utils::check_for_rustc_errors_attr; +use rustc_codegen_utils::check_for_rustc_errors_attr; pub struct StatRecorder<'a, 'tcx: 'a> { cx: &'a CodegenCx<'a, 'tcx>, diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index b11b0c7abe875..93d9ce1e98a4d 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -76,6 +76,7 @@ use rustc::middle::lang_items::LangItem; use rustc::session::{Session, CompileIncomplete}; use rustc::session::config::{OutputFilenames, OutputType, PrintRequest}; use rustc::ty::{self, TyCtxt}; +use rustc::util::time_graph; use rustc::util::nodemap::{FxHashSet, FxHashMap}; use rustc_mir::monomorphize; use rustc_codegen_utils::codegen_backend::CodegenBackend; @@ -114,7 +115,6 @@ mod llvm_util; mod metadata; mod meth; mod mir; -mod time_graph; mod mono_item; mod type_; mod type_of; @@ -368,7 +368,7 @@ struct CodegenResults { crate_info: CrateInfo, } -// Misc info we load from metadata to persist beyond the tcx +/// Misc info we load from metadata to persist beyond the tcx struct CrateInfo { panic_runtime: Option, compiler_builtins: Option, diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs index c4a23ac653ca0..2f7b27b85afef 100644 --- a/src/librustc_codegen_llvm/mono_item.rs +++ b/src/librustc_codegen_llvm/mono_item.rs @@ -33,7 +33,6 @@ use std::fmt; pub use rustc::mir::mono::MonoItem; -pub use rustc_mir::monomorphize::item::*; pub use rustc_mir::monomorphize::item::MonoItemExt as BaseMonoItemExt; pub trait MonoItemExt<'a, 'tcx>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> { diff --git a/src/librustc_codegen_llvm/type_of.rs b/src/librustc_codegen_llvm/type_of.rs index 88b75ff9c0943..bfabf65dfd850 100644 --- a/src/librustc_codegen_llvm/type_of.rs +++ b/src/librustc_codegen_llvm/type_of.rs @@ -16,7 +16,7 @@ use rustc::ty::{self, Ty, TypeFoldable}; use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout}; use rustc_target::spec::PanicStrategy; use rustc_target::abi::FloatTy; -use mono_item::DefPathBasedNames; +use rustc_mir::monomorphize::item::DefPathBasedNames; use type_::Type; use std::fmt::Write; diff --git a/src/librustc_codegen_utils/Cargo.toml b/src/librustc_codegen_utils/Cargo.toml index 690fb260390e5..30f533285ddfd 100644 --- a/src/librustc_codegen_utils/Cargo.toml +++ b/src/librustc_codegen_utils/Cargo.toml @@ -10,7 +10,6 @@ crate-type = ["dylib"] test = false [dependencies] -ar = "0.3.0" flate2 = "1.0" log = "0.4" diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index 8ba6f30cf16e5..3cbf176d98bc9 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -22,15 +22,13 @@ #![feature(box_syntax)] use std::any::Any; -use std::io::prelude::*; -use std::io::{self, Cursor}; +use std::io::{self, Write}; use std::fs::File; use std::path::Path; -use std::sync::mpsc; +use std::sync::{mpsc, Arc}; use rustc_data_structures::owning_ref::OwningRef; use rustc_data_structures::sync::Lrc; -use ar::{Archive, Builder, Header}; use flate2::Compression; use flate2::write::DeflateEncoder; @@ -81,89 +79,21 @@ pub trait CodegenBackend { ) -> Result<(), CompileIncomplete>; } -pub struct DummyCodegenBackend; - -impl CodegenBackend for DummyCodegenBackend { - fn metadata_loader(&self) -> Box { - box DummyMetadataLoader(()) - } - - fn provide(&self, _providers: &mut Providers) { - bug!("DummyCodegenBackend::provide"); - } - - fn provide_extern(&self, _providers: &mut Providers) { - bug!("DummyCodegenBackend::provide_extern"); - } - - fn codegen_crate<'a, 'tcx>( - &self, - _tcx: TyCtxt<'a, 'tcx, 'tcx>, - _rx: mpsc::Receiver> - ) -> Box { - bug!("DummyCodegenBackend::codegen_backend"); - } - - fn join_codegen_and_link( - &self, - _ongoing_codegen: Box, - _sess: &Session, - _dep_graph: &DepGraph, - _outputs: &OutputFilenames, - ) -> Result<(), CompileIncomplete> { - bug!("DummyCodegenBackend::join_codegen_and_link"); - } -} - -pub struct DummyMetadataLoader(()); - -impl MetadataLoader for DummyMetadataLoader { - fn get_rlib_metadata( - &self, - _target: &Target, - _filename: &Path - ) -> Result { - bug!("DummyMetadataLoader::get_rlib_metadata"); - } - - fn get_dylib_metadata( - &self, - _target: &Target, - _filename: &Path - ) -> Result { - bug!("DummyMetadataLoader::get_dylib_metadata"); - } -} - pub struct NoLlvmMetadataLoader; impl MetadataLoader for NoLlvmMetadataLoader { fn get_rlib_metadata(&self, _: &Target, filename: &Path) -> Result { - let file = File::open(filename) + let mut file = File::open(filename) .map_err(|e| format!("metadata file open err: {:?}", e))?; - let mut archive = Archive::new(file); - - while let Some(entry_result) = archive.next_entry() { - let mut entry = entry_result - .map_err(|e| format!("metadata section read err: {:?}", e))?; - if entry.header().identifier() == "rust.metadata.bin" { - let mut buf = Vec::new(); - io::copy(&mut entry, &mut buf).unwrap(); - let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); - return Ok(rustc_erase_owner!(buf.map_owner_box())); - } - } - Err("Couldn't find metadata section".to_string()) + let mut buf = Vec::new(); + io::copy(&mut file, &mut buf).unwrap(); + let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); + return Ok(rustc_erase_owner!(buf.map_owner_box())); } - fn get_dylib_metadata( - &self, - _target: &Target, - _filename: &Path, - ) -> Result { - // FIXME: Support reading dylibs from llvm enabled rustc - self.get_rlib_metadata(_target, _filename) + fn get_dylib_metadata(&self, target: &Target, filename: &Path) -> Result { + self.get_rlib_metadata(target, filename) } } @@ -205,8 +135,13 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { providers.target_features_whitelist = |_tcx, _cnum| { Lrc::new(FxHashMap()) // Just a dummy }; + providers.is_reachable_non_generic = |_tcx, _defid| true; + providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); + providers.wasm_custom_sections = |_tcx, _crate| Lrc::new(Vec::new()); + } + fn provide_extern(&self, providers: &mut Providers) { + providers.is_reachable_non_generic = |_tcx, _defid| true; } - fn provide_extern(&self, _providers: &mut Providers) {} fn codegen_crate<'a, 'tcx>( &self, @@ -225,7 +160,8 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { collector::MonoItemCollectionMode::Eager ).0.iter() ); - ::rustc::middle::dependency_format::calculate(tcx); + // FIXME: Fix this + // ::rustc::middle::dependency_format::calculate(tcx); let _ = tcx.link_args(LOCAL_CRATE); let _ = tcx.native_libraries(LOCAL_CRATE); for mono_item in @@ -280,9 +216,8 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { } else { &ongoing_codegen.metadata.raw_data }; - let mut builder = Builder::new(File::create(&output_name).unwrap()); - let header = Header::new("rust.metadata.bin".to_string(), metadata.len() as u64); - builder.append(&header, Cursor::new(metadata)).unwrap(); + let mut file = File::create(&output_name).unwrap(); + file.write_all(metadata).unwrap(); } sess.abort_if_errors(); diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index d09e8f4845e5e..f59cf5832fcb4 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -25,7 +25,6 @@ #![recursion_limit="256"] -extern crate ar; extern crate flate2; #[macro_use] extern crate log; @@ -39,8 +38,6 @@ extern crate syntax; extern crate syntax_pos; #[macro_use] extern crate rustc_data_structures; -pub extern crate rustc as __rustc; - use rustc::ty::TyCtxt; pub mod link; diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index 5b75912c18f50..7a020f331e50b 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -37,5 +37,3 @@ serialize = { path = "../libserialize" } syntax = { path = "../libsyntax" } syntax_ext = { path = "../libsyntax_ext" } syntax_pos = { path = "../libsyntax_pos" } - -ar = "0.3.0" diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile b/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile index 2ddf3aa5439f6..e203ec2737fc7 100644 --- a/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile @@ -4,6 +4,6 @@ all: /bin/echo || exit 0 # This test requires /bin/echo to exist $(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \ -o $(TMPDIR)/the_backend.dylib - $(RUSTC) some_crate.rs --crate-name some_crate --crate-type bin -o $(TMPDIR)/some_crate \ + $(RUSTC) some_crate.rs --crate-name some_crate --crate-type lib -o $(TMPDIR)/some_crate \ -Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options grep -x "This has been \"compiled\" successfully." $(TMPDIR)/some_crate diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs index 26ffce01b2e2c..bfa8b6b3ef69a 100644 --- a/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs @@ -8,6 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { - ::std::process::exit(1); -} +#![feature(no_core)] +#![no_core] diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 439bc017fee61..a3cd033f86382 100644 --- a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -63,7 +63,7 @@ impl CodegenBackend for TheBackend { let crate_name = ongoing_codegen.downcast::() .expect("in join_codegen_and_link: ongoing_codegen is not a Symbol"); for &crate_type in sess.opts.crate_types.iter() { - if crate_type != CrateType::CrateTypeExecutable { + if crate_type != CrateType::CrateTypeRlib { sess.fatal(&format!("Crate type is {:?}", crate_type)); } let output_name = diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index dedf42fecbbd4..942d27202ecd5 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -59,7 +59,6 @@ static WHITELIST_CRATES: &'static [CrateVersion] = &[ /// Whitelist of crates rustc is allowed to depend on. Avoid adding to the list if possible. static WHITELIST: &'static [Crate] = &[ Crate("aho-corasick"), - Crate("ar"), Crate("arrayvec"), Crate("atty"), Crate("backtrace"),