summary refs log tree commit diff
path: root/src/librustc_metadata/creader.rs
AgeCommit message (Collapse)AuthorLines
2017-09-18Fix issues uncovered by rebasing:Michael Woerister-1/+4
- Don't hash traits in scope as part of HIR hashing any more. - Some queries returned DefIndexes from other crates. - Provide a generic way of stably hashing maps (not used everywhere yet).
2017-09-10Autodetect the type of allocator crate usedMichal 'vorner' Vaner-36/+63
Annotate the allocator crates (allocator_system, allocator_jemalloc) by the type of allocator they are. If one is requested as an exe allocator, detect its type by the flags. This has the effect that using this (de jure wrong) configuration in the target spec works instead of producing a really unhelpful and arcane linker error: "exe-allocation-crate": "alloc_system" Fixes #43524.
2017-09-09rustc: Remove `DepGraph` handling from rustc_metadataAlex Crichton-43/+23
This should now be entirely tracked through queries, so no need to have a `DepGraph` in the `CStore` object any more!
2017-09-05rustc: Remove `CrateStore::used_crate*`Alex Crichton-2/+2
This commit removes the `use_crates` and `used_crate_source` methods in favor of a mix of queries and helper methods being used now instead.
2017-09-05rustc: Remove a number of mutable fields in cstoreAlex Crichton-220/+1
This commit started by moving methods from `CrateStore` to queries, but it ended up necessitating some deeper refactorings to move more items in general to queries. Before this commit the *resolver* would walk over the AST and process foreign modules (`extern { .. }` blocks) and collect `#[link]` annotations. It would then also process the command line `-l` directives and such. This information was then stored as precalculated lists in the `CrateStore` object for iterating over later. After this, commit, however, this pass no longer happens during resolution but now instead happens through queries. A query for the linked libraries of a crate will crawl the crate for `extern` blocks and then process the linkage annotations at that time.
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-19/+19
Like #43008 (f668999), but _much more aggressive_.
2017-07-15Add support for dylibs with Address Sanitizer. This supports cdylibs and ↵William Brown-14/+43
staticlibs on gnu-linux targets.
2017-07-05rustc: Implement the #[global_allocator] attributeAlex Crichton-54/+138
This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/197 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
2017-06-14Auto merge of #42433 - marco-c:profiling, r=alexcrichtonbors-0/+19
Build instruction profiler runtime as part of compiler-rt r? @alexcrichton This is #38608 with some fixes. Still missing: - [x] testing with profiler enabled on some builders (on which ones? Should I add the option to some of the already existing configurations, or create a new configuration?); - [x] enabling distribution (on which builders?); - [x] documentation.
2017-06-07Allocate DefIndices for global crate metadata.Michael Woerister-6/+2
This allows for treating global crate metadata the same as regular metadata with regard to incr. comp.
2017-06-04Stop checking uses_stdMarco Castelluccio-21/+12
2017-06-04Merge branch 'profiling' of github.com:whitequark/rust into profilingMarco Castelluccio-0/+28
2017-05-31Build DefPathHash->DefId table when incr.comp. is enabledMichael Woerister-1/+1
2017-05-17Auto merge of #41911 - michaelwoerister:querify_trait_def, r=nikomatsakisbors-0/+9
Remove interior mutability from TraitDef by turning fields into queries This PR gets rid of anything `std::cell` in `TraitDef` by - moving the global list of trait impls from `TraitDef` into a query, - moving the list of trait impls relevent for some self-type from `TraitDef` into a query - moving the specialization graph of trait impls into a query, and - moving `TraitDef::object_safety` into a query. I really like how querifying things not only helps with incremental compilation and on-demand, but also just plain makes the code cleaner `:)` There are also some smaller fixes in the PR. Commits can be reviewed separately. r? @eddyb or @nikomatsakis
2017-05-15ICH: Hash lists of local trait impls as part of the HIR.Michael Woerister-0/+9
2017-05-14Remove rustc_llvm dependency from rustc_metadataRobin Kruppe-0/+2
Move the code for loading metadata from rlibs and dylibs from rustc_metadata into rustc_trans, and introduce a trait to avoid introducing a direct dependency on rustc_trans. This means rustc_metadata is no longer rebuilt when LLVM changes.
2017-05-09Auto merge of #41709 - michaelwoerister:close-metadata-ich-holes, r=nikomatsakisbors-25/+51
incr.comp.: Hash more pieces of crate metadata to detect changes there. This PR adds incr. comp. hashes for non-`Entry` pieces of data in crate metadata. The first part of it I like: `EntryBuilder` is refactored into the more generally applicable `IsolatedEncoder` which provides means of encoding something into metadata while also feeding the encoded data into an incr. comp. hash. We already did this for `Entry`, now we are doing it for various other pieces of data too, like the set of exported symbols and so on. The hashes generated there are persisted together with the per-`Entry` hashes and are also used for dep-graph dirtying the same way. The second part of the PR I'm not entirely happy with: In order to make sure that we don't forget registering a read to the new `DepNodes` introduced here, I added the `Tracked<T>` struct. This struct wraps a value and requires a `DepNode` when accessing the wrapped value. This makes it harder to overlook adding read edges in the right places and works just fine. However, crate metadata is already used in places where there is no `tcx` yet or even in places where no `cnum` has been assigned -- this makes it harder to apply this feature consistently or implement it ergonomically. The result is not too bad but there's a bit more code churn and a bit more opportunity to get something wrong than I would have liked. On the other hand, wrapping things in `Tracked<T>` already has revealed some bugs, so there's definitely some value in it. This is still a work in progress: - [x] I need to write some test cases. - [x] Accessing the CodeMap should really be dependency tracked too, especially with the new path-remapping feature. cc @nikomatsakis
2017-05-08Remove need for &format!(...) or &&"" dances in `span_label` callsOliver Schneider-3/+3
2017-05-08incr.comp.: Hash more pieces of crate metadata to detect changes there.Michael Woerister-25/+51
2017-05-01Add profiling support, through the rustc -Z profile flag.whitequark-0/+28
When -Z profile is passed, the GCDAProfiling LLVM pass is added to the pipeline, which uses debug information to instrument the IR. After compiling with -Z profile, the $(OUT_DIR)/$(CRATE_NAME).gcno file is created, containing initial profiling information. After running the program built, the $(OUT_DIR)/$(CRATE_NAME).gcda file is created, containing branch counters. The created *.gcno and *.gcda files can be processed using the "llvm-cov gcov" and "lcov" tools. The profiling data LLVM generates does not faithfully follow the GCC's format for *.gcno and *.gcda files, and so it will probably not work with other tools (such as gcov itself) that consume these files.
2017-04-25Support AddressSanitizer and ThreadSanitizer on x86_64-apple-darwin.kennytm-5/+20
ASan and TSan are supported on macOS, and this commit enables their support. The sanitizers are always built as *.dylib on Apple platforms, so they cannot be statically linked into the corresponding `rustc_?san.rlib`. The dylibs are directly copied to `lib/rustlib/x86_64-apple-darwin/lib/` instead. Note, although Xcode also ships with their own copies of ASan/TSan dylibs, we cannot use them due to version mismatch. There is a caveat: the sanitizer libraries are linked as @rpath, so the user needs to additionally pass `-C rpath`: rustc -Z sanitizer=address -C rpath file.rs ^~~~~~~~ Otherwise there will be a runtime error: dyld: Library not loaded: @rpath/libclang_rt.asan_osx_dynamic.dylib Referenced from: /path/to/executable Reason: image not found Abort trap: 6 The next commit includes a temporary change in compiler to force the linker to emit a usable @rpath.
2017-04-22cache attributes of items from foreign cratesAriel Ben-Yehuda-0/+1
this avoids parsing item attributes on each call to `item_attrs`, which takes off 33% (!) of translation time and 50% (!) of trans-item collection time.
2017-04-13remove `LinkMeta` from `SharedCrateContext`Niko Matsakis-3/+3
A number of things were using `crate_hash` that really ought to be using `crate_disambiguator` (e.g., to create the plugin symbol names). They have been updated. It is important to remove `LinkMeta` from `SharedCrateContext` since it contains a hash of the entire crate, and hence it will change whenever **anything** changes (which would then require rebuilding **everything**).
2017-03-27Fix various useless derefs and slicingsOliver Schneider-1/+1
2017-03-23Remove internal liblogAlex Crichton-1/+1
This commit deletes the internal liblog in favor of the implementation that lives on crates.io. Similarly it's also setting a convention for adding crates to the compiler. The main restriction right now is that we want compiler implementation details to be unreachable from normal Rust code (e.g. requires a feature), and by default everything in the sysroot is reachable via `extern crate`. The proposal here is to require that crates pulled in have these lines in their `src/lib.rs`: #![cfg_attr(rustbuild, feature(staged_api, rustc_private))] #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] This'll mean that by default they're not using these attributes but when compiled as part of the compiler they do a few things: * Mark themselves as entirely unstable via the `staged_api` feature and the `#![unstable]` attribute. * Allow usage of other unstable crates via `feature(rustc_private)` which is required if the crate relies on any other crates to compile (other than std).
2017-03-21Correctly get source for metadata crate type;Austin Bonander-1/+2
replace `unwrap()` with `expect()`
2017-03-19Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrcbors-3/+5
`TokenStream`-based attributes, paths in attribute and derive macro invocations This PR - refactors `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`. - supports macro invocation paths for attribute procedural macros. - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;` - supports macro invocation paths for derive procedural macros. - e.g. `#[derive(foo::Bar, super::Baz)] struct S;` - supports arbitrary tokens as arguments to attribute procedural macros. - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;` - supports using arbitrary tokens in "inert attributes" with derive procedural macros. - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);` where `#[proc_macro_derive(Foo, attributes(inert))]` r? @nrc
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-3/+5
2017-03-12Update usages of 'OSX' (and other old names) to 'macOS'.Corey Farwell-1/+1
As of last year with version 'Sierra', the Mac operating system is now called 'macOS'.
2017-02-28Implement function-like procedural macros ( `#[proc_macro]`)Austin Bonander-1/+10
2017-02-23Better handling of lib defaultsPeter Wagenet-2/+12
2017-02-12Allow using inert attributes from `proc_macro_derive`s with ↵Jeffrey Seyfried-4/+3
`#![feature(proc_macro)]`.
2017-02-08sanitizer supportJorge Aparicio-1/+63
2017-02-05Rollup merge of #39442 - keeperofdakeys:expand-derives, r=jseyfriedCorey Farwell-3/+3
Expand derive macros in the MacroExpander This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver. Fixes https://github.com/rust-lang/rust/issues/39326 r? @jseyfried
2017-02-05Rename CustomDerive to ProcMacroDerive for macros 1.1Josh Driver-3/+3
2017-02-04Auto merge of #38426 - vadimcn:nobundle, r=alexcrichtonbors-0/+11
Implement kind="static-nobundle" (RFC 1717) This implements the "static-nobundle" library kind (last item from #37403). Rustc handles "static-nobundle" libs very similarly to dylibs, except that on Windows, uses of their symbols do not get marked with "dllimport". Which is the whole point of this feature.
2017-02-03Don't link "nobundle" libs which had already been included in upstream crate.Vadim Chugunov-0/+3
2017-01-19Feature gateVadim Chugunov-0/+7
2017-01-19Implement the "static-nobundle" library kind (RFC 1717).Vadim Chugunov-0/+1
These are static libraries that are not bundled (as the name implies) into rlibs and staticlibs that rustc generates, and must be present when the final binary artifact is being linked.
2017-01-16Implement `#[proc_macro_attribute]`Austin Bonander-0/+10
* Add support for `#[proc_macro]` * Reactivate `proc_macro` feature and gate `#[proc_macro_attribute]` under it * Have `#![feature(proc_macro)]` imply `#![feature(use_extern_macros)]`, error on legacy import of proc macros via `#[macro_use]`
2017-01-09metadata: Add is_exported_symbol() method to CrateStore.Michael Woerister-0/+3
2016-12-29Change --crate-type metadata to --emit=metadataNick Cameron-2/+1
2016-12-16definitions: Add some timing stats for DefPathTable decoding.Michael Woerister-1/+6
2016-12-16definitions: Store DefPath data in separate table in metadataMichael Woerister-1/+1
2016-12-05Consider only libs that aren't excluded by #[link(cfg=...)]Vadim Chugunov-4/+20
2016-12-02Rename _all_ library instances.Vadim Chugunov-1/+0
2016-12-01Tighten up error checking of library renames.Vadim Chugunov-5/+37
2016-12-01Remove the "linked_from" feature.Vadim Chugunov-22/+1
2016-12-01Implement native library kind and name overrides from the command line.Vadim Chugunov-8/+14
2016-12-01Emit 'dllimport' attribute for dylib foreign items on Windows.Vadim Chugunov-25/+53