about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2023-10-13Make `needs_analysis` true for `PpHirMode::Typed`.Nicholas Nethercote-1/+1
This avoids the need for a bespoke `tcx.analysis()` call.
2023-10-13Remove PpAstTreeMode.Nicholas Nethercote-14/+9
It's simpler to distinguish the two AST modes directly in `PpMode`.
2023-10-11Auto merge of #113218 - lqd:polonius-scopes, r=jackh726bors-1/+51
Compute NLL loan scopes using the polonius model For a *location-insensitive* analysis (that is, without expressiveness improvements for users yet), this PR implements loans going out of scope using reachability and liveness, rather than checking if the issuing region's values contain a given CFG point. This is equivalent to NLL scopes and computes the same data. r? `@matthewjasper` A couple of notes: - there are some assumptions about SCC representatives, placeholders, free regions, and member constraints that I believe hold, and they're documented in the code - this passes all the UI tests with `-Zpolonius=next` -- the perf is [not terrible](https://github.com/rust-lang/rust/pull/112432#issuecomment-1749685862) and there are a bunch of ways to improve it in the future. - there's a fixme left, hopefully Matthew you know a clean way to get the information it mentions.
2023-10-11Auto merge of #116014 - lqd:mcp510-2-electric-boogaloo, r=petrochenkovbors-54/+62
Implement `-Clink-self-contained=-linker` opt out This implements the `-Clink-self-contained` opt out necessary to switch to lld by changing rustc's defaults instead of cargo's. Components that are enabled and disabled on the CLI are recorded, for the purpose of being merged with the ones which the target spec will declare (I'll open another PR for that tomorrow, for easier review). For MCP510, we now check whether using the self-contained linker is disabled on the CLI. Right now it would only be sensible to with `-Zgcc-ld=lld` (and I'll add some checks that we don't both enable and disable a component on the CLI in a future PR), but the goal is to simplify adding the check of the target's enabled components here in the follow-up PRs. r? `@petrochenkov`
2023-10-10Rollup merge of #116595 - RalfJung:mir-enable-passes, r=oli-obkMatthias Krüger-3/+4
-Zmir-enable-passes: document that this may enable unsound passes also add some comments explaining why MIR opts are marked as unsound
2023-10-10-Zmir-enable-passes: document that this may enable unsound passesRalf Jung-3/+4
2023-10-09Remove cgu_reuse_tracker from Sessionbjorn3-161/+0
This removes a bit of global mutable state
2023-10-09Remove an LTO dependent cgu_reuse_tracker.set_actual_reuse callbjorn3-7/+1
2023-10-08consistency check for self-contained linking components CLI optionsRémy Rakic-0/+25
emit an error if components are both enabled and disabled on the CLI
2023-10-08implement opt out `-Clink-self-contained=-linker`Rémy Rakic-12/+30
record both enabled and disabled components so that they can be merged with the ones that the target spec will define
2023-10-08move single component parsing to dedicated functionRémy Rakic-7/+7
this will prevent parsing when expecting more than a single component to be parsed, and prepare for the symetric variant-to-name function to be added
2023-10-08move `LinkSelfContainedComponents` to `rustc_target`Rémy Rakic-35/+1
2023-10-08prepare stabilization of modern linker-flavorsRémy Rakic-3/+2
fix a few comments
2023-10-08Remove -Zdep-tasks.Camille GILLOT-3/+0
2023-10-08linker: Remove `-Zgcc-ld` optionVadim Petrochenkov-20/+3
It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now
2023-10-06Remove unused `FileName::CfgSpec`.Nicholas Nethercote-1/+0
2023-10-04extend Polonius options helpersRémy Rakic-1/+6
2023-10-04introduce `Polonius` enum for `-Zpolonius`Rémy Rakic-1/+46
this allows to opt into using the legacy version or the in-tree prototype
2023-09-23Enable drop_tracking_mir by default.Camille GILLOT-6/+0
2023-09-22Auto merge of #116001 - fmease:validate-crate-name-extern-cli-opt, r=est31bors-0/+31
[breaking change] Validate crate name in `--extern` [MCP 650] Reject non-ASCII-identifier crate names passed to the CLI option `--extern` (`rustc`, `rustdoc`). Implements [MCP 650](https://github.com/rust-lang/compiler-team/issues/650) (except that we only allow ASCII identifiers not arbitrary Rust identifiers). Fixes #113035. [As mentioned on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Disallow.20non-identifier-valid.20--extern.20cr.E2.80.A6.20compiler-team.23650/near/376826988), doing a crater run probably doesn't make sense since it wouldn't yield anything. Most users don't interact with `rustc` directly but only ever through Cargo which always passes a valid crate name to `--extern` when it invokes `rustc` and `rustdoc`. In any case, the user wouldn't be able to use such a crate name in the source code anyway. Note that I'm not using [`rustc_session::output::validate_crate_name`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/output/fn.validate_crate_name.html) (used for `--crate-name` and `#![crate_name]`) since the latter doesn't reject non-ASCII crate names and ones that start with a digit. As an aside, I've also thought about getting rid of `validate_crate_name` entirely in a separate PR (with another MCP) in favor of `is_ascii_ident` to reject more weird `--crate-name`s, `#![crate_name]`s and file names but I think that would lead to a lot of actual breakage, namely because of file names starting with a digit. In `tests/ui` 9 tests would be impacted for example. CC `@estebank` r? `@est31`
2023-09-22Allow `-Z treat-err-as-bug=0`Lieselotte-7/+14
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-09-20Validate crate name in CLI option --externLeón Orell Valerian Liehr-0/+31
2023-09-20coverage: Remove debug code from the instrumentorZalathar-5/+2
2023-09-19Rollup merge of #115869 - ferrocene:pa-fix-tests-cargo-remap, r=compiler-errorsMatthias Krüger-2/+10
Avoid blessing cargo deps's source code in ui tests Before this PR, the source code of dependencies was included in UI test error messages whenever possible. Unfortunately, "whenever possible" means in some cases the source code wouldn't be injected, resulting in a test failure. One such case is when `$CARGO_HOME` is remapped to something that is not present on disk [^1]. As the remapped path doesn't exist on disk, the source code wouldn't be showed in `tests/ui/issues/issue-21763.rs`: ```diff = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send` note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>` --> $HASHBROWN_SRC_LOCATION - | -LL | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> { - | ^^^^^^^ note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>` --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL note: required by a bound in `foo` ``` This PR fixes the problem by always hiding dependencies source code in the error messages generated during UI tests. This is implemented with a new internal flag, `-Z ignore-directory-in-diagnostics-source-blocks=$path`, which compiletest passes during UI tests. Once this is merged, remapping the Cargo home will be supported. This PR is best reviewed commit-by-commit. [^1]: After being puzzled for a bit, I discovered why this never impacted `rust-lang/rust`: we don't remap `$CARGO_HOME` :sweat_smile:. Instead, we set `$CARGO_HOME` to `/cargo` in CI, which sort-of-but-not-really achieves the same effect.
2023-09-17Auto merge of #114750 - Enselic:metadata-dep-info, r=compiler-errorsbors-18/+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-15implement -Z ignore-directory-in-diagnostics-source-blocksPietro Albini-2/+10
2023-09-13Auto merge of #115735 - bjorn3:better_list_crate_metadata, r=wesleywiserbors-3/+4
Extend rustc -Zls This makes it show a lot more things and thus a lot more useful.
2023-09-12Fix two typosbjorn3-1/+1
2023-09-11Auto merge of #115656 - cjgillot:default-relative-spans, r=davidtwcobors-9/+0
Enable incremental-relative-spans by default. This was enabled on nightly in https://github.com/rust-lang/rust/pull/84762. It has been a while, without obvious bugs. It's time to enable it by default for incremental runs.
2023-09-10Show lib features in -Zls and allow configuring which things are shownbjorn3-3/+4
2023-09-10Auto merge of #115711 - Zoxc:freeze-cstore, r=oli-obkbors-2/+2
Use `FreezeLock` for `CStore` This uses `FreezeLock` to protect the `CStore`. `FreezeReadGuard` and `FreezeWriteGuard` are changed to support a `map` operation. r? `@oli-obk`
2023-09-10Auto merge of #115713 - chenyukang:yukang-fix-115680-rustdoc-arg-check, ↵bors-5/+13
r=compiler-errors Abort if check nightly options failed on stable Fixes #115680 Also, if there are multiple unstable options passing on stable compiler, printing multiple same `note` and `help` seems noisy.
2023-09-10Abort if check nightly options failed on stableyukang-5/+13
2023-09-09Use `FreezeLock` for `CStore`John Kåre Alsaker-2/+2
2023-09-08sortAugie Fackler-2/+2
2023-09-08options: fix indentationAugie Fackler-3/+3
rustfmt didn't save me here, sigh
2023-09-08debuginfo: add compiler option to allow compressed debuginfo sectionsAugie Fackler-6/+53
LLVM already supports emitting compressed debuginfo. In debuginfo=full builds, the debug section is often a large amount of data, and it typically compresses very well (3x is not unreasonable.) We add a new knob to allow debuginfo to be compressed when the matching LLVM functionality is present. Like clang, if a known-but-disabled compression mechanism is requested, we disable compression and emit uncompressed debuginfo sections. The API is different enough on older LLVMs we just pretend the support is missing on LLVM older than 16.
2023-09-08Auto merge of #113492 - nebulark:pr_96475, r=petrochenkovbors-0/+8
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/+8
Set Arg0 and CommandLineArgs in MCTargetoptions so LLVM outputs correct CL and CMD in LF_DEBUGINFO instead of empty/invalid values.
2023-09-07Enable incremental-relative-spans by default.Camille GILLOT-9/+0
2023-09-07Auto merge of #114183 - Urgau:stabilize-print-with-path, r=oli-obkbors-6/+0
Stabilize `PATH` option for `--print KIND=PATH` This PR propose stabilizing the `PATH` option for `--print KIND=PATH`. This option was previously added in https://github.com/rust-lang/rust/pull/113780 (as insta-stable before being un-stablized in https://github.com/rust-lang/rust/pull/114139). Description of the `PATH` option: > A filepath may optionally be specified for each requested information kind, in the format `--print KIND=PATH`, just like for `--emit`. When a path is specified, information will be written there instead of to stdout. ------ Description of the original PR [\[link\]](https://github.com/rust-lang/rust/pull/113780#issue-1807080607): > **Support --print KIND=PATH command line syntax** > > As is already done for `--emit KIND=PATH` and `-L KIND=PATH`. > > In the discussion of https://github.com/rust-lang/rust/pull/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 ----- cc `@dtolnay` r? `@jackh726`
2023-09-07Stabilize `PATH` option for `--print KIND=PATH`Urgau-6/+0
Description of the `PATH` option: > A filepath may optionally be specified for each requested information > kind, in the format `--print KIND=PATH`, just like for `--emit`. When > a path is specified, information will be written there instead of to > stdout.
2023-09-03Make `.rmeta` file in `dep-info` have correct name (`lib` prefix)Martin Nordholts-18/+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/+2
2023-09-02Add `Freeze` type and use it to store `Definitions`John Kåre Alsaker-2/+2
2023-08-30Use conditional synchronization for LockJohn Kåre Alsaker-5/+5
2023-08-27Rollup merge of #114974 - nbdd0121:vtable, r=b-naberGuillaume Gomez-0/+2
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-25Auto merge of #115158 - Enselic:break-rust-args, r=compiler-errorsbors-0/+47
Include compiler flags when you `break rust;` Closes #70661 r? `@RalfJung` who requested this feature :)
2023-08-24Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonurbors-1/+1
Update bootstrap compiler to 1.73.0 beta
2023-08-24Move extra_compiler_flags() to rustc_sessionMartin Nordholts-0/+47
To make it available to other parts of the compiler.