summary refs log tree commit diff
path: root/compiler/rustc_interface/src
AgeCommit message (Collapse)AuthorLines
2021-06-11Auto merge of #85885 - bjorn3:remove_box_region, r=cjgillotbors-40/+87
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-10Remove unnecessary transmutebjorn3-2/+1
2021-06-09Add safety commentsbjorn3-0/+5
2021-06-09Use explicit drop implbjorn3-8/+13
2021-06-08Do not require the DefPathTable to construct the on-disk cache.Camille GILLOT-3/+1
2021-06-08Don't require LintStore to live for 'a in configure_and_expand_innerbjorn3-1/+1
2021-06-08Revert "Let several methods take &Resolver instead of a BoxedResolver wrapper"bjorn3-29/+25
This reverts commit 5343ec338f72a61e2f51f9d90117092c8e8a725a.
2021-06-08Use a submodule as safety boundary for BoxedResolverbjorn3-55/+60
2021-06-08Don't use a generator for BoxedResolverbjorn3-119/+48
The generator is non-trivial and requires unsafe code anyway. Using regular unsafe code without a generator is much easier to follow.
2021-06-08Don't return a BoxedResolver on errorsbjorn3-5/+4
2021-06-08Inline two more methodsbjorn3-24/+14
2021-06-08Let several methods take &Resolver instead of a BoxedResolver wrapperbjorn3-25/+29
2021-06-08Store boxed metadata loader in CrateLoaderbjorn3-2/+2
2021-06-08Replace Pin::new with .as_mut()bjorn3-3/+5
2021-06-08Use more accurate lifetimesbjorn3-8/+6
2021-06-08Inline PinnedGeneratorbjorn3-42/+29
2021-06-08Inline the rest of box_regionbjorn3-22/+79
2021-06-08Inline box_region macro callsbjorn3-5/+77
2021-06-08Simplify box_region macrosbjorn3-2/+1
2021-06-07Revert "Merge CrateDisambiguator into StableCrateId"bjorn3-8/+40
This reverts commit d0ec85d3fb6d322496cb8f4bc1c21e19f23284ad.
2021-06-07Auto merge of #85810 - bjorn3:further_driver_cleanup, r=varkorbors-44/+38
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-04Auto merge of #84449 - alexcrichton:metadata-in-object, r=nagisabors-1/+1
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-04rustc: Store metadata-in-rlibs in object filesAlex Crichton-1/+1
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-04Use SyncOnceCell in get_codegen_backendbjorn3-11/+9
This reduces the amount of unsafe code in get_codegen_backend
2021-06-04Allow printing the version of the default codegen backend if it isn't llvmbjorn3-22/+15
2021-06-04A couple of small cleanupsbjorn3-12/+15
2021-06-04Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514Yuki Okushi-1/+0
Remove unused feature gates The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`) The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though. The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-01Avoid a clone of output_filenames.Camille GILLOT-1/+1
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-1/+1
2021-06-01Auto merge of #85153 - cjgillot:qresolve, r=Aaron1011bors-1/+1
Reduce the amount of untracked state in TyCtxt Access to untracked global state may generate instances of #84970. The GlobalCtxt contains the lowered HIR, the resolver outputs and interners. By wrapping the resolver inside a query, we make sure those accesses are properly tracked. As a no_hash query, all dependent queries essentially become `eval_always`, what they should have been from the beginning.
2021-05-31Auto merge of #85702 - Aaron1011:no-vec-sort, r=michaelwoeristerbors-4/+6
Don't sort a `Vec` before computing its `DepTrackingHash` Previously, we sorted the vec prior to hashing, making the hash independent of the original (command-line argument) order. However, the original vec was still always kept in the original order, so we were relying on the rest of the compiler always working with it in an 'order-independent' way. This assumption was not being upheld by the `native_libraries` query - the order of the entires in its result depends on the order of entries in `Options.libs`. This lead to an 'unstable fingerprint' ICE when the `-l` arguments were re-ordered. This PR removes the sorting logic entirely. Re-ordering command-line arguments (without adding/removing/changing any arguments) seems like a really niche use case, and correctly optimizing for it would require additional work. By always hashing arguments in their original order, we can entirely avoid a cause of 'unstable fingerprint' errors.
2021-05-31Remove unused feature gatesbjorn3-1/+0
2021-05-30Avoid a clone of output_filenames.Camille GILLOT-1/+1
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-40/+8
2021-05-25Don't sort a `Vec` before computing its `DepTrackingHash`Aaron Hill-4/+6
Previously, we sorted the vec prior to hashing, making the hash independent of the original (command-line argument) order. However, the original vec was still always kept in the original order, so we were relying on the rest of the compiler always working with it in an 'order-independent' way. This assumption was not being upheld by the `native_libraries` query - the order of the entires in its result depends on the order of entries in `Options.libs`. This lead to an 'unstable fingerprint' ICE when the `-l` arguments were re-ordered. This PR removes the sorting logic entirely. Re-ordering command-line arguments (without adding/removing/changing any arguments) seems like a really niche use case, and correctly optimizing for it would require additional work. By always hashing arguments in their original order, we can entirely avoid a cause of 'unstable fingerprint' errors.
2021-05-25Don't panic when failing to initialize incremental directory.Eric Huss-3/+3
2021-05-24Make `thir_check_unsafety` itself responsible for checking gateLeSeulArtichaut-3/+2
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-23/+14
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-15fix version_str commentRalf Jung-1/+1
2021-05-13Auto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakisbors-1/+6
Introduce the beginning of a THIR unsafety checker This poses the foundations for the THIR unsafety checker, so that it can be implemented incrementally: - implements a rudimentary `Visitor` for the THIR (which will definitely need some tweaking in the future) - introduces a new `-Zthir-unsafeck` flag which tells the compiler to use THIR unsafeck instead of MIR unsafeck - implements detection of unsafe functions - adds revisions to the UI tests to test THIR unsafeck alongside MIR unsafeck This uses a very simple query design, where bodies are unsafety-checked on a body per body basis. This however has some big flaws: - the unsafety-checker builds the THIR itself, which means a lot of work is duplicated with MIR building constructing its own copy of the THIR - unsafety-checking closures is currently completely wrong: closures should take into account the "safety context" in which they are created, here we are considering that closures are always a safe context I had intended to fix these problems in follow-up PRs since they are always gated under the `-Zthir-unsafeck` flag (which is explicitely noted to be unsound). r? `@nikomatsakis` cc https://github.com/rust-lang/project-thir-unsafeck/issues/3 https://github.com/rust-lang/project-thir-unsafeck/issues/7
2021-05-12Use () for analysis.Camille GILLOT-5/+3
2021-05-12Use () for privacy.Camille GILLOT-2/+2
2021-05-12Use () for proc_macro_decls_static.Camille GILLOT-10/+6
2021-05-12Use () for plugin_registrar_fn.Camille GILLOT-3/+1
2021-05-12Use () for entry_fn.Camille GILLOT-3/+2
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-10/+7
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-12Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillotbors-9/+5
rustc_driver cleanup Best reviewed one commit at a time.
2021-05-11Introduce the (WIP) THIR unsafety checkerLeSeulArtichaut-1/+6
2021-05-10Adjust target search algorithm for rustlib pathSimonas Kazlauskas-2/+1
With this the concerns expressed in #83800 should be addressed.
2021-05-08Make -Z new-llvm-pass-manager an Option<bool>Nikita Popov-1/+1
To allow it to have an LLVM version dependent default.