about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
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.
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-22unknown unstable lint command linemojave2-5/+18
fix ##113702 fix #113702 unknown unstable lint command lint improve impelementation
2023-08-18Add the relocation_model to the cfgLuca Barbato-1/+11
This way is possible to write inline assembly code aware of it.
2023-08-18Add an (perma-)unstable option to disable vtable vptrGary Guo-0/+2
This flag is intended for evaluation of trait upcasting space cost for embedded use cases.
2023-08-13Remove reached_eof from ParseSessbjorn3-4/+1
It was only ever set in a function which isn't called anywhere.
2023-08-11rustc: Move `features` from `Session` to `GlobalCtxt`Vadim Petrochenkov-19/+1
Removes two pieces of mutable state. Follow up to #114622.
2023-08-09rustc: Move `stable_crate_id` from `Session` to `GlobalCtxt`Vadim Petrochenkov-12/+0
Removes a piece of mutable state. Follow up to #114578.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-42/+0
Removes a piece of mutable state. Follow up to #114578.
2023-08-08Rollup merge of #113593 - rcvalle:rust-cfi-fix-90546, r=wesleywiserMatthias Krüger-3/+13
CFI: Fix error compiling core with LLVM CFI enabled Fix #90546 by filtering out global value function pointer types from the type tests, and adding the LowerTypeTests pass to the rustc LTO optimization pipelines.
2023-08-07CFI: Fix error compiling core with LLVM CFI enabledRamon de C Valle-3/+13
Fix #90546 by filtering out global value function pointer types from the type tests, and adding the LowerTypeTests pass to the rustc LTO optimization pipelines.
2023-08-04Auto merge of #114104 - oli-obk:syn2, r=compiler-errorsbors-24/+10
Lots of tiny incremental simplifications of `EmitterWriter` internals ignore the first commit, it's https://github.com/rust-lang/rust/pull/114088 squashed and rebased, but it's needed to use to use `derive_setters`, as they need a newer `syn` version. Then this PR starts out with removing many arguments that are almost always defaulted to `None` or `false` and replace them with builder methods that can set these fields in the few cases that want to set them. After that it's one commit after the other that removes or merges things until everything becomes some very simple trait objects
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-07-31Replace the many arguments of `EmitterWriter::stderr` with builder methodsOli Scherer-24/+10
2023-07-31Fix a comment.Nicholas Nethercote-0/+1
Make it match the corresponding comment at the start of the unstable options.
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-7/+4