summary refs log tree commit diff
path: root/src/librustc/session
AgeCommit message (Collapse)AuthorLines
2017-10-09Auto merge of #45075 - alexcrichton:inline-less, r=michaelwoeristerbors-0/+2
rustc: Don't inline in CGUs at -O0 This commit tweaks the behavior of inlining functions into multiple codegen units when rustc is compiling in debug mode. Today rustc will unconditionally treat `#[inline]` functions by translating them into all codegen units that they're needed within, marking the linkage as `internal`. This commit changes the behavior so that in debug mode (compiling at `-O0`) rustc will instead only translate `#[inline]` functions into *one* codegen unit, forcing all other codegen units to reference this one copy. The goal here is to improve debug compile times by reducing the amount of translation that happens on behalf of multiple codegen units. It was discovered in #44941 that increasing the number of codegen units had the adverse side effect of increasing the overal work done by the compiler, and the suspicion here was that the compiler was inlining, translating, and codegen'ing more functions with more codegen units (for example `String` would be basically inlined into all codegen units if used). The strategy in this commit should reduce the cost of `#[inline]` functions to being equivalent to one codegen unit, which is only translating and codegen'ing inline functions once. Collected [data] shows that this does indeed improve the situation from [before] as the overall cpu-clock time increases at a much slower rate and when pinned to one core rustc does not consume significantly more wall clock time than with one codegen unit. One caveat of this commit is that the symbol names for inlined functions that are only translated once needed some slight tweaking. These inline functions could be translated into multiple crates and we need to make sure the symbols don't collideA so the crate name/disambiguator is mixed in to the symbol name hash in these situations. [data]: https://github.com/rust-lang/rust/issues/44941#issuecomment-334880911 [before]: https://github.com/rust-lang/rust/issues/44941#issuecomment-334583384
2017-10-09Auto merge of #45064 - alexcrichton:reduce-codegen-units, r=michaelwoeristerbors-2/+16
rustc: Reduce default CGUs to 16 Rationale explained in the included comment as well as #44941
2017-10-08Auto merge of #45012 - Gankro:noalias, r=arielb1bors-0/+2
Add -Zmutable-noalias flag We disabled noalias on mutable references a long time ago when it was clear that llvm was incorrectly handling this in relation to unwinding edges. Since then, a few things have happened: * llvm has cleaned up a bunch of the issues (I'm told) * we've added a nounwind codegen option As such, I would like to add this -Z flag so that we can evaluate if the codegen bugs still exist, and if this significantly affects the codegen of different projects, with an eye towards permanently re-enabling it (or at least making it a stable option).
2017-10-08Rollup merge of #45090 - rust-lang:petrochenkov-patch-1, r=alexcrichtonkennytm-1/+2
Document that `-C ar=PATH` doesn't do anything Are there any plans to use an external archiver in the future? IIRC, it was used before, but its use was replaced with LLVM's built-in archive management machinery. I can't found a relevant PR though. EDIT: Found it - https://github.com/rust-lang/rust/pull/26926! The `-C` option is stable so it still can't be removed right away even if there are no plans to use it (but maybe it can be deprecated?). Target specifications have a field for archiver as well, which is unused too (these ones are unstable, so I guess it can be removed). r? @alexcrichton
2017-10-07rustc: Don't inline in CGUs at -O0Alex Crichton-0/+2
This commit tweaks the behavior of inlining functions into multiple codegen units when rustc is compiling in debug mode. Today rustc will unconditionally treat `#[inline]` functions by translating them into all codegen units that they're needed within, marking the linkage as `internal`. This commit changes the behavior so that in debug mode (compiling at `-O0`) rustc will instead only translate `#[inline]` functions into *one* codegen unit, forcing all other codegen units to reference this one copy. The goal here is to improve debug compile times by reducing the amount of translation that happens on behalf of multiple codegen units. It was discovered in #44941 that increasing the number of codegen units had the adverse side effect of increasing the overal work done by the compiler, and the suspicion here was that the compiler was inlining, translating, and codegen'ing more functions with more codegen units (for example `String` would be basically inlined into all codegen units if used). The strategy in this commit should reduce the cost of `#[inline]` functions to being equivalent to one codegen unit, which is only translating and codegen'ing inline functions once. Collected [data] shows that this does indeed improve the situation from [before] as the overall cpu-clock time increases at a much slower rate and when pinned to one core rustc does not consume significantly more wall clock time than with one codegen unit. One caveat of this commit is that the symbol names for inlined functions that are only translated once needed some slight tweaking. These inline functions could be translated into multiple crates and we need to make sure the symbols don't collideA so the crate name/disambiguator is mixed in to the symbol name hash in these situations. [data]: https://github.com/rust-lang/rust/issues/44941#issuecomment-334880911 [before]: https://github.com/rust-lang/rust/issues/44941#issuecomment-334583384
2017-10-07Document that `-C ar=PATH` doesn't do anythingVadim Petrochenkov-1/+2
2017-10-07rustc: Implement ThinLTOAlex Crichton-14/+6
This commit is an implementation of LLVM's ThinLTO for consumption in rustc itself. Currently today LTO works by merging all relevant LLVM modules into one and then running optimization passes. "Thin" LTO operates differently by having more sharded work and allowing parallelism opportunities between optimizing codegen units. Further down the road Thin LTO also allows *incremental* LTO which should enable even faster release builds without compromising on the performance we have today. This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then also implements two forms of ThinLTO: * In one mode we'll *only* perform ThinLTO over the codegen units produced in a single compilation. That is, we won't load upstream rlibs, but we'll instead just perform ThinLTO amongst all codegen units produced by the compiler for the local crate. This is intended to emulate a desired end point where we have codegen units turned on by default for all crates and ThinLTO allows us to do this without performance loss. * In anther mode, like full LTO today, we'll optimize all upstream dependencies in "thin" mode. Unlike today, however, this LTO step is fully parallelized so should finish much more quickly. There's a good bit of comments about what the implementation is doing and where it came from, but the tl;dr; is that currently most of the support here is copied from upstream LLVM. This code duplication is done for a number of reasons: * Controlling parallelism means we can use the existing jobserver support to avoid overloading machines. * We will likely want a slightly different form of incremental caching which integrates with our own incremental strategy, but this is yet to be determined. * This buys us some flexibility about when/where we run ThinLTO, as well as having it tailored to fit our needs for the time being. * Finally this allows us to reuse some artifacts such as our `TargetMachine` creation, where all our options we used today aren't necessarily supported by upstream LLVM yet. My hope is that we can get some experience with this copy/paste in tree and then eventually upstream some work to LLVM itself to avoid the duplication while still ensuring our needs are met. Otherwise I fear that maintaining these bindings may be quite costly over the years with LLVM updates!
2017-10-06rustc: Reduce default CGUs to 16Alex Crichton-2/+16
Rationale explained in the included comment as well as #44941
2017-10-05Auto merge of #44940 - philipc:remap-path, r=michaelwoeristerbors-3/+1
Don't use remapped path when loading modules and include files Fixes bug reported in https://github.com/rust-lang/rust/issues/41555#issuecomment-327866056. cc @michaelwoerister
2017-10-03Add -Zmutable-noalias flagAlexis Beingessner-0/+2
2017-09-30rustc: Enable LTO and multiple codegen unitsAlex Crichton-18/+0
This commit is a refactoring of the LTO backend in Rust to support compilations with multiple codegen units. The immediate result of this PR is to remove the artificial error emitted by rustc about `-C lto -C codegen-units-8`, but longer term this is intended to lay the groundwork for LTO with incremental compilation and ultimately be the underpinning of ThinLTO support. The problem here that needed solving is that when rustc is producing multiple codegen units in one compilation LTO needs to merge them all together. Previously only upstream dependencies were merged and it was inherently relied on that there was only one local codegen unit. Supporting this involved refactoring the optimization backend architecture for rustc, namely splitting the `optimize_and_codegen` function into `optimize` and `codegen`. After an LLVM module has been optimized it may be blocked and queued up for LTO, and only after LTO are modules code generated. Non-LTO compilations should look the same as they do today backend-wise, we'll spin up a thread for each codegen unit and optimize/codegen in that thread. LTO compilations will, however, send the LLVM module back to the coordinator thread once optimizations have finished. When all LLVM modules have finished optimizing the coordinator will invoke the LTO backend, producing a further list of LLVM modules. Currently this is always a list of one LLVM module. The coordinator then spawns further work to run LTO and code generation passes over each module. In the course of this refactoring a number of other pieces were refactored: * Management of the bytecode encoding in rlibs was centralized into one module instead of being scattered across LTO and linking. * Some internal refactorings on the link stage of the compiler was done to work directly from `CompiledModule` structures instead of lists of paths. * The trans time-graph output was tweaked a little to include a name on each bar and inflate the size of the bars a little
2017-09-30Don't use remapped path when loading modules and include filesPhilip Craig-3/+1
2017-09-29Auto merge of #44853 - alexcrichton:debug-codegen-units, r=michaelwoeristerbors-28/+69
rustc: Default 32 codegen units at O0 This commit changes the default of rustc to use 32 codegen units when compiling in debug mode, typically an opt-level=0 compilation. Since their inception codegen units have matured quite a bit, gaining features such as: * Parallel translation and codegen enabling codegen units to get worked on even more quickly. * Deterministic and reliable partitioning through the same infrastructure as incremental compilation. * Global rate limiting through the `jobserver` crate to avoid overloading the system. The largest benefit of codegen units has forever been faster compilation through parallel processing of modules on the LLVM side of things, using all the cores available on build machines that typically have many available. Some downsides have been fixed through the features above, but the major downside remaining is that using codegen units reduces opportunities for inlining and optimization. This, however, doesn't matter much during debug builds! In this commit the default number of codegen units for debug builds has been raised from 1 to 32. This should enable most `cargo build` compiles that are bottlenecked on translation and/or code generation to immediately see speedups through parallelization on available cores. Work is being done to *always* enable multiple codegen units (and therefore parallel codegen) but it requires #44841 at least to be landed and stabilized, but stay tuned if you're interested in that aspect!
2017-09-28Update to the `cc` crateAlex Crichton-14/+14
This is the name the `gcc` crate has moved to
2017-09-26rustc: Default 32 codegen units at O0Alex Crichton-28/+69
This commit changes the default of rustc to use 32 codegen units when compiling in debug mode, typically an opt-level=0 compilation. Since their inception codegen units have matured quite a bit, gaining features such as: * Parallel translation and codegen enabling codegen units to get worked on even more quickly. * Deterministic and reliable partitioning through the same infrastructure as incremental compilation. * Global rate limiting through the `jobserver` crate to avoid overloading the system. The largest benefit of codegen units has forever been faster compilation through parallel processing of modules on the LLVM side of things, using all the cores available on build machines that typically have many available. Some downsides have been fixed through the features above, but the major downside remaining is that using codegen units reduces opportunities for inlining and optimization. This, however, doesn't matter much during debug builds! In this commit the default number of codegen units for debug builds has been raised from 1 to 32. This should enable most `cargo build` compiles that are bottlenecked on translation and/or code generation to immediately see speedups through parallelization on available cores. Work is being done to *always* enable multiple codegen units (and therefore parallel codegen) but it requires #44841 at least to be landed and stabilized, but stay tuned if you're interested in that aspect!
2017-09-23incr.comp.: Remove support for loading metadata fingerprints.Michael Woerister-1/+1
2017-09-23Rollup merge of #44717 - ↵Corey Farwell-1/+2
pnkfelix:debugflags-borrowckmir-implies-emitendregions, r=arielb1 Make `-Z borrowck-mir` imply that `EndRegion`'s should be emitted. Before this change, the `-Z borrowck-mir` flag is useless if you do not also pass `-Z emit-end-regions`. So, in the same spirit as f2892ad281cb11421ebae741d698e0af14d3ecf6, make `-Z borrowck-mir` also emit `EndRegion` statements. (This will hopefully avoid some initial speed bumps for new-comers helping out with NLL.)
2017-09-21Auto merge of #44627 - zackmdavis:the_capgate_perogative, r=nrcbors-3/+7
`--cap-lints allow` switches off `can_emit_warnings` This boolean field on the error `Handler` is toggled to silence warnings when `-A warnings` is passed. (This is actually a separate mechanism from the global lint level—whether there's some redundancy to be factored away here is an important question, but not one we concern ourselves with in this commit.) But the same rationale applies for `--cap-lints allow`. In particular, this makes the "soft" feature-gate warning introduced in 8492ad24 (which is not a lint, but just calls `struct_span_warn`) not pollute the builds of dependent crates. Thanks to @kennytm for pointing out the potential of `can_emit_warnings` for this purpose. Resolves #44213.
2017-09-20Make `-Z borrowck-mir` imply that `EndRegion`'s should be emitted.Felix S. Klock II-1/+2
2017-09-19Fix a typo in rustc help menuBob Sun-1/+1
Change from native-static-deps to native-static-libs.
2017-09-18Rollup merge of #44548 - oyvindln:rustc_help_fix, r=arielb1Alex Crichton-3/+3
Add proper help line for `-C inline threshold` Looks like someone accidentally some words when adding this. This also remove a period on a different help line for consistency, as no options have a period.
2017-09-18incr.comp.: Fix rebase fallout.Michael Woerister-0/+33
2017-09-16`--cap-lints allow` switches off `can_emit_warnings`Zack M. Davis-3/+7
This boolean field on the error `Handler` is toggled to silence warnings when `-A warnings` is passed. (This is actually a separate mechanism from the global lint level—whether there's some redundancy to be factored away here is an important question, but not one we concern ourselves with in this commit.) But the same rationale applies for `--cap-lints allow`. In particular, this makes the "soft" feature-gate warning introduced in 8492ad24 (which is not a lint, but just calls `struct_span_warn`) not pollute the builds of dependent crates. Thanks to @kennytm for pointing out the potential of `can_emit_warnings` for this purpose. Resolves #44213.
2017-09-14rustc: Remove `Session::dep_graph`Alex Crichton-21/+34
This commit removes the `dep_graph` field from the `Session` type according to issue #44390. Most of the fallout here was relatively straightforward and the `prepare_session_directory` function was rejiggered a bit to reuse the results in the later-called `load_dep_graph` function. Closes #44390
2017-09-13Remove the other period and start with lowercase for more consistencyoyvindln-2/+2
2017-09-13Add proper help line for inline thresholdoyvindln-2/+2
Also remove a period on a different help line for consistency
2017-09-12Remove the `cstore` reference from Session in order to prepare encapsulating ↵Michael Woerister-22/+9
CrateStore access in tcx.
2017-09-11rustc: replace usize with u64 and ConstUsize.Eduard-Mihai Burtescu-5/+5
2017-09-05Emit `EndRegion` statements when given `-Z mir-emit-validate=N` (for N > 0).Felix S. Klock II-0/+4
This way the miri test suite does not have to be updated to explcitly request `-Z emit-end-regions`.
2017-09-05Skip EndRegion emission by default. Use `-Z emit-end-regions` to reenable it.Felix S. Klock II-0/+2
The main intent is to fix cases where EndRegion emission is believed to be causing excess peak memory pressure. It may also be a welcome change to people inspecting the MIR output who find the EndRegions to be a distraction.
2017-09-04Auto merge of #43067 - pornel:libdeps, r=nrcbors-1/+3
Compact display of static lib dependencies Fixes #33173 Instead of displaying one dependency per line, I've changed the format to display them all in one line. As a bonus they're in format of linker flags (`-lfoo`), so the output can be copy&pasted if one is actually going to link as suggested.
2017-08-23-Z profile-query-and-key, separate from -Z profile-query; query key is ↵Matthew Hammer-1/+9
string option
2017-08-23inc comp: -Z profile-queries support; see also ↵Matthew Hammer-0/+3
https://github.com/rust-lang-nursery/rust-forge/blob/master/profile-queries.md
2017-08-22Introduce temporary target feature crt_static_respectedSamuel Holland-0/+9
This feature allows targets to opt in to full support of the crt-static feature. Currently, crt-static is allowed on all targets, even those that really can't or really shouldn't support it. This works because it is very loose in the specification of its effects. Changing the behavior of crt-static to be more strict in how it chooses libraries and links executables would likely cause compilation to fail on these platforms. To avoid breaking existing uses of crt-static, whitelist targets that support the new, stricter behavior. For all other targets, this changes crt-static from being "mostly a no-op" to "explicitly a no-op".
2017-08-22Factor out a helper for the getting C runtime linkageSamuel Holland-0/+16
This commit makes no functional changes.
2017-08-22--print=native-static-libsKornel-1/+3
2017-08-16MIR based borrow check (opt-in).Felix S. Klock II-0/+2
One can either use `-Z borrowck-mir` or add the `#[rustc_mir_borrowck]` attribute to opt into MIR based borrow checking. Note that regardless of whether one opts in or not, AST-based borrow check will still run as well. The errors emitted from AST-based borrow check will include a "(Ast)" suffix in their error message, while the errors emitted from MIR-based borrow check will include a "(Mir)" suffix. post-rebase: removed check for intra-statement mutual conflict; replaced with assertion checking that at most one borrow is generated per statement. post-rebase: removed dead code: `IdxSet::pairs` and supporting stuff.
2017-08-12Fix some typosBastien Orivel-2/+2
2017-08-09rustc: Rearchitect lints to be emitted more eagerlyAlex Crichton-18/+11
In preparation for incremental compilation this commit refactors the lint handling infrastructure in the compiler to be more "eager" and overall more incremental-friendly. Many passes of the compiler can emit lints at various points but before this commit all lints were buffered in a table to be emitted at the very end of compilation. This commit changes these lints to be emitted immediately during compilation using pre-calculated lint level-related data structures. Linting today is split into two phases, one set of "early" lints run on the `syntax::ast` and a "late" set of lints run on the HIR. This commit moves the "early" lints to running as late as possible in compilation, just before HIR lowering. This notably means that we're catching resolve-related lints just before HIR lowering. The early linting remains a pass very similar to how it was before, maintaining context of the current lint level as it walks the tree. Post-HIR, however, linting is structured as a method on the `TyCtxt` which transitively executes a query to calculate lint levels. Each request to lint on a `TyCtxt` will query the entire crate's 'lint level data structure' and then go from there about whether the lint should be emitted or not. The query depends on the entire HIR crate but should be very quick to calculate (just a quick walk of the HIR) and the red-green system should notice that the lint level data structure rarely changes, and should hopefully preserve incrementality. Overall this resulted in a pretty big change to the test suite now that lints are emitted much earlier in compilation (on-demand vs only at the end). This in turn necessitated the addition of many `#![allow(warnings)]` directives throughout the compile-fail test suite and a number of updates to the UI test suite.
2017-08-04Auto merge of #43403 - RalfJung:mir-validate, r=nikomatsakisbors-0/+3
Add MIR Validate statement This adds statements to MIR that express when types are to be validated (following [Types as Contracts](https://internals.rust-lang.org/t/types-as-contracts/5562)). Obviously nothing is stabilized, and in fact a `-Z` flag has to be passed for behavior to even change at all. This is meant to make experimentation with Types as Contracts in miri possible. The design is definitely not final. Cc @nikomatsakis @aturon
2017-07-31optionally only emit basic validation for functions containing unsafe block ↵Ralf Jung-2/+3
/ unsafe function
2017-07-31async-llvm(22): mw invokes mad html skillz to produce graphical LLVM timing ↵Michael Woerister-0/+2
reports.
2017-07-31async-llvm(14): Move LTO/codegen-unit conflict check to beginning of ↵Michael Woerister-0/+17
compilation process.
2017-07-30add -Z flag for AddValidation passRalf Jung-0/+2
2017-07-22Use config::pub_only rather than a spearate api modeNick Cameron-5/+0
2017-07-20Auto merge of #43271 - Nashenas88:nll, r=nikomatsakisbors-0/+2
Add empty MIR pass for non-lexical lifetimes This is the first step for #43234.
2017-07-19explanatory error on `--print target-spec-json` without unstable optionsZack M. Davis-2/+9
Resolves #41683.
2017-07-19Add empty MIR pass for non-lexical lifetimesPaul Faria-0/+2
2017-07-18Implement FromStr for RelroLevel rather than duplicating the matchJohannes Löthberg-3/+6
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2017-07-18Move relro_level from CodegenOptions to DebuggingOptionsJohannes Löthberg-6/+6
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>