From 345ba505ece1d0b9f929d43bd7dc37036ae3c580 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 19 Dec 2018 18:11:31 +0100 Subject: [PATCH] rustc: Remove `dylib` crate type from most rustc crates Now that procedural macros no longer link transitively to libsyntax, this shouldn't be needed any more! This commit is an experiment in removing all dynamic libraries from rustc except for librustc_driver itself. Let's see how far we can get with that! --- src/libarena/Cargo.toml | 1 - src/libfmt_macros/Cargo.toml | 1 + src/libgraphviz/Cargo.toml | 1 - src/librustc/Cargo.toml | 2 +- src/librustc/lib.rs | 1 - src/librustc_allocator/Cargo.toml | 1 - src/librustc_apfloat/Cargo.toml | 1 - src/librustc_apfloat/lib.rs | 3 --- src/librustc_borrowck/Cargo.toml | 2 +- src/librustc_codegen_llvm/lib.rs | 1 + src/librustc_codegen_ssa/Cargo.toml | 1 - src/librustc_codegen_utils/Cargo.toml | 1 - src/librustc_cratesio_shim/Cargo.toml | 26 ------------------- src/librustc_cratesio_shim/src/lib.rs | 11 -------- src/librustc_data_structures/Cargo.toml | 3 +-- src/librustc_data_structures/lib.rs | 4 --- src/librustc_errors/Cargo.toml | 3 +-- src/librustc_fs_util/Cargo.toml | 1 - src/librustc_incremental/Cargo.toml | 2 +- src/librustc_interface/Cargo.toml | 2 +- src/librustc_lint/Cargo.toml | 1 - src/librustc_llvm/lib.rs | 4 --- src/librustc_metadata/Cargo.toml | 2 +- src/librustc_mir/Cargo.toml | 2 +- src/librustc_passes/Cargo.toml | 1 - src/librustc_plugin/Cargo.toml | 2 +- src/librustc_privacy/Cargo.toml | 1 - src/librustc_resolve/Cargo.toml | 2 +- src/librustc_save_analysis/Cargo.toml | 1 - src/librustc_target/Cargo.toml | 2 -- src/librustc_target/lib.rs | 4 --- src/librustc_traits/Cargo.toml | 1 - src/librustc_typeck/Cargo.toml | 2 +- src/libserialize/Cargo.toml | 1 - src/libsyntax/Cargo.toml | 2 +- src/libsyntax_ext/Cargo.toml | 2 +- src/libsyntax_pos/Cargo.toml | 2 +- src/test/run-make-fulldeps/issue-19371/foo.rs | 2 ++ 38 files changed, 18 insertions(+), 84 deletions(-) delete mode 100644 src/librustc_cratesio_shim/Cargo.toml delete mode 100644 src/librustc_cratesio_shim/src/lib.rs diff --git a/src/libarena/Cargo.toml b/src/libarena/Cargo.toml index aa1bf38b995..2643912f6d7 100644 --- a/src/libarena/Cargo.toml +++ b/src/libarena/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "arena" path = "lib.rs" -crate-type = ["dylib"] [dependencies] rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/libfmt_macros/Cargo.toml b/src/libfmt_macros/Cargo.toml index fc32f21ec4e..a95193b8595 100644 --- a/src/libfmt_macros/Cargo.toml +++ b/src/libfmt_macros/Cargo.toml @@ -11,3 +11,4 @@ crate-type = ["dylib"] [dependencies] syntax_pos = { path = "../libsyntax_pos" } + diff --git a/src/libgraphviz/Cargo.toml b/src/libgraphviz/Cargo.toml index a6a3c1a249d..4a6e41f7603 100644 --- a/src/libgraphviz/Cargo.toml +++ b/src/libgraphviz/Cargo.toml @@ -7,4 +7,3 @@ edition = "2018" [lib] name = "graphviz" path = "lib.rs" -crate-type = ["dylib"] diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index 4d50e80d4cf..7584df82ac6 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "rustc" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] arena = { path = "../libarena" } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index b20f7120bbf..8bedbefc0a6 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -46,7 +46,6 @@ #![feature(extern_types)] #![feature(nll)] #![feature(non_exhaustive)] -#![feature(proc_macro_internals)] #![feature(optin_builtin_traits)] #![feature(range_is_empty)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_allocator/Cargo.toml b/src/librustc_allocator/Cargo.toml index cf6c598bfb1..a964f323c9e 100644 --- a/src/librustc_allocator/Cargo.toml +++ b/src/librustc_allocator/Cargo.toml @@ -6,7 +6,6 @@ edition = "2018" [lib] path = "lib.rs" -crate-type = ["dylib"] test = false [dependencies] diff --git a/src/librustc_apfloat/Cargo.toml b/src/librustc_apfloat/Cargo.toml index c7496a9547e..af6c2feed00 100644 --- a/src/librustc_apfloat/Cargo.toml +++ b/src/librustc_apfloat/Cargo.toml @@ -10,5 +10,4 @@ path = "lib.rs" [dependencies] bitflags = "1.0" -rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } smallvec = { version = "0.6.7", features = ["union", "may_dangle"] } diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index 1b0bcdd0b5b..ceade5d2788 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -35,9 +35,6 @@ #![deny(rust_2018_idioms)] #![feature(nll)] -// See librustc_cratesio_shim/Cargo.toml for a comment explaining this. -#[allow(unused_extern_crates)] -extern crate rustc_cratesio_shim; use std::cmp::Ordering; use std::fmt; diff --git a/src/librustc_borrowck/Cargo.toml b/src/librustc_borrowck/Cargo.toml index f293739dec7..e9abc17202e 100644 --- a/src/librustc_borrowck/Cargo.toml +++ b/src/librustc_borrowck/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" [lib] name = "rustc_borrowck" path = "lib.rs" -crate-type = ["dylib"] test = false +doctest = false [dependencies] log = "0.4" diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index dbcb2031552..0f0b9f27917 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -39,6 +39,7 @@ extern crate rustc_incremental; extern crate rustc_codegen_utils; extern crate rustc_codegen_ssa; extern crate rustc_fs_util; +extern crate rustc_driver as _; #[macro_use] extern crate log; #[macro_use] extern crate syntax; diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml index a4cb517fafe..343596feed2 100644 --- a/src/librustc_codegen_ssa/Cargo.toml +++ b/src/librustc_codegen_ssa/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "rustc_codegen_ssa" path = "lib.rs" -crate-type = ["dylib"] test = false [dependencies] diff --git a/src/librustc_codegen_utils/Cargo.toml b/src/librustc_codegen_utils/Cargo.toml index b218d18a06b..d93589ea84b 100644 --- a/src/librustc_codegen_utils/Cargo.toml +++ b/src/librustc_codegen_utils/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "rustc_codegen_utils" path = "lib.rs" -crate-type = ["dylib"] test = false [dependencies] diff --git a/src/librustc_cratesio_shim/Cargo.toml b/src/librustc_cratesio_shim/Cargo.toml deleted file mode 100644 index 6bdfbe09354..00000000000 --- a/src/librustc_cratesio_shim/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -# This crate exists to allow rustc to link certain crates from crates.io into -# the distribution. This doesn't work normally because: -# -# - Cargo always builds dependencies as rlibs: -# https://github.com/rust-lang/cargo/issues/629 -# - rustc wants to avoid multiple definitions of the same symbol, so it refuses -# to link multiple dylibs containing the same rlib -# - multiple dylibs depend on the same crates.io crates -# -# This solution works by including all the conflicting rlibs in a single dylib, -# which is then linked into all dylibs that depend on these crates.io crates. -# The result is that each rlib only appears once, and things work! - -[package] -authors = ["The Rust Project Developers"] -name = "rustc_cratesio_shim" -version = "0.0.0" -edition = "2018" - -[lib] -crate-type = ["dylib"] - -[dependencies] -bitflags = "1.0" -log = "0.4" -unicode-width = "0.1.4" diff --git a/src/librustc_cratesio_shim/src/lib.rs b/src/librustc_cratesio_shim/src/lib.rs deleted file mode 100644 index 4c170f4f5f6..00000000000 --- a/src/librustc_cratesio_shim/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![deny(rust_2018_idioms)] - -// See Cargo.toml for a comment explaining this crate. -#![allow(unused_extern_crates)] - -#![feature(nll)] - -extern crate bitflags; -extern crate log; -extern crate proc_macro; -extern crate unicode_width; diff --git a/src/librustc_data_structures/Cargo.toml b/src/librustc_data_structures/Cargo.toml index cd792d31187..acddb3448ca 100644 --- a/src/librustc_data_structures/Cargo.toml +++ b/src/librustc_data_structures/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "rustc_data_structures" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] ena = "0.13" @@ -15,7 +15,6 @@ indexmap = "1" log = "0.4" jobserver_crate = { version = "0.1.13", package = "jobserver" } lazy_static = "1" -rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } serialize = { path = "../libserialize" } graphviz = { path = "../libgraphviz" } cfg-if = "0.1.2" diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 38dfb675237..b479643a5e8 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -38,10 +38,6 @@ extern crate libc; #[macro_use] extern crate cfg_if; -// See librustc_cratesio_shim/Cargo.toml for a comment explaining this. -#[allow(unused_extern_crates)] -extern crate rustc_cratesio_shim; - pub use rustc_serialize::hex::ToHex; #[inline(never)] diff --git a/src/librustc_errors/Cargo.toml b/src/librustc_errors/Cargo.toml index 3689a463a5c..4df9632cce2 100644 --- a/src/librustc_errors/Cargo.toml +++ b/src/librustc_errors/Cargo.toml @@ -7,14 +7,13 @@ edition = "2018" [lib] name = "rustc_errors" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] log = "0.4" serialize = { path = "../libserialize" } syntax_pos = { path = "../libsyntax_pos" } rustc_data_structures = { path = "../librustc_data_structures" } -rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } unicode-width = "0.1.4" atty = "0.2" termcolor = "1.0" diff --git a/src/librustc_fs_util/Cargo.toml b/src/librustc_fs_util/Cargo.toml index 47918643f31..e74e3809927 100644 --- a/src/librustc_fs_util/Cargo.toml +++ b/src/librustc_fs_util/Cargo.toml @@ -7,6 +7,5 @@ edition = "2018" [lib] name = "rustc_fs_util" path = "lib.rs" -crate-type = ["dylib"] [dependencies] diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index df971ec5bdb..9678cb4f655 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "rustc_incremental" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] graphviz = { path = "../libgraphviz" } diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index bcaa4216109..82880d21987 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "rustc_interface" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] log = "0.4" diff --git a/src/librustc_lint/Cargo.toml b/src/librustc_lint/Cargo.toml index fd2b635faef..041d0aaead9 100644 --- a/src/librustc_lint/Cargo.toml +++ b/src/librustc_lint/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "rustc_lint" path = "lib.rs" -crate-type = ["dylib"] [dependencies] log = "0.4" diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 292ce8b0a01..bdf6b091857 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -4,10 +4,6 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] -// See librustc_cratesio_shim/Cargo.toml for a comment explaining this. -#[allow(unused_extern_crates)] -extern crate rustc_cratesio_shim; - // NOTE: This crate only exists to allow linking on mingw targets. /// Initialize targets enabled by the build script via `cfg(llvm_component = "...")`. diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 76aba33b6a4..e5c9f1bf205 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "rustc_metadata" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] flate2 = "1.0" diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index 5de5f5e7571..695bf1f077c 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "rustc_mir" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] arena = { path = "../libarena" } diff --git a/src/librustc_passes/Cargo.toml b/src/librustc_passes/Cargo.toml index 00bdcdc0cc0..de2476775b0 100644 --- a/src/librustc_passes/Cargo.toml +++ b/src/librustc_passes/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "rustc_passes" path = "lib.rs" -crate-type = ["dylib"] [dependencies] log = "0.4" diff --git a/src/librustc_plugin/Cargo.toml b/src/librustc_plugin/Cargo.toml index 5e23aa0d7f7..7486281c1ea 100644 --- a/src/librustc_plugin/Cargo.toml +++ b/src/librustc_plugin/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [lib] name = "rustc_plugin" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] rustc = { path = "../librustc" } diff --git a/src/librustc_privacy/Cargo.toml b/src/librustc_privacy/Cargo.toml index 5bf8024c569..7cf3a5d6dcd 100644 --- a/src/librustc_privacy/Cargo.toml +++ b/src/librustc_privacy/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "rustc_privacy" path = "lib.rs" -crate-type = ["dylib"] [dependencies] rustc = { path = "../librustc" } diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml index 8e3359c7752..548f982fe3b 100644 --- a/src/librustc_resolve/Cargo.toml +++ b/src/librustc_resolve/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" [lib] name = "rustc_resolve" path = "lib.rs" -crate-type = ["dylib"] test = false +doctest = false [dependencies] bitflags = "1.0" diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index 767c726b761..88bb76d2aba 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "rustc_save_analysis" path = "lib.rs" -crate-type = ["dylib"] [dependencies] log = "0.4" diff --git a/src/librustc_target/Cargo.toml b/src/librustc_target/Cargo.toml index 3ab25146331..f1b21365e4b 100644 --- a/src/librustc_target/Cargo.toml +++ b/src/librustc_target/Cargo.toml @@ -7,12 +7,10 @@ edition = "2018" [lib] name = "rustc_target" path = "lib.rs" -crate-type = ["dylib"] [dependencies] bitflags = "1.0" log = "0.4" -rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } rustc_data_structures = { path = "../librustc_data_structures" } serialize = { path = "../libserialize" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index b65813fd8e3..c1ec4e59ef2 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -23,10 +23,6 @@ #[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; // used by deriving -// See librustc_cratesio_shim/Cargo.toml for a comment explaining this. -#[allow(unused_extern_crates)] -extern crate rustc_cratesio_shim; - #[macro_use] extern crate rustc_data_structures; diff --git a/src/librustc_traits/Cargo.toml b/src/librustc_traits/Cargo.toml index da19cc95eb9..bb28ac839a5 100644 --- a/src/librustc_traits/Cargo.toml +++ b/src/librustc_traits/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "rustc_traits" path = "lib.rs" -crate-type = ["dylib"] [dependencies] bitflags = "1.0" diff --git a/src/librustc_typeck/Cargo.toml b/src/librustc_typeck/Cargo.toml index dcfcd74257e..ac396667683 100644 --- a/src/librustc_typeck/Cargo.toml +++ b/src/librustc_typeck/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" [lib] name = "rustc_typeck" path = "lib.rs" -crate-type = ["dylib"] test = false +doctest = false [dependencies] arena = { path = "../libarena" } diff --git a/src/libserialize/Cargo.toml b/src/libserialize/Cargo.toml index fa31a68a75b..c302bcf95dc 100644 --- a/src/libserialize/Cargo.toml +++ b/src/libserialize/Cargo.toml @@ -7,7 +7,6 @@ edition = "2018" [lib] name = "serialize" path = "lib.rs" -crate-type = ["dylib", "rlib"] [dependencies] indexmap = "1" diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml index b48f3c9b8b8..c5daa656476 100644 --- a/src/libsyntax/Cargo.toml +++ b/src/libsyntax/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "syntax" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] bitflags = "1.0" diff --git a/src/libsyntax_ext/Cargo.toml b/src/libsyntax_ext/Cargo.toml index 773f0948a8a..eafbe6371a3 100644 --- a/src/libsyntax_ext/Cargo.toml +++ b/src/libsyntax_ext/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "syntax_ext" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] fmt_macros = { path = "../libfmt_macros" } diff --git a/src/libsyntax_pos/Cargo.toml b/src/libsyntax_pos/Cargo.toml index af7edc0a6bd..eebd25d1faf 100644 --- a/src/libsyntax_pos/Cargo.toml +++ b/src/libsyntax_pos/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "syntax_pos" path = "lib.rs" -crate-type = ["dylib"] +doctest = false [dependencies] serialize = { path = "../libserialize" } diff --git a/src/test/run-make-fulldeps/issue-19371/foo.rs b/src/test/run-make-fulldeps/issue-19371/foo.rs index 0cbdf40e2f9..3c4f2cd541f 100644 --- a/src/test/run-make-fulldeps/issue-19371/foo.rs +++ b/src/test/run-make-fulldeps/issue-19371/foo.rs @@ -2,6 +2,8 @@ extern crate rustc; extern crate rustc_interface; +#[allow(unused_extern_crates)] +extern crate rustc_driver; extern crate syntax; use rustc::session::DiagnosticOutput;