Commit Graph

142 Commits

Author SHA1 Message Date
Victor Ding a47fdb99c0 Support linking from a .rlink file
Flag `-Z no-link` was previously introduced, which allows creating
an `.rlink` file to perform compilation without linking.
This change enables linking from an `.rlink` file.
2020-02-11 20:19:28 +11:00
bors fc07615c49 Auto merge of #68601 - 0dvictor:split, r=tmandry
Split `join_codegen_and_link()` into two steps

`join_codegen_and_link()` is split to `join_codegen()` and `link()`.
2020-02-04 05:48:54 +00:00
Victor Ding ae51d2ba32 Split `join_codegen_and_link()` into two steps
`join_codegen_and_link()` is split to `join_codegen()` and `link()`.
2020-02-04 11:09:50 +11:00
Wesley Wiser f5f86be1d4 Add support for enabling the LLVM time-trace feature
I found this helpful while investigating an LLVM performance issue.
Passing `-Z llvm-time-trace` causes a `llvm_timings.json` file to be
created. This file can be inspected in either the Chrome Profiler tools
or with any other compatible tool like SpeedScope.

More information on the LLVM feature:

- https://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/

- https://reviews.llvm.org/rL357340
2020-02-01 14:19:17 -05:00
Victor Ding 6a6ebb4403 Add `-Z no-link` flag
Adds a compiler option to allow rustc compile a crate without linking.
With this flag, rustc serializes codegen_results into a .rlink file.
2020-01-23 11:00:36 +11:00
John Kåre Alsaker f45758cddc Compile some CGUs in parallel at the start of codegen 2020-01-09 22:36:15 +01:00
John Kåre Alsaker 5427601e9e Change -Z time event naming scheme and make them generic activities 2020-01-09 07:06:40 +01:00
John Kåre Alsaker 5a485ce4a3 Use self profile infrastructure for -Z time and -Z time-passes 2020-01-05 02:57:14 +01:00
Vadim Petrochenkov 70f1d57048 Rename `syntax_pos` to `rustc_span` in source code 2020-01-01 09:15:18 +03:00
Mark Rousskov a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Aaron Hill 1aa34d4dec
Remove `extern crate` declarations 2019-12-11 09:50:12 -05:00
Aaron Hill fca192cca2
Fix fallout from rebase 2019-12-11 09:50:12 -05:00
Alex Crichton 7f23e6e8d7
rustc: Link LLVM directly into rustc again
This commit builds on #65501 continue to simplify the build system and
compiler now that we no longer have multiple LLVM backends to ship by
default. Here this switches the compiler back to what it once was long
long ago, which is linking LLVM directly to the compiler rather than
dynamically loading it at runtime. The `codegen-backends` directory of
the sysroot no longer exists and all relevant support in the build
system is removed. Note that `rustc` still supports a dynamically loaded
codegen backend as it did previously, it just no longer supports
dynamically loaded codegen backends in its own sysroot.

Additionally as part of this the `librustc_codegen_llvm` crate now once
again explicitly depends on all of its crates instead of implicitly
loading them through the sysroot. This involved filling out its
`Cargo.toml` and deleting all the now-unnecessary `extern crate`
annotations in the header of the crate. (this in turn required adding a
number of imports for names of macros too).

The end results of this change are:

* Rustbuild's build process for the compiler as all the "oh don't forget
  the codegen backend" checks can be easily removed.
* Building `rustc_codegen_llvm` is much simpler since it's simply
  another compiler crate.
* Managing the dependencies of `rustc_codegen_llvm` is much simpler since
  it's "just another `Cargo.toml` to edit"
* The build process should be a smidge faster because there's more
  parallelism in the main rustc build step rather than splitting
  `librustc_codegen_llvm` out to its own step.
* The compiler is expected to be slightly faster by default because the
  codegen backend does not need to be dynamically loaded.
* Disabling LLVM as part of rustbuild is still supported, supporting
  multiple codegen backends is still supported, and dynamic loading of a
  codegen backend is still supported.
2019-12-11 09:50:11 -05:00
varkor e3a8ea4e18 Use `to_option` in various places 2019-12-06 12:23:23 +00:00
Mark Rousskov 984c74a40a Move cgu_reuse_tracker to librustc_session 2019-12-03 12:18:32 -05:00
Mazdak Farrokhzad b45f21d38e move UnstableFeatures -> rustc_feature 2019-11-30 02:50:47 +01:00
Eduard-Mihai Burtescu 1e42072673 rustc_codegen_ssa: hide address ops from the declare_local interface. 2019-10-31 20:25:56 +02:00
Mazdak Farrokhzad fb12c70852 rustc, rustc_passes: don't depend on syntax_expand.
This is done by moving some data definitions to syntax::expand.
2019-10-27 17:05:57 +01:00
Vadim Petrochenkov 222503a354 rustc: Add a convenience alias for `dyn MetadataLoader + Sync` 2019-10-24 20:51:33 +03:00
Nicholas Nethercote 2da7a9c0d9 Use `Symbol` for codegen unit names.
This is a straightforward replacement except for two places where we
have to convert to `LocalInternedString` to get a stable sort.
2019-10-21 18:30:40 +11:00
Mazdak Farrokhzad d420d719c4 move syntax::ext to new crate syntax_expand 2019-10-16 10:59:53 +02:00
bjorn3 5f6ddb94a6 Move span_invalid_monomorphization_error from cg_llvm to cg_ssa
The associated long diagnostic didn't get registered before
2019-10-13 14:35:14 +02:00
bjorn3 5f203d5988 Move some provides from cg_llvm to rustc_interface 2019-10-13 14:35:14 +02:00
bjorn3 41d329c10d Remove unused method CodegenBackend::diagnostics 2019-10-13 14:35:14 +02:00
Jon Gjengset 45aca119a6
Stabilize mem::take (mem_take)
Tracking issue: https://github.com/rust-lang/rust/issues/61129
2019-10-08 18:04:18 -04:00
Tyler Mandry 8f5f92a07a
Rollup merge of #64840 - michaelwoerister:self-profiling-raii-refactor, r=wesleywiser
SelfProfiler API refactoring and part one of event review

This PR refactors the `SelfProfiler` a little bit so that most profiling methods are RAII-based. The codegen backend code already had something similar, this refactoring pulls this functionality up into `SelfProfiler` itself, for general use.

The second commit of this PR is a review and update of the existing events we are already recording. Names have been made more consistent. CGU names have been removed from event names. They will be added back in when function parameter recording is implemented.

There is still some work to be done for adding new events, especially around trait resolution and the incremental system.

r? @wesleywiser
2019-10-01 23:06:16 -07:00
Michael Woerister d94262272b Self-Profiling: Make names of existing events more consistent and use new API. 2019-09-30 13:31:56 +02:00
csmoe 64f61c7888 remove indexed_vec re-export from rustc_data_structures 2019-09-29 16:48:31 +00:00
Mark Rousskov b8a040fc5f Remove tx_to_llvm_workers from TyCtxt
This can be kept within the codegen backend crates entirely
2019-09-25 16:57:27 -04:00
Guanqun Lu 5355a16150 use println!() 2019-09-15 23:15:06 +08:00
Mark Rousskov 41b39fce98 Remove rustc_diagnostic_macros feature 2019-09-05 12:35:18 -04:00
Mark Rousskov b437240cee Replace diagnostic plugins with macro_rules 2019-09-05 12:35:15 -04:00
Alex Crichton 1a4330d2a2 rustc: Handle modules in "fat" LTO more robustly
When performing a "fat" LTO the compiler has a whole mess of codegen
units that it links together. To do this it needs to select one module
as a "base" module and then link everything else into this module.
Previously LTO passes assume that there's at least one module in-memory
to link into, but nowadays that's not always true! With incremental
compilation modules may actually largely be cached and it may be
possible that there's no in-memory modules to work with.

This commit updates the logic of the LTO backend to handle modules a bit
more uniformly during a fat LTO. This commit immediately splits them
into two lists, one serialized and one in-memory. The in-memory list is
then searched for the largest module and failing that we simply
deserialize the first serialized module and link into that. This
refactoring avoids juggling three lists, two of which are serialized
modules and one of which is half serialized and half in-memory.

Closes #63349
2019-08-27 13:51:14 -07:00
Alex Crichton d05c4d5459 Deduplicate rustc_demangle in librustc_codegen_llvm
This commit removes the crates.io dependency of `rustc-demangle` from
`rustc_codegen_llvm`. This crate is actually already pulled in to part
of the `librustc_driver` build and with the upcoming pipelining
implementation in Cargo it causes build issues if `rustc-demangle` is
left to its own devices.

This is not currently required, but once pipelining is enabled for
rustc's own build it will be required to build correctly.
2019-07-31 15:04:25 -07:00
Vadim Petrochenkov 676d282dd3 Deny `unused_lifetimes` through rustbuild 2019-07-28 18:47:02 +03:00
Vadim Petrochenkov 434152157f Remove lint annotations in specific crates that are already enforced by rustbuild
Remove some random unnecessary lint `allow`s
2019-07-28 18:46:24 +03:00
Vadim Petrochenkov a93fdfedf3 Merge `rustc_allocator` into `libsyntax_ext` 2019-07-24 12:27:58 +03:00
Alex Crichton 345ba505ec 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!
2019-07-07 03:23:00 +02:00
Mazdak Farrokhzad 485a084b45
Rollup merge of #61545 - flip1995:internal_lints, r=oli-obk
Implement another internal lints

cc #49509

This adds ~~two~~ one internal lint~~s~~:
1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc #59669
2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in #49509~~

~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~

TODO (not directly relevant for review):
- [ ] https://github.com/rust-lang/rust/pull/59316#discussion_r280186517 (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) 🤔 cc @eddyb)
- [x] https://github.com/rust-lang/rust/pull/61735#discussion_r292389870
- [x] Check explicitly for the `{declare,impl}_lint_pass!` macros

r? @oli-obk
2019-07-05 20:26:51 +02:00
Mazdak Farrokhzad 88c007cd04
Rollup merge of #62249 - czipperz:use-mem-take-instead-of-replace-default, r=dtolnay,Centril
Use mem::take instead of mem::replace with default
2019-07-04 01:38:46 +02:00
Jeremy Stucki ec711767a7
Remove needless lifetimes 2019-07-03 10:01:02 +02:00
Chris Gregory b0c199a969 Enable mem_take feature in relevant crates 2019-07-01 20:21:53 -07:00
flip1995 084c829fb8
Enable internal lints in bootstrap 2019-06-24 10:45:20 +02:00
Matthew Jasper d0311e7154 Deny explicit_outlives_requirements in the compiler 2019-06-22 17:13:19 +01:00
Eduard-Mihai Burtescu 356a37d8d1 rustc: remove unused lifetimes. 2019-06-18 18:10:26 +03:00
Eduard-Mihai Burtescu b25b466a88 rustc: remove 'x: 'y bounds (except from comments/strings). 2019-06-18 18:10:21 +03:00
Eduard-Mihai Burtescu afc39bbf24 Run `rustfmt --file-lines ...` for changes from previous commits. 2019-06-14 18:58:32 +03:00
Eduard-Mihai Burtescu f3f9d6dfd9 Unify all uses of 'gcx and 'tcx. 2019-06-14 18:58:23 +03:00
Eduard-Mihai Burtescu 4c98cb6f75 rustc_codegen_llvm: `deny(internal)`. 2019-06-12 16:06:35 +03:00
Eduard-Mihai Burtescu 87b6b86468 rustc_codegen_llvm: `deny(unused_lifetimes)`. 2019-06-12 16:02:03 +03:00