about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
AgeCommit message (Collapse)AuthorLines
2023-09-24Don't use a thread to load the dep graphJohn Kåre Alsaker-44/+3
2023-09-23Enable drop_tracking_mir by default.Camille GILLOT-10/+6
2023-09-22Merge `ExternProviders` into the general `Providers` structOli Scherer-17/+5
2023-09-22Have a single struct for queries and hookOli Scherer-12/+12
2023-09-22Add a way to decouple the implementation and the declaration of a TyCtxt method.Oli Scherer-5/+8
2023-09-21Move `DepKind` to `rustc_query_system` and define it as `u16`John Kåre Alsaker-1/+42
2023-09-17Auto merge of #114750 - Enselic:metadata-dep-info, r=compiler-errorsbors-7/+13
Make `.rmeta` file in `dep-info` have correct name (`lib` prefix) Since `filename_for_metadata()` and `OutputFilenames::path(OutputType::Metadata)` had different logic for the name of the metadata file, the `.d` file contained a file name different from the actual name used. Share the logic to fix the out-of-sync name. Without this fix, the `.d` file contained dash-separated_something-extra.rmeta: dash-separated.rs instead of libdash_separated_something-extra.rmeta: dash-separated.rs which is the name of the file that is actually written by the compiler. Worth noting: It took me several iterations to get all tests to pass, so I am relatively confident that this PR does not break anything. Closes #68839
2023-09-13Auto merge of #115735 - bjorn3:better_list_crate_metadata, r=wesleywiserbors-1/+1
Extend rustc -Zls This makes it show a lot more things and thus a lot more useful.
2023-09-11Rollup merge of #115730 - bjorn3:some_driver_refactors, r=compiler-errorsMatthias Krüger-0/+2
Some more small driver refactors To improve clarity and simplify some code.
2023-09-10Fix testbjorn3-1/+1
2023-09-10Deprecate the pre_configure querybjorn3-0/+2
Only deprecating it rather than making it private to just in case someone has a use case for it.
2023-09-09Use `FreezeLock` for `CStore`John Kåre Alsaker-5/+3
2023-09-08Auto merge of #113492 - nebulark:pr_96475, r=petrochenkovbors-0/+10
Add CL and CMD into to pdb debug info Partial fix for https://github.com/rust-lang/rust/issues/96475 The Arg0 and CommandLineArgs of the MCTargetOptions cpp class are not set within https://github.com/rust-lang/rust/blob/bb548f964572f7fe652716f5897d9050a31c936e/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp#L378 This causes LLVM to not neither output any compiler path (cl) nor the arguments that were used when invoking it (cmd) in the PDB file. This fix adds the missing information to the target machine so LLVM can use it.
2023-09-08Add missing Debuginfo to PDB debug file on windows.Florian Schmiderer-0/+10
Set Arg0 and CommandLineArgs in MCTargetoptions so LLVM outputs correct CL and CMD in LF_DEBUGINFO instead of empty/invalid values.
2023-09-03Make `.rmeta` file in `dep-info` have correct name (`lib` prefix)Martin Nordholts-7/+13
Since `filename_for_metadata()` and `OutputFilenames::path(OutputType::Metadata)` had different logic for the name of the metadata file, the `.d` file contained a file name different from the actual name used. Share the logic to fix the out-of-sync name. Closes 68839.
2023-09-02Rename `Freeze` to `FreezeLock`John Kåre Alsaker-2/+4
2023-09-02Add `Freeze` type and use it to store `Definitions`John Kåre Alsaker-2/+2
2023-09-01Use `OnceLock` for `SingleCache`John Kåre Alsaker-5/+5
2023-08-30Auto merge of #111713 - Zoxc:lock-switch, r=nnethercotebors-8/+28
Use conditional synchronization for Lock This changes `Lock` to use synchronization only if `mode::is_dyn_thread_safe` could be true. This reduces overhead for the parallel compiler running with 1 thread. The emitters are changed to use `DynSend` instead of `Send` so they can still use `Lock`. A Rayon thread pool is not used with 1 thread anymore, as session globals contains `Lock`s which are no longer `Sync`. Performance improvement with 1 thread and `cfg(parallel_compiler)`: <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.7665s</td><td align="right">1.7336s</td><td align="right">💚 -1.86%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2780s</td><td align="right">0.2736s</td><td align="right">💚 -1.61%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9994s</td><td align="right">0.9824s</td><td align="right">💚 -1.70%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5875s</td><td align="right">1.5656s</td><td align="right">💚 -1.38%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.0682s</td><td align="right">5.9532s</td><td align="right">💚 -1.90%</td></tr><tr><td>Total</td><td align="right">10.6997s</td><td align="right">10.5083s</td><td align="right">💚 -1.79%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9831s</td><td align="right">💚 -1.69%</td></tr></table> cc `@SparrowLii`
2023-08-30Auto merge of #114908 - cjgillot:no-let-under, r=compiler-errorsbors-3/+2
Do not compute unneeded query results. r? `@ghost`
2023-08-30Use conditional synchronization for LockJohn Kåre Alsaker-8/+28
2023-08-28Auto merge of #115267 - nikic:revert-elf-relaxation, r=compiler-errorsbors-1/+1
Revert relax_elf_relocations default change This reverts commit 441086879821d554ecdfde391e767d1a954fd5e2 (#106511). The change caused linker failures with the binutils version used by cross (#115239), as well as miscompilations when using the mold linker (https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/SIGILL.20in.20build-script-build.20with.20nightly-2023-08-25/near/387506479).
2023-08-27Rollup merge of #114974 - nbdd0121:vtable, r=b-naberGuillaume Gomez-0/+1
Add an (perma-)unstable option to disable vtable vptr This flag is intended for evaluation of trait upcasting space cost for embedded use cases. Compared to the approach in #112355, this option provides a way to evaluate end-to-end cost of trait upcasting. Rationale: https://github.com/rust-lang/rust/issues/112355#issuecomment-1658207769 ## How this flag should be used (after merge) Build your project with and without `-Zno-trait-vptr` flag. If you are using cargo, set `RUSTFLAGS="-Zno-trait-vptr"` in the environment variable. You probably also want to use `-Zbuild-std` or the binary built may be broken. Save both binaries somewhere. ### Evaluate the space cost The option has a direct and indirect impact on vtable space usage. Directly, it gets rid of the trait vptr entry needed to store a pointer to a vtable of a supertrait. (IMO) this is a small saving usually. The larger saving usually comes with the indirect saving by eliminating the vtable of the supertrait (and its parent). Both impacts only affects vtables (notably the number of functions monomorphized should , however where vtable reside can depend on your relocation model. If the relocation model is static, then vtable is rodata (usually stored in Flash/ROM together with text in embedded scenario). If the binary is relocatable, however, the vtable will live in `.data` (more specifically, `.data.rel.ro`), and this will need to reside in RAM (which may be a more scarce resource in some cases), together with dynamic relocation info living in readonly segment. For evaluation, you should run `size` on both binaries, with and without the flag. `size` would output three columns, `text`, `data`, `bss` and the sum `dec` (and it's hex version). As explained above, both `text` and `data` may change. `bss` shouldn't usually change. It'll be useful to see: * Percentage change in text + data (indicating required flash/ROM size) * Percentage change in data + bss (indicating required RAM size)
2023-08-27add rustc_abi debugging attributeRalf Jung-1/+2
2023-08-27Revert "Auto merge of #106511 - MaskRay:gotpcrelx, r=nikic"Nikita Popov-1/+1
This reverts commit 441086879821d554ecdfde391e767d1a954fd5e2, reversing changes made to 249595b7523fc07a99c1adee90b1947739ca0e5b. This causes linker failures with the binutils version used by cross (#115239), as well as miscompilations when using the mold linker.
2023-08-23Default relax_elf_relocations to trueFangrui Song-1/+1
This option tells LLVM to emit relaxable relocation types R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX/R_386_GOT32X in applicable cases. True matches Clang's CMake default since 2020-08 [1] and latest LLVM default[2]. This also works around a GNU ld<2.41 issue[3] when using general-dynamic/local-dynamic TLS models in `-Z plt=no` mode with latest LLVM. [1]: https://github.com/llvm/llvm-project/commit/c41a18cf61790fc898dcda1055c3efbf442c14c0 [2]: https://github.com/llvm/llvm-project/commit/2aedfdd9b82e6c72a28576d0e8ea854f1300ff4e [3]: https://sourceware.org/bugzilla/show_bug.cgi?id=24784
2023-08-19Do not compute unneeded results.Camille GILLOT-3/+2
2023-08-18Add an (perma-)unstable option to disable vtable vptrGary Guo-0/+1
This flag is intended for evaluation of trait upcasting space cost for embedded use cases.
2023-08-14Fix review commentbjorn3-1/+1
2023-08-13Remove metadata_loader querybjorn3-4/+4
It is only used by CrateLoader. We can store the metadata loader in CStore instead which CrateLoader has access to.
2023-08-13Pass WorkProductMap to build_dep_graph instead of FxIndexMapbjorn3-9/+1
Constructing an FxIndexMap is useless work as the iteration order never matters.
2023-08-13Inline queries for crate_name, crate_types and stable_crate_idbjorn3-45/+19
All of them are not exported from rustc_interface and used only during global_ctxt(). Inlining them makes it easier to follow the order of queries and slightly reduces line count.
2023-08-11rustc: Move `features` from `Session` to `GlobalCtxt`Vadim Petrochenkov-12/+30
Removes two pieces of mutable state. Follow up to #114622.
2023-08-09rustc: Move `stable_crate_id` from `Session` to `GlobalCtxt`Vadim Petrochenkov-3/+5
Removes a piece of mutable state. Follow up to #114578.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-6/+9
Removes a piece of mutable state. Follow up to #114578.
2023-08-07rustc_interface: Dismantle `register_plugins` queryVadim Petrochenkov-110/+100
2023-08-04Make MissingDoc a module lint.Camille GILLOT-3/+1
2023-08-04Querify clashing_extern_declarations lint.Camille GILLOT-0/+3
2023-07-26replace atty crate with std's isTerminalklensy-1/+2
2023-07-26Auto merge of #113893 - mdibaiee:type-name-spill-flag, r=compiler-errorsbors-0/+1
new unstable option: -Zwrite-long-types-to-disk This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-25write-long-types-to-disk: update testsMahdi Dibaiee-1/+1
2023-07-24new unstable option: -Zwrite-long-types-to-diskMahdi Dibaiee-0/+1
This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-21Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"David Tolnay-2/+0
This reverts commit 557359f92512ca88b62a602ebda291f17a953002, reversing changes made to 1e6c09a803fd543a98bfbe1624d697a55300a786.
2023-07-21Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obkbors-0/+2
Prototype: Add unstable `-Z reference-niches` option MCP: rust-lang/compiler-team#641 Relevant RFC: rust-lang/rfcs#3204 This prototype adds a new `-Z reference-niches` option, controlling the range of valid bit-patterns for reference types (`&T` and `&mut T`), thereby enabling new enum niching opportunities. Like `-Z randomize-layout`, this setting is crate-local; as such, references to built-in types (primitives, tuples, ...) are not affected. The possible settings are (here, `MAX` denotes the all-1 bit-pattern): | `-Z reference-niches=` | Valid range | |:---:|:---:| | `null` (the default) | `1..=MAX` | | `size` | `1..=(MAX- size)` | | `align` | `align..=MAX.align_down_to(align)` | | `size,align` | `align..=(MAX-size).align_down_to(align)` | ------ This is very WIP, and I'm not sure the approach I've taken here is the best one, but stage 1 tests pass locally; I believe this is in a good enough state to unleash this upon unsuspecting 3rd-party code, and see what breaks.
2023-07-21Rollup merge of #113723 - khei4:khei4/llvm-stats, r=oli-obk,nikicMatthias Krüger-0/+1
Resurrect: rustc_llvm: Add a -Z `print-codegen-stats` option to expose LLVM statistics. This resurrects PR https://github.com/rust-lang/rust/pull/104000, which has sat idle for a while. And I want to see the effect of stack-move optimizations on LLVM (like https://reviews.llvm.org/D153453) :). I have applied the changes requested by `@oli-obk` and `@nagisa` https://github.com/rust-lang/rust/pull/104000#discussion_r1014625377 and https://github.com/rust-lang/rust/pull/104000#discussion_r1014642482 in the latest commits. r? `@oli-obk` ----- LLVM has a neat [statistics](https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option) feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too. ----- (Edit: fix broken link (Edit2: fix segmentation fault and use malloc If `rustc` is built with ```toml [llvm] assertions = true ``` Then you can see like ``` rustc +stage1 -Z print-codegen-stats -C opt-level=3 tmp.rs ===-------------------------------------------------------------------------=== ... Statistics Collected ... ===-------------------------------------------------------------------------=== 3 aa - Number of MayAlias results 193 aa - Number of MustAlias results 531 aa - Number of NoAlias results ... ``` And the current default build emits only ``` $ rustc +stage1 -Z print-codegen-stats -C opt-level=3 tmp.rs ===-------------------------------------------------------------------------=== ... Statistics Collected ... ===-------------------------------------------------------------------------=== $ ``` This might be better to emit the message to tell assertion flag necessity, but now I can't find how to do that...
2023-07-21add crate-local `-Z reference_niches` unstable flag (does nothing for now)Moulins-0/+2
2023-07-19On nightly, dump ICE backtraces to diskEsteban Küber-2/+12
Implement rust-lang/compiler-team#578. When an ICE is encountered on nightly releases, the new rustc panic handler will also write the contents of the backtrace to disk. If any `delay_span_bug`s are encountered, their backtrace is also added to the file. The platform and rustc version will also be collected.
2023-07-17print on rustc_codegen_llvm and rename malloc and cpy c_charkhei4-1/+1
2023-07-16rustc_llvm: Add a `-Z print-llvm-stats` option to expose LLVM statistics.Patrick Walton-0/+1
LLVM has a neat [statistics] feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too. [statistics]: https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option
2023-07-15Auto merge of #113606 - jyn514:parallel-compiler-cleanup, r=cjgillotbors-5/+4
Don't require each rustc_interface tool to opt-in to parallel_compiler Previously, forgetting to call `interface::set_thread_safe_mode` would cause the following ICE: ``` thread 'rustc' panicked at 'uninitialized dyn_thread_safe mode!', /rustc/dfe0683138de0959b6ab6a039b54d9347f6a6355/compiler/rustc_data_structures/src/sync.rs:74:18 ``` This calls `set_thread_safe_mode` in `interface::run_compiler` to avoid requiring it in the caller. Fixes `tests/run-make-fulldeps/issue-19371` when parallel-compiler is enabled. r? `@SparrowLii` cc https://github.com/rust-lang/rust/issues/75760