about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl
AgeCommit message (Collapse)AuthorLines
2023-10-18Auto merge of #116814 - estebank:windows-ice-path, r=petrochenkovbors-3/+8
Use `YYYY-MM-DDTHH_MM_SS` as datetime format for ICE dump files Windows paths do not support `:`, so use a datetime format in ICE dump paths that Windows will accept. CC #116809, fix #115180.
2023-10-17Use `YYYY-MM-DDTHH_MM_SS` as datetime format for ICE dump filesEsteban Küber-3/+8
Windows paths do not support `:`, so use a datetime format in ICE dump paths that Windows will accept. Fix #116809, fix #115180.
2023-10-17Rollup merge of #116827 - nnethercote:pub-handle_options, r=compiler-errorsMatthias Krüger-1/+5
Make `handle_options` public again. r? ``@compiler-errors``
2023-10-17Remove `rustc_symbol_mangling/messages.ftl`.Nicholas Nethercote-1/+0
It contains a single message that (a) doesn't contain any natural language, and (b) is only used in tests.
2023-10-17Auto merge of #116477 - nnethercote:tidy-alpha-deps, r=wesleywiserbors-26/+28
Use tidy to enforce alphabetical dependency ordering I get annoyed when dependencies in `Cargo.toml` files are not in alphabetical order. The [style guide](https://github.com/rust-lang/rust/blob/master/src/doc/style-guide/src/cargo.md) agrees with me. There are ongoing efforts to provide linting/formatting of `Cargo.toml` files, e.g. https://github.com/rust-lang/rustfmt/pull/5240, https://crates.io/crates/cargo-toml-lint, and https://github.com/TimonPost/cargo-toml-format. But it's far from clear what's the right approach. So this PR does something very simple: it uses the order checking already present in tidy. This allows incremental application of ordering, starting right now, and avoiding the need for any kind of all-at-once conversion. If we do end up using some more comprehensive `Cargo.toml` linting/formatting solution in the future, the `tidy-alphabetical` lines will be easy to remove. r? `@wesleywiser`
2023-10-17Make `handle_options` public again.Nicholas Nethercote-1/+5
2023-10-16Auto merge of #116731 - Alexendoo:hash-untracked-state, r=oli-obkbors-0/+1
Add `Config::hash_untracked_state` callback For context, I'm looking to use [late module passes](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/context/struct.LintStore.html#structfield.late_module_passes) in Clippy which unlike regular late passes run incrementally per module However we have a config file which can change between runs, we need changes to that to invalidate the `lint_mod` query. This PR adds a side channel for us to hash some extra state into `Options` in order to do that This does not make any changes to Clippy, I plan to do that in a PR to the Clippy repo along with some other required changes An alternative implementation would be to add a new query to track this state and override the `lint_mod` query in Clippy to first call that cc `@rust-lang/clippy`
2023-10-14Add `Config::hash_untracked_state` callbackAlex Macleod-0/+1
2023-10-13Format all the let chains in compilerMichael Goulet-3/+4
2023-10-13Remove unneeded `pub`s.Nicholas Nethercote-7/+7
2023-10-13Split and rename the annotation structs.Nicholas Nethercote-27/+36
`NoAnn` and `IdentifiedAnnotation` impl both `pprust_ast::PpAnn` and `pprust_hir::PpAnn`, which is a bit confusing, because the optional `tcx` is only needed for the HIR cases. (Currently the `tcx` is unnecessarily provided in the `expanded` AST cases.) This commit splits each one into `Ast` and `Hir` versions, which makes things clear about where the `tcx` is needed. The commit also renames all the traits so they consistently end with `Ann`.
2023-10-13Make `needs_analysis` true for `PpHirMode::Typed`.Nicholas Nethercote-1/+0
This avoids the need for a bespoke `tcx.analysis()` call.
2023-10-13Rename some `'hir` lifetimes as `'tcx`.Nicholas Nethercote-8/+8
Because they all end up within a `TyCtxt`.
2023-10-13Remove pretty-printing traits.Nicholas Nethercote-130/+52
`call_with_pp_support_ast` and `call_with_pp_support_hir` how each have a single call site. This commit inlines and removes them, which also removes the need for all the supporting traits: `Sess`, `AstPrinterSupport`, and `HirPrinterSupport`. The `sess` member is also removed from several structs.
2023-10-13Merge `print_*` functions.Nicholas Nethercote-70/+52
The handling of the `PpMode` variants is currently spread across three functions: `print_after_parsing`, `print_after_hir_lowering`, and `print_with_analysis`. Each one handles some of the variants. This split is primarily because `print_after_parsing` has slightly different arguments to the other two. This commit changes the structure. It merges the three functions into a single `print` function, and encapsulates the different arguments in a new enum `PrintExtra`. Benefits: - The code is a little shorter. - All the `PpMode` variants are handled in a single `match`, with no need for `unreachable!` arms. - It enables the trait removal in the subsequent commit by reducing the number of `call_with_pp_support_ast` call sites from two to one.
2023-10-13Simplify support traits.Nicholas Nethercote-70/+30
First, both `AstPrinterSupport` and `HirPrinterSupport` have a `sess` method. This commit introduces a `Sess` trait and makes the support traits be subtraits of `Sess`, to avoid some duplication. Second, both support traits have a `pp_ann` method that isn't needed if we enable `trait_upcasting`. This commit removes those methods. (Both of these traits will be removed in a subsequent commit, as will the `trait_upcasting` use.)
2023-10-13Remove unused `PrinterSupport::hir_map` method.Nicholas Nethercote-16/+0
2023-10-13Remove PpAstTreeMode.Nicholas Nethercote-3/+3
It's simpler to distinguish the two AST modes directly in `PpMode`.
2023-10-13Remove an outdated comment.Nicholas Nethercote-4/+0
`phase_3_run_analysis_passes` no longer exists, and AFAICT this code has been refactored so much since this comment was written that it no longer has any useful meaning.
2023-10-13Remove unnecessary call to `call_with_pp_support_hir`.Nicholas Nethercote-4/+2
The callback is trivial and no pp support is actually needed. This makes the `HirTree` case more like the `AstTree` case above.
2023-10-13Rename some things.Nicholas Nethercote-35/+35
- Rename `pprust` as `pprust_ast`, to align with `pprust_hir`. - Rename `PrinterSupport` as `AstPrinterSupport`, to align with `HirPrinterSupport`.
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+3
2023-10-06rustc_driver: avoid fallible conversionsTamir Duberstein-15/+18
Use `std::path::PathBuf` rather than `String`; use `std::env::var_os` rather than `std::env::var`. These changes avoid a number of error paths which can arise in the presence of non-UTF-8 paths.
2023-10-06compiler: always use var_os("RUST_BACKTRACE")Tamir Duberstein-2/+2
There are 3 instances of var(...) and 3 instances of var_os(...); the latter avoids an appearance of unhandled error, so use it everywhere.
2023-10-06Sort `rustc_driver_impl` dependencies.Nicholas Nethercote-26/+28
As per https://github.com/rust-lang/rust/blob/master/src/doc/style-guide/src/cargo.md, which says: > Sort key names alphabetically within each section, with the exception > of the [package] section. And use tidy to enforce it.
2023-09-19Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-sebors-26/+54
Don't modify libstd to dump rustc ICEs Do a much simpler thing and just dump a `std::backtrace::Backtrace` to file. r? `@estebank` `@oli-obk` Fixes #115610
2023-09-13Auto merge of #115735 - bjorn3:better_list_crate_metadata, r=wesleywiserbors-2/+4
Extend rustc -Zls This makes it show a lot more things and thus a lot more useful.
2023-09-10Show lib features in -Zls and allow configuring which things are shownbjorn3-2/+4
2023-09-10Remove EarlyErrorHandler argument from after_analysis callbackbjorn3-2/+1
It is only used by miri which can create a new one using the Session.
2023-09-10Rename after_parsing callback to after_crate_root_parsingbjorn3-3/+4
To avoid confusion if it is called after all parsing is done or not.
2023-09-08Add missing Debuginfo to PDB debug file on windows.Florian Schmiderer-0/+1
Set Arg0 and CommandLineArgs in MCTargetoptions so LLVM outputs correct CL and CMD in LF_DEBUGINFO instead of empty/invalid values.
2023-09-07Make ICE backtrace actually match the panic handlerMichael Goulet-2/+19
2023-09-07Don't modify libstd to dump rustc ICEsMichael Goulet-26/+37
2023-08-30Rollup merge of #113565 - workingjubilee:better-signal-handler-message, ↵Matthias Krüger-66/+151
r=pnkfelix Make SIGSEGV handler emit nicer backtraces This annotates the code heavily with comments to explain what is going on, for the benefit of other compiler contributors. The backtrace also emits appropriate comments to clarify, to a programmer who may not know why a bunch of file paths and hexadecimal blather was just dumped into stderr, what is going on. Finally, it detects cycles and uses their regularity to avoid repeating a bunch of text. The previous backtraces we were emitting was extremely unfriendly, potentially confusing, and often alarming, and this makes things almost "nice". We can't necessarily make them much nicer than this, because a signal handler must use "signal-safe" functions. This precludes conveniences like dynamic allocations. Fortunately, Rust's stdlib has allocation-free formatting, but it may hinder integrating this error with our localization middleware, as I wasn't able to clearly ascertain, at a glance, whether there was a zero-alloc path through it. r? `@Nilstrieb`
2023-08-29Auto merge of #114114 - ↵bors-5/+3
keith:ks/always-add-lc_build_version-for-metadata-object-files, r=wesleywiser Always add LC_BUILD_VERSION for metadata object files As of Xcode 15 Apple's linker has become a bit more strict about the warnings it produces. One of those new warnings requires all valid Mach-O object files in an archive to have a LC_BUILD_VERSION load command: ``` ld: warning: no platform load command found in 'ARCHIVE[arm64][2106](lib.rmeta)', assuming: iOS-simulator ``` This was already being done for Mac Catalyst so this change expands this logic to include it for all Apple platforms. I filed this behavior change as FB12546320 and was told it was the new intentional behavior.
2023-08-24Move extra_compiler_flags() to rustc_sessionMartin Nordholts-48/+1
To make it available to other parts of the compiler.
2023-08-21Always add LC_BUILD_VERSION for metadata object filesKeith Smiley-5/+3
As of Xcode 15 Apple's linker has become a bit more strict about the warnings it produces. One of those new warnings requires all valid Mach-O object files in an archive to have a LC_BUILD_VERSION load command: ``` ld: warning: no platform load command found in 'ARCHIVE[arm64][2106](lib.rmeta)', assuming: iOS-simulator ``` This was already being done for Mac Catalyst so this change expands this logic to include it for all Apple platforms. I filed this behavior change as FB12546320 and was told it was the new intentional behavior.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-2/+0
Removes a piece of mutable state. Follow up to #114578.
2023-08-07rustc_interface: Dismantle `register_plugins` queryVadim Petrochenkov-10/+6
2023-08-06Auto merge of #114476 - Urgau:missing-dep-file-112898, r=oli-obkbors-0/+4
Fix missing dependency file with `-Zunpretty` This PR force the `output_filenames` to be run ~~in every early exits like~~ when using `-Zunpretty`, so to respect the `dep-info` flag. Fixes https://github.com/rust-lang/rust/issues/112898 r? `@oli-obk`
2023-08-04Fix missing dependency file with -ZunprettyUrgau-0/+4
2023-07-31Replace the many arguments of `EmitterWriter::stderr` with builder methodsOli Scherer-11/+1
2023-07-25Use a builder instead of boolean/option argumentsOli Scherer-1/+1
2023-07-21Rollup merge of #113780 - dtolnay:printkindpath, r=b-naberMatthias Krüger-43/+46
Support `--print KIND=PATH` command line syntax As is already done for `--emit KIND=PATH` and `-L KIND=PATH`. In the discussion of #110785, it was pointed out that `--print KIND=PATH` is nicer than trying to apply the single global `-o` path to `--print`'s output, because in general there can be multiple print requests within a single rustc invocation, and anyway `-o` would already be used for a different meaning in the case of `link-args` and `native-static-libs`. I am interested in using `--print cfg=PATH` in Buck2. Currently Buck2 works around the lack of support for `--print KIND=PATH` by [indirecting through a Python wrapper script](https://github.com/facebook/buck2/blob/d43cf3a51a31f00be2c2248e78271b0fef0452b4/prelude/rust/tools/get_rustc_cfg.py) to redirect rustc's stdout into the location dictated by the build system. From skimming Cargo's usages of `--print`, it definitely seems like it would benefit from `--print KIND=PATH` too. Currently it is working around the lack of this by inserting `--crate-name=___ --print=crate-name` so that it can look for a line containing `___` as a delimiter between the 2 other `--print` informations it actually cares about. This is commented as a "HACK" and "abuse". https://github.com/rust-lang/cargo/blob/31eda6f7c360d9911f853b3014e057db61238f3e/src/cargo/core/compiler/build_context/target_info.rs#L242 (FYI `@weihanglo` as you dealt with this recently in https://github.com/rust-lang/cargo/pull/11633.) Mentioning reviewers active in #110785: `@fee1-dead` `@jyn514` `@bjorn3`
2023-07-20Create separate match arms for FileNames and CrateNamesDavid Tolnay-10/+14
This introduces a bit of code duplication, but we don't have the build_output_filenames in the CrateName arm and this seems a little cleaner overall.
2023-07-20Implement printing to file in codegen_backend.printDavid Tolnay-1/+1
2023-07-20Implement printing to file in print_crate_infoDavid Tolnay-17/+38
2023-07-20Move OutFileName writing into rustc_sessionDavid Tolnay-21/+1
2023-07-20Store individual output file name with every PrintRequestDavid Tolnay-8/+6
2023-07-19On nightly, dump ICE backtraces to diskEsteban Küber-14/+94
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.