Commit graph

227 commits

Author SHA1 Message Date
Guillaume Gomez
a2654fb64c Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
bjorn3
489ad8b8b5 Revert "Revert "Merge CrateDisambiguator into StableCrateId""
This reverts commit 8176ab8bc1.
2021-07-06 11:28:04 +02:00
Aaron Hill
7e5a88a56c
Combine individual limit queries into single limits query 2021-07-04 13:02:51 -05:00
Aaron Hill
ff15b5e2c7
Query-ify global limit attribute handling 2021-07-04 12:33:14 -05:00
Bernhard Schuster
67e6a81315 add track_path::path fn for proc-macro usage
Ref #73921
2021-07-02 07:13:19 +02:00
bors
1034282bca Auto merge of #86617 - joshtriplett:prune-dependencies, r=Mark-Simulacrum
Remove unused dependencies from compiler crates

Various compiler crates have dependencies that they don't appear to use. I used some scripting to detect such dependencies, filtered them based on some manual review, and removed those that do indeed appear to be entirely unused.
2021-07-01 03:49:47 +00:00
Camille GILLOT
f69877426a Update comments. 2021-06-30 20:56:49 +02:00
Camille GILLOT
aa1bc5874e Fix AST pretty. 2021-06-30 20:53:10 +02:00
Camille GILLOT
2f28737ebe Move AST crate. 2021-06-30 20:53:10 +02:00
Camille GILLOT
c520cf2253 Arena-allocate Crate during lowering. 2021-06-30 20:31:56 +02:00
Camille GILLOT
e05cd155fe Move lowering to create_global_ctxt. 2021-06-30 20:31:55 +02:00
Camille GILLOT
b80f720a2a Inline lower_to_hir. 2021-06-30 20:31:54 +02:00
Camille GILLOT
18c10fb1a6 Separate resolver creation from expansion. 2021-06-30 20:31:53 +02:00
Camille GILLOT
5f98e5ee56 Simplify DepGraph creation. 2021-06-30 20:31:52 +02:00
Aman Arora
fc273e9bf2 Introduce -Zprofile-closures to evaluate the impact of 2229
This creates a CSV with name "closure_profile_XXXXX.csv", where the
variable part is the process id of the compiler.

To profile a cargo project you can run one of the following depending on
if you're compiling a library or a binary:

```
cargo +stage1 rustc --lib -- -Zprofile-closures
cargo +stage1 rustc --bin -- -Zprofile-closures
```
2021-06-28 14:21:55 -04:00
bors
a1411de9de Auto merge of #86267 - ZuseZ4:master, r=nagisa
Allow loading of llvm plugins on nightly

Based on a discussion in  #82734 / with `@wsmoses.`
Mainly moves [this](0149bc4e7e) behind a -Z flag, so it can only be used on nightly,
as requested by `@nagisa` in https://github.com/rust-lang/rust/issues/82734#issuecomment-835863940

This change allows loading of llvm plugins like Enzyme.
Right now it also requires a shared library LLVM build of rustc for symbol resolution.

```rust
// test.rs
extern { fn __enzyme_autodiff(_: usize, ...) -> f64; }

fn square(x : f64) -> f64 {
   return x * x;
}

fn main() {
   unsafe {
      println!("Hello, world {} {}!", square(3.0), __enzyme_autodiff(square as usize, 3.0));
   }
}
```
```
./rustc test.rs -Z llvm-plugins="./LLVMEnzyme-12.so" -C passes="enzyme"
./test
Hello, world 9 6!
```

I will try to figure out how to simplify the usage and get this into stable in a later iteration,
but having this on nightly will already help testing further steps.
2021-06-26 19:20:41 +00:00
Josh Triplett
b836ecd83a rustc_interface: Remove unused dependency rustc_index
Unused since commit cd7a011f37
("Don't duplicate the extern providers once for each crate").
2021-06-25 01:12:59 -07:00
Smitty
bdfcb88e8b Use HTTPS links where possible 2021-06-23 16:26:46 -04:00
Aaron Hill
99f652ff22 Only hash OutputTypes keys in non-crate-hash mode
This effectively turns OutputTypes into a hybrid where keys (OutputType)
are TRACKED and the values (optional paths) are TRACKED_NO_CRATE_HASH.
2021-06-21 17:22:35 -07:00
Jeremy Fitzhardinge
f1f7f2f508 make -Zno-codegen TRACKED_NO_CRATE_HASH 2021-06-21 17:22:35 -07:00
Jeremy Fitzhardinge
48921ce300 Implement assert_non_crate_hash_different for tests 2021-06-21 17:22:35 -07:00
Jeremy Fitzhardinge
a26d99f348 In --emit KIND=PATH options, only hash KIND
The PATH has no material effect on the emitted artifact, and setting
the patch via `-o` or `--out-dir` does not affect the hash.

Closes https://github.com/rust-lang/rust/issues/86044
2021-06-21 17:22:35 -07:00
bors
ed33787335 Auto merge of #85284 - eggyal:custom-profiler-runtime, r=jackh726
Provide option for specifying the profiler runtime

Currently, if `-Zinstrument-coverage` is enabled, the target is linked
against the `library/profiler_builtins` crate (which pulls in LLVM's
compiler-rt runtime).

This option enables backends to specify an alternative runtime crate for
handling injected instrumentation calls.
2021-06-18 04:39:01 +00:00
Manuel Drehwald
4dbdcd1c5c allow loading of llvm plugins on nightly 2021-06-13 18:23:01 +02:00
bors
0a8629bff6 Auto merge of #85885 - bjorn3:remove_box_region, r=cjgillot
Don't use a generator for BoxedResolver

The generator is non-trivial and requires unsafe code anyway. Using regular unsafe code without a generator is much easier to follow.

Based on #85810 as it touches rustc_interface too.
2021-06-11 16:11:20 +00:00
bjorn3
4301d1ee7d Remove unnecessary transmute 2021-06-10 19:36:27 +02:00
bjorn3
2754d4e514 Add safety comments 2021-06-09 14:51:42 +02:00
bjorn3
e1aa45b64d Use explicit drop impl 2021-06-09 14:47:01 +02:00
Camille GILLOT
aeb050da9f Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
bjorn3
2bf839e870 Don't require LintStore to live for 'a in configure_and_expand_inner 2021-06-08 19:24:17 +02:00
bjorn3
cf1f92a2ca Revert "Let several methods take &Resolver instead of a BoxedResolver wrapper"
This reverts commit 5343ec338f72a61e2f51f9d90117092c8e8a725a.
2021-06-08 19:24:17 +02:00
bjorn3
5e148200d4 Use a submodule as safety boundary for BoxedResolver 2021-06-08 19:24:17 +02:00
bjorn3
86c2d1a2a7 Don't use a generator for BoxedResolver
The generator is non-trivial and requires unsafe code anyway. Using
regular unsafe code without a generator is much easier to follow.
2021-06-08 19:24:17 +02:00
bjorn3
36bdfdc411 Don't return a BoxedResolver on errors 2021-06-08 19:24:17 +02:00
bjorn3
9d9ccec3fc Inline two more methods 2021-06-08 19:24:17 +02:00
bjorn3
d376f032e6 Let several methods take &Resolver instead of a BoxedResolver wrapper 2021-06-08 19:24:16 +02:00
bjorn3
db4d8e2cab Store boxed metadata loader in CrateLoader 2021-06-08 19:24:16 +02:00
bjorn3
ecc68e7879 Replace Pin::new with .as_mut() 2021-06-08 19:24:16 +02:00
bjorn3
bddf151dea Use more accurate lifetimes 2021-06-08 19:24:16 +02:00
bjorn3
1b7ec34878 Inline PinnedGenerator 2021-06-08 19:24:16 +02:00
bjorn3
99e112d282 Inline the rest of box_region 2021-06-08 19:24:16 +02:00
bjorn3
86b3ebe2da Inline box_region macro calls 2021-06-08 19:24:15 +02:00
bjorn3
8f397bc8a0 Simplify box_region macros 2021-06-08 19:24:15 +02:00
bjorn3
8176ab8bc1 Revert "Merge CrateDisambiguator into StableCrateId"
This reverts commit d0ec85d3fb.
2021-06-07 10:37:45 +02:00
bors
cc9610bf5a Auto merge of #85810 - bjorn3:further_driver_cleanup, r=varkor
Driver improvements

This PR contains a couple of cleanups for the driver and a few small improvements for the custom codegen backend interface. It also implements `--version` and `-Cpasses=list` support for custom codegen backends.
2021-06-07 02:30:24 +00:00
bors
c79419af07 Auto merge of #84449 - alexcrichton:metadata-in-object, r=nagisa
rustc: Store metadata-in-rlibs in object files

This commit updates how rustc compiler metadata is stored in rlibs.
Previously metadata was stored as a raw file that has the same format as
`--emit metadata`. After this commit, however, the metadata is encoded
into a small object file which has one section which is the contents of
the metadata.

The motivation for this commit is to fix a common case where #83730
arises. The problem is that when rustc crates a `dylib` crate type it
needs to include entire rlib files into the dylib, so it passes
`--whole-archive` (or the equivalent) to the linker. The problem with
this, though, is that the linker will attempt to read all files in the
archive. If the metadata file were left as-is (today) then the linker
would generate an error saying it can't read the file. The previous
solution was to alter the rlib just before linking, creating a new
archive in a temporary directory which has the metadata file removed.

This problem from before this commit is now removed if the metadata file
is stored in an object file that the linker can read. The only caveat we
have to take care of is to ensure that the linker never actually
includes the contents of the object file into the final output. We apply
similar tricks as the `.llvmbc` bytecode sections to do this.

This involved changing the metadata loading code a bit, namely updating
some of the LLVM C APIs used to use non-deprecated ones and fiddling
with the lifetimes a bit to get everything to work out. Otherwise though
this isn't intended to be a functional change really, only that metadata
is stored differently in archives now.

This should end up fixing #83730 because by default dylibs will no
longer have their rlib dependencies "altered" meaning that
split-debuginfo will continue to have valid paths pointing at the
original rlibs. (note that we still "alter" rlibs if LTO is enabled to
remove Rust object files and we also "alter" for the #[link(cfg)]
feature, but that's rarely used).

Closes #83730
2021-06-04 19:29:50 +00:00
Alex Crichton
0e0338744d rustc: Store metadata-in-rlibs in object files
This commit updates how rustc compiler metadata is stored in rlibs.
Previously metadata was stored as a raw file that has the same format as
`--emit metadata`. After this commit, however, the metadata is encoded
into a small object file which has one section which is the contents of
the metadata.

The motivation for this commit is to fix a common case where #83730
arises. The problem is that when rustc crates a `dylib` crate type it
needs to include entire rlib files into the dylib, so it passes
`--whole-archive` (or the equivalent) to the linker. The problem with
this, though, is that the linker will attempt to read all files in the
archive. If the metadata file were left as-is (today) then the linker
would generate an error saying it can't read the file. The previous
solution was to alter the rlib just before linking, creating a new
archive in a temporary directory which has the metadata file removed.

This problem from before this commit is now removed if the metadata file
is stored in an object file that the linker can read. The only caveat we
have to take care of is to ensure that the linker never actually
includes the contents of the object file into the final output. We apply
similar tricks as the `.llvmbc` bytecode sections to do this.

This involved changing the metadata loading code a bit, namely updating
some of the LLVM C APIs used to use non-deprecated ones and fiddling
with the lifetimes a bit to get everything to work out. Otherwise though
this isn't intended to be a functional change really, only that metadata
is stored differently in archives now.

This should end up fixing #83730 because by default dylibs will no
longer have their rlib dependencies "altered" meaning that
split-debuginfo will continue to have valid paths pointing at the
original rlibs. (note that we still "alter" rlibs if LTO is enabled to
remove Rust object files and we also "alter" for the #[link(cfg)]
feature, but that's rarely used).

Closes #83730
2021-06-04 10:05:20 -07:00
bjorn3
d96446c53c Use SyncOnceCell in get_codegen_backend
This reduces the amount of unsafe code in get_codegen_backend
2021-06-04 13:20:04 +02:00
bjorn3
1870f9b05f Allow printing the version of the default codegen backend if it isn't llvm 2021-06-04 13:20:04 +02:00
bjorn3
45c9775361 A couple of small cleanups 2021-06-04 13:20:04 +02:00