Commit Graph

186 Commits

Author SHA1 Message Date
Michael Woerister
22f6163db4 Make metadata decoding use AllocDecodingState/Session. 2018-06-01 09:32:24 +02:00
Isaac Whitfield
55a00a95cf Remove unnecessary impl methods for CrateMetadata 2018-05-18 09:38:08 -07:00
Isaac Whitfield
680f3b24ba Serialize attributes into the CrateRoot 2018-05-18 09:37:29 -07:00
Isaac Whitfield
ece778e2a3 Attempt to pass CrateMetadata flags on creation 2018-05-18 09:37:29 -07:00
Isaac Whitfield
466fc6815d Avoid generating attributes more than once for CrateMetadata 2018-05-18 09:37:13 -07:00
Isaac Whitfield
f418f1dd78 Remove attribute_cache from CrateMetadata 2018-05-18 09:36:45 -07:00
Vadim Petrochenkov
f4cbc2388f Pass crate editions to macro expansions, update tests 2018-05-17 23:13:09 +03:00
Alex Crichton
4199a6c1ee
Rollup merge of #50538 - michaelwoerister:atomic-cnums, r=Zoxc
Make CrateNum allocation more thread-safe.

This PR makes sure that we can't have race conditions when assigning CrateNums. It's a slight improvement but a larger refactoring of the CrateStore/CrateLoader infrastructure would be good, I think.

r? @Zoxc
2018-05-10 11:35:24 -05:00
Michael Woerister
b8b957d479 Make CrateNum allocation more thread-safe. 2018-05-09 16:05:32 +02:00
Michael Woerister
ea4942835d Don't use Lock for heavily accessed CrateMetadata::cnum_map. 2018-05-08 14:32:31 +02:00
Irina Popa
38e964077b Rename rustc_back::target to rustc_target::spec. 2018-04-26 16:39:44 +03:00
Irina Popa
6f03b80020 rustc_back: move LinkerFlavor, PanicStrategy, and RelroLevel to target. 2018-04-26 16:39:27 +03:00
bors
748c549185 Auto merge of #49847 - sinkuu:save_analysis_implicit_extern, r=petrochenkov
Fix save-analysis generation with extern_in_paths/extern_absolute_paths

Fixes #48742.
2018-04-16 02:34:32 +00:00
Shotaro Yamada
2c7e83f746 Move path_len to ExternCrate 2018-04-13 09:31:43 +09:00
Shotaro Yamada
bbed61d3d2 Extend ExternCrate to cover externs inferred from use or paths 2018-04-11 01:17:59 +09:00
John Kåre Alsaker
006f9b2f56 Make Session.injected_panic_runtime thread-safe 2018-04-10 14:40:26 +02:00
John Kåre Alsaker
dacf9ba00f Make Session.injected_allocator and Session.allocator_kind thread-safe 2018-04-10 14:40:26 +02:00
John Kåre Alsaker
7d33d1a84e Make Session.has_global_allocator thread-safe 2018-04-10 14:40:25 +02:00
Chris Manchester
bd8154784e Take the original extra-filename passed to a crate into account when
resolving it as a dependency.

Fixes #46816
2018-03-28 23:24:41 -07:00
bors
d87c19db6d Auto merge of #49019 - phil-opp:target-spec, r=pnkfelix
Introduce a TargetTriple enum to support absolute target paths

This PR replaces target triple strings with a `TargetTriple` enum, which represents either a target triple or a path to a JSON target file. The path variant is used if the `--target` argument has a `.json` extension, else the target triple variant is used.

The motivation of this PR is support for absolute target paths to avoid the need for setting the `RUST_TARGET_PATH` environment variable (see rust-lang/cargo#4905 for more information). For places where some kind of triple is needed (e.g. in the sysroot folder), we use the file name (without extension).

For compatibility, we keep the old behavior of searching for a file named `$(target_triple).json` in `RUST_TARGET_PATH` for non-official target triples.
2018-03-28 12:56:09 +00:00
Philipp Oppermann
3908b2e443 Introduce a TargetTriple enum to support absolute target paths 2018-03-26 18:57:23 +02:00
Emilio Cobos Álvarez
688275a400
librustc: Convert -C pgo-gen and -C pgo-use into -Z flags.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25 03:30:06 +02:00
Emilio Cobos Álvarez
50a38725e1
rustc_metadata: Load the profiler runtime if we're generating PGO profile data.
This contains all the actual profiling code.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25 03:30:04 +02:00
Alex Crichton
d889957dab rustc: Add a #[wasm_import_module] attribute
This commit adds a new attribute to the Rust compiler specific to the wasm
target (and no other targets). The `#[wasm_import_module]` attribute is used to
specify the module that a name is imported from, and is used like so:

    #[wasm_import_module = "./foo.js"]
    extern {
        fn some_js_function();
    }

Here the import of the symbol `some_js_function` is tagged with the `./foo.js`
module in the wasm output file. Wasm-the-format includes two fields on all
imports, a module and a field. The field is the symbol name (`some_js_function`
above) and the module has historically unconditionally been `"env"`. I'm not
sure if this `"env"` convention has asm.js or LLVM roots, but regardless we'd
like the ability to configure it!

The proposed ES module integration with wasm (aka a wasm module is "just another
ES module") requires that the import module of wasm imports is interpreted as an
ES module import, meaning that you'll need to encode paths, NPM packages, etc.
As a result, we'll need this to be something other than `"env"`!

Unfortunately neither our version of LLVM nor LLD supports custom import modules
(aka anything not `"env"`). My hope is that by the time LLVM 7 is released both
will have support, but in the meantime this commit adds some primitive
encoding/decoding of wasm files to the compiler. This way rustc postprocesses
the wasm module that LLVM emits to ensure it's got all the imports we'd like to
have in it.

Eventually I'd ideally like to unconditionally require this attribute to be
placed on all `extern { ... }` blocks. For now though it seemed prudent to add
it as an unstable attribute, so for now it's not required (as that'd force usage
of a feature gate). Hopefully it doesn't take too long to "stabilize" this!

cc rust-lang-nursery/rust-wasm#29
2018-03-22 13:16:38 -07:00
bors
5e3ecdce4e Auto merge of #48917 - petrochenkov:import, r=oli-obk
syntax: Make imports in AST closer to the source and cleanup their parsing

This is a continuation of https://github.com/rust-lang/rust/pull/45846 in some sense.
2018-03-18 01:50:52 +00:00
Vadim Petrochenkov
c6c6cf9515 AST/HIR: Clarify what the optional name in extern crate items mean 2018-03-17 22:12:21 +03:00
John Kåre Alsaker
4edb539159 Make CrateMetadata thread-safe 2018-03-12 09:35:41 +01:00
Michael Woerister
e5ee01143b Rename exported_symbol_ids query to something more explicit and document what it is doing. 2018-03-06 09:47:43 +01:00
John Kåre Alsaker
b74e97cf42 Replace Rc with Lrc for shared data 2018-03-02 10:48:52 +01:00
Michael Woerister
8756ef6385 Don't include DefIndex in plugin- and proc-macro registrar fn symbol. 2018-01-16 17:30:11 +01:00
Malo Jaffré
3f073c409a Try to fix a perf regression by updating log
Upgrade `log` to `0.4` in multiple crates.
2018-01-07 16:54:05 +01:00
Vadim Petrochenkov
b07e26e36e Resolve absolute paths as extern under a feature flag 2017-12-13 00:02:23 +03:00
Vadim Petrochenkov
9552b9cfd2 rustc_metadata: Refactor away ExternCrateInfo 2017-12-12 23:50:35 +03:00
Matt Brubeck
3024c1434a Use Try syntax for Option in place of macros or match 2017-12-09 14:18:33 -08:00
Irina-Gabriela Popa
dda924ab6a rustc_back: move dynamic_lib to rustc_metadata. 2017-12-04 18:25:29 +02:00
Michael Woerister
d01b89b948 incr.comp.: Provide session to some more decoding contexts. 2017-11-08 14:52:00 +01:00
Michael Woerister
102eaa5c10 incr.comp.: Always require Session when decoding Spans (as to avoid silently wrong results). 2017-11-07 15:14:32 +01:00
Igor Matuszewski
7fa64bcef3 Introduce CrateDisambiguator newtype and fix tests 2017-10-24 17:49:58 +02:00
Igor Matuszewski
d017466d10 Use 128 bit instead of Symbol for crate disambiguator 2017-10-23 18:44:58 +02:00
Michael Woerister
e3f913167c Fix issues uncovered by rebasing:
- 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-18 11:25:34 +02:00
Michal 'vorner' Vaner
94297c6746
Autodetect the type of allocator crate used
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-10 19:59:42 +02:00
Alex Crichton
d724d03389 rustc: Remove DepGraph handling from rustc_metadata
This should now be entirely tracked through queries, so no need to have a
`DepGraph` in the `CStore` object any more!
2017-09-09 21:11:25 -07:00
Alex Crichton
490f34ac0c rustc: Remove CrateStore::used_crate*
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-05 07:37:58 -07:00
Alex Crichton
64a70342e6 rustc: Remove a number of mutable fields in cstore
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-09-05 07:37:28 -07:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
William Brown
0af5c002a2 Add support for dylibs with Address Sanitizer. This supports cdylibs and staticlibs on gnu-linux targets. 2017-07-15 08:22:46 +10:00
Alex Crichton
695dee063b rustc: Implement the #[global_allocator] attribute
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-07-05 14:37:01 -07:00
bors
dfa7e21e4e Auto merge of #42433 - marco-c:profiling, r=alexcrichton
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-14 08:46:14 +00:00
Michael Woerister
8b36d3308e Allocate DefIndices for global crate metadata.
This allows for treating global crate metadata the same as regular metadata with regard to incr. comp.
2017-06-07 12:11:40 +02:00
Marco Castelluccio
60524c55e9 Stop checking uses_std 2017-06-04 17:12:47 +01:00