summary refs log tree commit diff
path: root/compiler/rustc_interface/src/tests.rs
AgeCommit message (Collapse)AuthorLines
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-30/+30
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-4/+4
2023-12-18Rename `EarlyErrorHandler` as `EarlyDiagCtxt`.Nicholas Nethercote-4/+4
2023-12-14rename `-Ztrait-solver` to `-Znext-solver`lcnr-5/+7
2023-12-13Add unstable `-Zdefault-hidden-visibility` cmdline flag for `rustc`.Lukasz Anforowicz-0/+1
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/656
2023-12-081. fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before useoksbsb-0/+2
2. jobserver::initialize_checked should call before build_session, still should use EarlyErrorHandler, so revert stderr change in #118635
2023-12-06Fewer early errors.Nicholas Nethercote-4/+4
`build_session` is passed an `EarlyErrorHandler` and then constructs a `Handler`. But the `EarlyErrorHandler` is still used for some time after that. This commit changes `build_session` so it consumes the passed `EarlyErrorHandler`, and also drops it as soon as the `Handler` is built. As a result, `parse_cfg` and `parse_check_cfg` now take a `Handler` instead of an `EarlyErrorHandler`.
2023-12-05Factor out some repeated code.Nicholas Nethercote-14/+10
2023-11-30Add `-Zfunction-return={keep,thunk-extern}` optionMiguel Ojeda-4/+6
This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-15Auto merge of #116555 - paulmenage:llvm-module-flag, r=wesleywiserbors-0/+1
Add -Z llvm_module_flag Allow adding values to the `!llvm.module.flags` metadata for a generated module. The syntax is `-Z llvm_module_flag=<name>:<type>:<value>:<behavior>` Currently only u32 values are supported but the type is required to be specified for forward compatibility. The `behavior` element must match one of the named LLVM metadata behaviors.viors. This flag is expected to be perma-unstable.
2023-11-14Auto merge of #117773 - nnethercote:rm-Zperf-stats, r=wesleywiserbors-1/+0
Remove `-Zperf-stats`. The included measurements have varied over the years. At one point there were quite a few more, but #49558 deleted a lot that were no longer used. Today there's just four, and it's a motley collection that doesn't seem particularly valuable. I think it has been well and truly subsumed by self-profiling, which collects way more data. r? `@wesleywiser`
2023-11-13Remove `-Zperf-stats`.Nicholas Nethercote-1/+0
The included measurements have varied over the years. At one point there were quite a few more, but #49558 deleted a lot that were no longer used. Today there's just four, and it's a motley collection that doesn't seem particularly valuable. I think it has been well and truly subsumed by self-profiling, which collects way more data.
2023-11-11Add -Z llvm_module_flagPaul Menage-0/+1
Allow adding values to the `!llvm.module.flags` metadata for a generated module. The syntax is `-Z llvm_module_flag=<name>:<type>:<value>:<behavior>` Currently only u32 values are supported but the type is required to be specified for forward compatibility. The `behavior` element must match one of the named LLVM metadata behaviors.viors. This flag is expected to be perma-unstable.
2023-11-10Remove `-Zkeep-hygiene-data`.Nicholas Nethercote-1/+0
It was added way back in #28585 under the name `-Zkeep-mtwt-tables`. The justification was: > This is so that the resolution results can be used after analysis, > potentially for tool support. There are no uses of significance in the code base, and various Google searches for both option names (and variants) found nothing of interest. @petrochenkov says removing this part (and it's only part) of the hygiene data is dubious. It doesn't seem that big, so let's just keep it around.
2023-11-07Add -Zcross-crate-inline-threshold=yesBen Kimock-6/+6
2023-11-02Remove support for alias `-Z symbol-mangling-version`Zalathar-1/+0
2023-10-30Streamline some `use` items.Nicholas Nethercote-17/+7
2023-10-30Make `Cfg` and `CheckCfg` non-generic.Nicholas Nethercote-6/+2
They now only ever contains symbols.
2023-10-30Change cfg parsers to produce symbols instead of strings.Nicholas Nethercote-2/+2
2023-10-28Rollup merge of #117268 - nnethercote:rustc_interface, r=oli-obkJubilee-19/+10
`rustc_interface` cleanups Particularly in and around `--cfg` and `--check-cfg` handling. r? `@oli-obk`
2023-10-28Rollup merge of #116534 - cjgillot:no-dep-tasks, r=davidtwcoJubilee-1/+0
Remove -Zdep-tasks. This option is not useful any more, we can use `tracing` and `RUSTC_LOG` to debug the dep-graph.
2023-10-28Clean up config mess.Nicholas Nethercote-11/+10
`parse_cfgspecs` and `parse_check_cfg` run very early, before the main interner is running. They each use a short-lived interner and convert all interned symbols to strings in their output data structures. Once the main interner starts up, these data structures get converted into new data structures that are identical except with the strings converted to symbols. All is not obvious from the current code, which is a mess, particularly with inconsistent naming that obscures the parallel string/symbol data structures. This commit clean things up a lot. - The existing `CheckCfg` type is generic, allowing both `CheckCfg<String>` and `CheckCfg<Symbol>` forms. This is really useful, but it defaults to `String`. The commit removes the default so we have to use `CheckCfg<String>` and `CheckCfg<Symbol>` explicitly, which makes things clearer. - Introduces `Cfg`, which is generic over `String` and `Symbol`, similar to `CheckCfg`. - Renames some things. - `parse_cfgspecs` -> `parse_cfg` - `CfgSpecs` -> `Cfg<String>`, plus it's used in more places, rather than the underlying `FxHashSet` type. - `CrateConfig` -> `Cfg<Symbol>`. - `CrateCheckConfig` -> `CheckCfg<Symbol>` - Adds some comments explaining the string-to-symbol conversions. - `to_crate_check_config`, which converts `CheckCfg<String>` to `CheckCfg<Symbol>`, is inlined and removed and combined with the overly-general `CheckCfg::map_data` to produce `CheckCfg::<String>::intern`. - `build_configuration` now does the `Cfg<String>`-to-`Cfg<Symbol>` conversion, so callers don't need to, which removes the need for `to_crate_config`. The diff for two of the fields in `Config` is a good example of the improved clarity: ``` - pub crate_cfg: FxHashSet<(String, Option<String>)>, - pub crate_check_cfg: CheckCfg, + pub crate_cfg: Cfg<String>, + pub crate_check_cfg: CheckCfg<String>, ``` Compare that with the diff for the corresponding fields in `ParseSess`, and the relationship to `Config` is much clearer than before: ``` - pub config: CrateConfig, - pub check_config: CrateCheckConfig, + pub config: Cfg<Symbol>, + pub check_config: CheckCfg<Symbol>, ```
2023-10-28Streamline `rustc_interface` tests.Nicholas Nethercote-11/+3
In `test_edition_parsing`, change the `build_session_options_and_crate_config` call to `build_session_options`, because the config isn't used. That leaves a single call site for `build_session_options_and_crate_config`, so just inline and remove it.
2023-10-26Rollup merge of #117207 - Zalathar:no-option, r=compiler-errorsMatthias Krüger-1/+1
The value of `-Cinstrument-coverage=` doesn't need to be `Option` (Extracted from #117199, since this is a purely internal cleanup that can land independently.) Not using this flag is identical to passing `-Cinstrument-coverage=off`, so there's no need to distinguish between `None` and `Some(Off)`.
2023-10-26The value of `-Cinstrument-coverage=` doesn't need to be `Option`Zalathar-1/+1
Not using this flag is identical to passing `-Cinstrument-coverage=off`, so there's no need to distinguish between `None` and `Some(Off)`.
2023-10-26Auto merge of #116818 - Nilstrieb:stop-submitting-bug-reports, r=wesleywiserbors-0/+2
Stop telling people to submit bugs for internal feature ICEs This keeps track of usage of internal features, and changes the message to instead tell them that using internal features is not supported. I thought about several ways to do this but now used the explicit threading of an `Arc<AtomicBool>` through `Session`. This is not exactly incremental-safe, but this is fine, as this is set during macro expansion, which is pre-incremental, and also only affects the output of ICEs, at which point incremental correctness doesn't matter much anyways. See [MCP 620.](https://github.com/rust-lang/compiler-team/issues/596) ![image](https://github.com/rust-lang/rust/assets/48135649/be661f05-b78a-40a9-b01d-81ad2dbdb690)
2023-10-25Stop telling people to submit bugs for internal feature ICEsNilstrieb-0/+2
This keeps track of usage of internal features, and changes the message to instead tell them that using internal features is not supported. See MCP 620.
2023-10-25Remove support for alias `-Z instrument-coverage`Zalathar-1/+0
This flag was stabilized in rustc 1.60.0 as `-C instrument-coverage`, but the old unstable flag was kept around as an alias to ease migration.
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-0/+1
2023-10-08Remove -Zdep-tasks.Camille GILLOT-1/+0
2023-10-04introduce `Polonius` enum for `-Zpolonius`Rémy Rakic-1/+2
this allows to opt into using the legacy version or the in-tree prototype
2023-09-23Enable drop_tracking_mir by default.Camille GILLOT-2/+0
2023-09-10Fix testbjorn3-1/+1
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-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-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-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-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-0/+1
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-03Remove chalk from the compilerMichael Goulet-1/+1