Skip to content

Commit

Permalink
Auto merge of #30043 - arielb1:split-metadata, r=nikomatsakis
Browse files Browse the repository at this point in the history
This improves bootstrap times because of better parallelism - though I need to measure how much - and allows metadata to be modified without triggering a full recompile. This also ensures that metadata handling and the rest of rustc remain decoupled, which is a first step for switching to a new metadata format.

This is a [breaking-change] to all plugin authors because of the following renames:
 * `rustc::plugin` is now `rustc_plugin`
 * `rustc::metadata` is now `rustc_metadata`
 * Most data types from `rustc::metadata`, along with `LOCAL_CRATE`, are now in `rustc::middle::cstore`.
 * The CStore methods were split between the `rustc::middle::CrateStore` trait (and trait object) and the `rustc_metadata::cstore::CStore`, with an `Rc<CrateStore>` stored in the `Session`. The inner `CStore` can be accessed via the inner `Any` bound, but this is deprecated.

r? @nikomatsakis
  • Loading branch information
bors committed Nov 26, 2015
2 parents 6f3becb + 43a6deb commit 6ef02ef
Show file tree
Hide file tree
Showing 105 changed files with 1,760 additions and 1,244 deletions.
11 changes: 7 additions & 4 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ TARGET_CRATES := libc std flate arena term \
alloc_system
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
rustc_data_structures rustc_front rustc_platform_intrinsics
rustc_data_structures rustc_front rustc_platform_intrinsics \
rustc_plugin rustc_metadata
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
TOOLS := compiletest rustdoc rustc rustbook error-index-generator

Expand Down Expand Up @@ -87,21 +88,23 @@ DEPS_test := std getopts serialize rbml term native:rust_test_helpers

DEPS_syntax := std term serialize log fmt_macros arena libc rustc_bitflags

DEPS_rustc := syntax flate arena serialize getopts rbml rustc_front\
DEPS_rustc := syntax flate arena serialize getopts rustc_front\
log graphviz rustc_llvm rustc_back rustc_data_structures
DEPS_rustc_back := std syntax rustc_llvm rustc_front flate log libc
DEPS_rustc_borrowck := rustc rustc_front log graphviz syntax
DEPS_rustc_data_structures := std log serialize
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
rustc_trans rustc_privacy rustc_lint rustc_front

rustc_trans rustc_privacy rustc_lint rustc_front rustc_plugin \
rustc_metadata
DEPS_rustc_front := std syntax log serialize
DEPS_rustc_lint := rustc log syntax
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
DEPS_rustc_metadata := rustc rustc_front syntax rbml
DEPS_rustc_mir := rustc rustc_front syntax
DEPS_rustc_resolve := rustc rustc_front log syntax
DEPS_rustc_platform_intrinsics := rustc rustc_llvm
DEPS_rustc_plugin := rustc rustc_metadata syntax
DEPS_rustc_privacy := rustc rustc_front log syntax
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics
Expand Down
12 changes: 7 additions & 5 deletions src/doc/book/compiler-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ extend the compiler's behavior with new syntax extensions, lint checks, etc.
A plugin is a dynamic library crate with a designated *registrar* function that
registers extensions with `rustc`. Other crates can load these extensions using
the crate attribute `#![plugin(...)]`. See the
[`rustc::plugin`](../rustc/plugin/index.html) documentation for more about the
[`rustc_plugin`](../rustc_plugin/index.html) documentation for more about the
mechanics of defining and loading a plugin.

If present, arguments passed as `#![plugin(foo(... args ...))]` are not
interpreted by rustc itself. They are provided to the plugin through the
`Registry`'s [`args` method](../rustc/plugin/registry/struct.Registry.html#method.args).
`Registry`'s [`args` method](../rustc_plugin/registry/struct.Registry.html#method.args).

In the vast majority of cases, a plugin should *only* be used through
`#![plugin]` and not through an `extern crate` item. Linking a plugin would
Expand Down Expand Up @@ -43,13 +43,14 @@ that implements Roman numeral integer literals.
extern crate syntax;
extern crate rustc;
extern crate rustc_plugin;
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::ast::TokenTree;
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
use syntax::ext::build::AstBuilder; // trait for expr_usize
use rustc::plugin::Registry;
use rustc_plugin::Registry;
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
-> Box<MacResult + 'static> {
Expand Down Expand Up @@ -120,7 +121,7 @@ The advantages over a simple `fn(&str) -> u32` are:
In addition to procedural macros, you can define new
[`derive`](../reference.html#derive)-like attributes and other kinds of
extensions. See
[`Registry::register_syntax_extension`](../rustc/plugin/registry/struct.Registry.html#method.register_syntax_extension)
[`Registry::register_syntax_extension`](../rustc_plugin/registry/struct.Registry.html#method.register_syntax_extension)
and the [`SyntaxExtension`
enum](https://doc.rust-lang.org/syntax/ext/base/enum.SyntaxExtension.html). For
a more involved macro example, see
Expand Down Expand Up @@ -189,10 +190,11 @@ extern crate syntax;
// Load rustc as a plugin to get macros
#[macro_use]
extern crate rustc;
extern crate rustc_plugin;
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
EarlyLintPassObject, LintArray};
use rustc::plugin::Registry;
use rustc_plugin::Registry;
use syntax::ast;
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
Expand Down
2 changes: 1 addition & 1 deletion src/doc/complement-lang-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ can be combined to control the exact logging you want to see. For example, when
debugging linking in the compiler, you might set the following:

```sh
RUST_LOG=rustc::metadata::creader,rustc::util::filesearch,rustc::back::rpath
RUST_LOG=rustc_metadata::creader,rustc::util::filesearch,rustc::back::rpath
```

For a full description, see [the logging crate][1].
Expand Down
5 changes: 4 additions & 1 deletion src/grammar/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ use std::path::Path;
use syntax::parse;
use syntax::parse::lexer;
use rustc::session::{self, config};
use rustc::middle::cstore::DummyCrateStore;

use std::rc::Rc;
use syntax::ast;
use syntax::ast::Name;
use syntax::codemap;
Expand Down Expand Up @@ -286,7 +288,8 @@ fn main() {

let options = config::basic_options();
let session = session::build_session(options, None,
syntax::diagnostics::registry::Registry::new(&[]));
syntax::diagnostics::registry::Registry::new(&[]),
Rc::new(DummyCrateStore));
let filemap = session.parse_sess.codemap().new_filemap(String::from("<n/a>"), code);
let mut lexer = lexer::StringReader::new(session.diagnostic(), filemap);
let cm = session.codemap();
Expand Down
61 changes: 0 additions & 61 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1899,51 +1899,6 @@ contain references (with a maximum lifetime of `'a`).
[1]: https://github.com/rust-lang/rfcs/pull/1156
"##,

E0454: r##"
A link name was given with an empty name. Erroneous code example:
```
#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
```
The rust compiler cannot link to an external library if you don't give it its
name. Example:
```
#[link(name = "some_lib")] extern {} // ok!
```
"##,

E0458: r##"
An unknown "kind" was specified for a link attribute. Erroneous code example:
```
#[link(kind = "wonderful_unicorn")] extern {}
// error: unknown kind: `wonderful_unicorn`
```
Please specify a valid "kind" value, from one of the following:
* static
* dylib
* framework
"##,

E0459: r##"
A link was used without a name parameter. Erroneous code example:
```
#[link(kind = "dylib")] extern {}
// error: #[link(...)] specified without `name = "foo"`
```
Please add the name parameter to allow the rust compiler to find the library
you want. Example:
```
#[link(kind = "dylib", name = "some_lib")] extern {} // ok!
```
"##,

E0493: r##"
A type with a destructor was assigned to an invalid type of variable. Erroneous
code example:
Expand Down Expand Up @@ -2144,20 +2099,6 @@ register_diagnostics! {
E0400, // overloaded derefs are not allowed in constants
E0452, // malformed lint attribute
E0453, // overruled by outer forbid
E0455, // native frameworks are only available on OSX targets
E0456, // plugin `..` is not available for triple `..`
E0457, // plugin `..` only found in rlib format, but must be available...
E0460, // found possibly newer version of crate `..`
E0461, // couldn't find crate `..` with expected target triple ..
E0462, // found staticlib `..` instead of rlib or dylib
E0463, // can't find crate for `..`
E0464, // multiple matching crates for `..`
E0465, // multiple .. candidates for `..` found
E0466, // bad macro import
E0467, // bad macro reexport
E0468, // an `extern crate` loading macros must be at the crate root
E0469, // imported macro not found
E0470, // reexported macro not found
E0471, // constant evaluation error: ..
E0472, // asm! is unsupported on this target
E0473, // dereference of reference outside its lifetime
Expand All @@ -2181,6 +2122,4 @@ register_diagnostics! {
E0491, // in type `..`, reference has a longer lifetime than the data it...
E0492, // cannot borrow a constant which contains interior mutability
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
E0498, // malformed plugin attribute
E0514, // metadata version mismatch
}
2 changes: 1 addition & 1 deletion src/librustc/front/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use metadata::cstore::LOCAL_CRATE;
use middle::cstore::LOCAL_CRATE;
use middle::def_id::{DefId, DefIndex};
use rustc_data_structures::fnv::FnvHashMap;
use rustc_front::hir;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/front/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use self::MapEntry::*;
use self::collector::NodeCollector;
pub use self::definitions::{Definitions, DefKey, DefPath, DefPathData, DisambiguatedDefPathData};

use metadata::inline::InlinedItem;
use metadata::inline::InlinedItem as II;
use middle::cstore::InlinedItem;
use middle::cstore::InlinedItem as II;
use middle::def_id::DefId;

use syntax::abi;
Expand Down
10 changes: 2 additions & 8 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#![feature(const_fn)]
#![feature(core)]
#![feature(duration_span)]
#![feature(dynamic_lib)]
#![feature(enumset)]
#![feature(hashmap_hasher)]
#![feature(into_cow)]
Expand Down Expand Up @@ -68,7 +67,6 @@ extern crate rustc_back;
extern crate rustc_front;
extern crate rustc_data_structures;
extern crate serialize;
extern crate rbml;
extern crate collections;
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
Expand Down Expand Up @@ -100,9 +98,8 @@ pub mod front {
}

pub mod middle {
pub mod expr_use_visitor; // STAGE0: increase glitch immunity
pub mod astconv_util;
pub mod astencode;
pub mod expr_use_visitor; // STAGE0: increase glitch immunity
pub mod cfg;
pub mod check_const;
pub mod check_static_recursion;
Expand All @@ -111,6 +108,7 @@ pub mod middle {
pub mod check_no_asm;
pub mod check_rvalues;
pub mod const_eval;
pub mod cstore;
pub mod dataflow;
pub mod dead;
pub mod def;
Expand Down Expand Up @@ -138,12 +136,8 @@ pub mod middle {
pub mod weak_lang_items;
}

pub mod metadata;

pub mod session;

pub mod plugin;

pub mod lint;

pub mod util {
Expand Down
Loading

0 comments on commit 6ef02ef

Please sign in to comment.