about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-17/+17
2022-02-26Auto merge of #93516 - nagisa:branch-protection, r=cjgillotbors-2/+4
No branch protection metadata unless enabled Even if we emit metadata disabling branch protection, this metadata may conflict with other modules (e.g. during LTO) that have different branch protection metadata set. This is an unstable flag and feature, so ideally the flag not being specified should act as if the feature wasn't implemented in the first place. Additionally this PR also ensures we emit an error if `-Zbranch-protection` is set on targets other than the supported aarch64. For now the error is being output from codegen, but ideally it should be moved to earlier in the pipeline before stabilization.
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-25Auto merge of #94130 - erikdesjardins:partially, r=nikicbors-3/+3
Use undef for (some) partially-uninit constants There needs to be some limit to avoid perf regressions on large arrays with undef in each element (see comment in the code). Fixes: #84565 Original PR: #83698 Depends on LLVM 14: #93577
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-47/+51
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`
2022-02-24Rollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkovDylan DPC-23/+25
Improve `--check-cfg` implementation This pull-request is a mix of improvements regarding the `--check-cfg` implementation: - Simpler internal representation (usage of `Option` instead of separate bool) - Add --check-cfg to the unstable book (based on the RFC) - Improved diagnostics: * List possible values when the value is unexpected * Suggest if possible a name or value that is similar - Add more tests (well known names, mix of combinations, ...) r? ```@petrochenkov```
2022-02-23Continue improvements on the --check-cfg implementationLoïc BRANSTETT-11/+11
- Test the combinations of --check-cfg with partial values() and --cfg - Test that we detect unexpected value when none are expected
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-18/+38
2022-02-23rustc_errors: handle `force_warn` only through `DiagnosticId::Lint`.Eduard-Mihai Burtescu-10/+0
2022-02-23Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.Eduard-Mihai Burtescu-22/+16
2022-02-22Improve CheckCfg internal representationLoïc BRANSTETT-23/+25
2022-02-20Rollup merge of #94146 - est31:let_else, r=cjgillotMatthias Krüger-12/+7
Adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.
2022-02-19Adopt let else in more placesest31-12/+7
2022-02-19reduce default uninit_const_chunk_threshold to 16 (from 256)Erik Desjardins-2/+2
2022-02-19No branch protection metadata unless enabledSimonas Kazlauskas-2/+4
Even if we emit metadata disabling branch protection, this metadata may conflict with other modules (e.g. during LTO) that have different branch protection metadata set. This is an unstable flag and feature, so ideally the flag not being specified should act as if the feature wasn't implemented in the first place. Additionally this PR also ensures we emit an error if `-Zbranch-protection` is set on targets other than the supported aarch64. For now the error is being output from codegen, but ideally it should be moved to earlier in the pipeline before stabilization.
2022-02-19switch to limiting the number of init/uninit chunksErik Desjardins-3/+3
2022-02-18Rollup merge of #93915 - Urgau:rfc-3013, r=petrochenkovMatthias Krüger-1/+92
Implement --check-cfg option (RFC 3013), take 2 This pull-request implement RFC 3013: Checking conditional compilation at compile time (https://github.com/rust-lang/rfcs/pull/3013) and is based on the previous attempt https://github.com/rust-lang/rust/pull/89346 by `@mwkmwkmwk` that was closed due to inactivity. I have address all the review comments from the previous attempt and added some more tests. cc https://github.com/rust-lang/rust/issues/82450 r? `@petrochenkov`
2022-02-18Rollup merge of #91675 - ivanloz:memtagsan, r=nagisaMatthias Krüger-1/+2
Add MemTagSanitizer Support Add support for the LLVM [MemTagSanitizer](https://llvm.org/docs/MemTagSanitizer.html). On hardware which supports it (see caveats below), the MemTagSanitizer can catch bugs similar to AddressSanitizer and HardwareAddressSanitizer, but with lower overhead. On a tag mismatch, a SIGSEGV is signaled with code SEGV_MTESERR / SEGV_MTEAERR. # Usage `-Zsanitizer=memtag -C target-feature="+mte"` # Comments/Caveats * MemTagSanitizer is only supported on AArch64 targets with hardware support * Requires `-C target-feature="+mte"` * LLVM MemTagSanitizer currently only performs stack tagging. # TODO * Tests * Example
2022-02-18Use undef for partially-uninit constants up to 1024 bytesErik Desjardins-2/+2
There needs to be some limit to avoid perf regressions on large arrays with undef in each element (see comment in the code).
2022-02-16MemTagSanitizer SupportIvan Lozano-1/+2
Adds support for the LLVM MemTagSanitizer.
2022-02-16Implement --check-cfg option (RFC 3013)Loïc BRANSTETT-1/+92
Co-authored-by: Urgau <lolo.branstett@numericable.fr> Co-authored-by: Marcelina Kościelnicka <mwk@0x04.net>
2022-02-14Add support for control-flow protectionAndrew Brown-4/+43
This change adds a flag for configuring control-flow protection in the LLVM backend. In Clang, this flag is exposed as `-fcf-protection` with options `none|branch|return|full`. This convention is followed for `rustc`, though as a codegen option: `rustc -Z cf-protection=<none|branch|return|full>`. Co-authored-by: BlackHoleFox <blackholefoxdev@gmail.com>
2022-02-11Remove the alt_std_name optionbjorn3-6/+0
This option introduced in #15820 allows a custom crate to be imported in the place of std, but with the name std. I don't think there is any value to this. At most it is confusing users of a driver that uses this option. There are no users of this option on github. If anyone still needs it, they can emulate it injecting #![no_core] in addition to their own prelude.
2022-02-09Auto merge of #93724 - Mark-Simulacrum:drop-query-stats, r=michaelwoeristerbors-2/+0
Delete -Zquery-stats infrastructure These statistics are computable from the self-profile data and/or ad-hoc collectable as needed, and in the meantime contribute to rustc bootstrap times -- locally, this PR shaves ~2.5% from rustc_query_impl builds in instruction counts. If this does lose some functionality we want to keep, I think we should migrate it to self-profile (or a similar interface) rather than this ad-hoc reporting.
2022-02-07Add a flag enabling drop range tracking in generatorsTomasz Miąsko-0/+2
2022-02-06Delete query statsMark Rousskov-2/+0
These statistics are computable from the self-profile data and/or ad-hoc collectable as needed, and in the meantime contribute to rustc bootstrap times.
2022-02-04Rollup merge of #93608 - nnethercote:speed-up-find_library_crate, r=petrochenkovMatthias Krüger-46/+14
Clean up `find_library_crate` Some clean-ups. r? `@petrochenkov`
2022-02-04Rollup merge of #90132 - joshtriplett:stabilize-instrument-coverage, ↵Matthias Krüger-18/+51
r=wesleywiser Stabilize `-Z instrument-coverage` as `-C instrument-coverage` (Tracking issue for `instrument-coverage`: https://github.com/rust-lang/rust/issues/79121) This PR stabilizes support for instrumentation-based code coverage, previously provided via the `-Z instrument-coverage` option. (Continue supporting `-Z instrument-coverage` for compatibility for now, but show a deprecation warning for it.) Many, many people have tested this support, and there are numerous reports of it working as expected. Move the documentation from the unstable book to stable rustc documentation. Update uses and documentation to use the `-C` option. Addressing questions raised in the tracking issue: > If/when stabilized, will the compiler flag be updated to -C instrument-coverage? (If so, the -Z variant could also be supported for some time, to ease migrations for existing users and scripts.) This stabilization PR updates the option to `-C` and keeps the `-Z` variant to ease migration. > The Rust coverage implementation depends on (and automatically turns on) -Z symbol-mangling-version=v0. Will stabilizing this feature depend on stabilizing v0 symbol-mangling first? If so, what is the current status and timeline? This stabilization PR depends on https://github.com/rust-lang/rust/pull/90128 , which stabilizes `-C symbol-mangling-version=v0` (but does not change the default symbol-mangling-version). > The Rust coverage implementation implements the latest version of LLVM's Coverage Mapping Format (version 4), which forces a dependency on LLVM 11 or later. A compiler error is generated if attempting to compile with coverage, and using an older version of LLVM. Given that LLVM 13 has now been released, requiring LLVM 11 for coverage support seems like a reasonable requirement. If people don't have at least LLVM 11, nothing else breaks; they just can't use coverage support. Given that coverage support currently requires a nightly compiler and LLVM 11 or newer, allowing it on a stable compiler built with LLVM 11 or newer seems like an improvement. The [tracking issue](https://github.com/rust-lang/rust/issues/79121) and the [issue label A-code-coverage](https://github.com/rust-lang/rust/labels/A-code-coverage) link to a few open issues related to `instrument-coverage`, but none of them seem like showstoppers. All of them seem like improvements and refinements we can make after stabilization. The original `-Z instrument-coverage` support went through a compiler-team MCP at https://github.com/rust-lang/compiler-team/issues/278 . Based on that, `@pnkfelix` suggested that this needed a stabilization PR and a compiler-team FCP.
2022-02-02Make `SearchPathFile::file_name_str` non-optional.Nicholas Nethercote-13/+13
Currently, it can be `None` if the conversion from `OsString` fails, in which case all searches will skip over the `SearchPathFile`. The commit changes things so that the `SearchPathFile` just doesn't get created in the first place. Same behaviour, but slightly simpler code.
2022-02-02Inline and remove `FileSearch::search`.Nicholas Nethercote-14/+1
It has only a single callsite, and having all the code in one place will make it possible to optimize the search.
2022-02-02Remove `FileMatch`.Nicholas Nethercote-12/+2
It's returned from `FileSearch::search` but it's only used to print some debug info.
2022-02-02Remove rlib special-casing in `FileSearch::search`.Nicholas Nethercote-10/+1
This code and comment appear to be out of date. `CrateLocator::find_library_crate` is the only caller of this function and it handles rlib vs dylib overlap itself (see `CrateLocator::extract_lib`) after inspecting all the files present, so it doesn't need to see them in any particular order.
2022-02-01Add missing | between print optionsDaniel Frampton-1/+1
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-23Rollup merge of #93229 - mark-i-m:noquiet, r=eddybMatthias Krüger-4/+0
Remove DiagnosticBuilder.quiet r? `@eddyb` cc https://github.com/rust-lang/rust/issues/69426 `@GuillaumeGomez` `@Manishearth`
2022-01-23Remove DiagnosticBuilder.quietmark-4/+0
2022-01-21Gate `l4-bender` linker flavorVadim Petrochenkov-1/+11
2022-01-20Rollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pnkfelixMatthias Krüger-3/+4
Stabilize `-Z print-link-args` as `--print link-args` We have stable options for adding linker arguments; we should have a stable option to help debug linker arguments. Add documentation for the new option. In the documentation, make it clear that the *exact* format of the output is not a stable guarantee.
2022-01-18Rollup merge of #90782 - ricobbe:binutils-dlltool, r=michaelwoeristerMatthias Krüger-0/+2
Implement raw-dylib support for windows-gnu Add support for `#[link(kind = "raw-dylib")]` on windows-gnu targets. Work around binutils's linker's inability to read import libraries produced by LLVM by calling out to the binutils `dlltool` utility to create an import library from a temporary .DEF file; this approach is effectively a slightly refined version of `@mati865's` earlier attempt at this strategy in PR #88801. (In particular, this attempt at this strategy adds support for `#[link_ordinal(...)]` as well.) In support of #58713.
2022-01-12Call out to binutils' dlltool for raw-dylib on windows-gnu platforms.Richard Cobbe-0/+2
2022-01-09Stabilize -Z print-link-args as --print link-argsJosh Triplett-3/+4
We have stable options for adding linker arguments; we should have a stable option to help debug linker arguments.
2022-01-06sess/cg: re-introduce split dwarf kindDavid Wood-6/+72
In #79570, `-Z split-dwarf-kind={none,single,split}` was replaced by `-C split-debuginfo={off,packed,unpacked}`. `-C split-debuginfo`'s packed and unpacked aren't exact parallels to single and split, respectively. On Unix, `-C split-debuginfo=packed` will put debuginfo into object files and package debuginfo into a DWARF package file (`.dwp`) and `-C split-debuginfo=unpacked` will put debuginfo into dwarf object files and won't package it. In the initial implementation of Split DWARF, split mode wrote sections which did not require relocation into a DWARF object (`.dwo`) file which was ignored by the linker and then packaged those DWARF objects into DWARF packages (`.dwp`). In single mode, sections which did not require relocation were written into object files but ignored by the linker and were not packaged. However, both split and single modes could be packaged or not, the primary difference in behaviour was where the debuginfo sections that did not require link-time relocation were written (in a DWARF object or the object file). This commit re-introduces a `-Z split-dwarf-kind` flag, which can be used to pick between split and single modes when `-C split-debuginfo` is used to enable Split DWARF (either packed or unpacked). Signed-off-by: David Wood <david.wood@huawei.com>
2022-01-01Require `-Zunstable-options` for `-C instrument-coverage=except-*` optionsJosh Triplett-4/+11
These options primarily exist to work around bugs, and those bugs have largely been fixed. Avoid stabilizing them, so that we don't have to support them indefinitely.
2022-01-01Stabilize -Z instrument-coverage as -C instrument-coverageJosh Triplett-17/+43
Continue supporting -Z instrument-coverage for compatibility for now, but show a deprecation warning for it. Update uses and documentation to use the -C option. Move the documentation from the unstable book to stable rustc documentation.
2022-01-01Update references to `-Z symbol-mangling-version` to use `-C`Josh Triplett-1/+1
Replace `-Z symbol-mangling-version=v0` with `-C symbol-mangling-version=v0`. Replace `-Z symbol-mangling-version=legacy` with `-Z unstable-options -C symbol-mangling-version=legacy`.
2022-01-01Stabilize -Z symbol-mangling-version as -C symbol-mangling-versionJosh Triplett-10/+39
This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options. Continue supporting -Z symbol-mangling-version for compatibility for now, but show a deprecation warning for it.
2021-12-31Auto merge of #92175 - Aaron1011:fix-missing-source-file, r=cjgillotbors-0/+6
Import `SourceFile`s from crate before decoding foreign `Span` Fixes #92163 Fixes #92014 When writing to the incremental cache, we encode all `Span`s we encounter, regardless of whether or not their `SourceFile` comes from the local crate, or from a foreign crate. When we decode a `Span`, we use the `StableSourceFileId` we encoded to locate the matching `SourceFile` in the current session. If this id corresponds to a `SourceFile` from another crate, then we need to have already imported that `SourceFile` into our current session. This usually happens automatically during resolution / macro expansion, when we try to resolve definitions from other crates. In certain cases, however, we may try to load a `Span` from a transitive dependency without having ever imported the `SourceFile`s from that crate, leading to an ICE. This PR fixes the issue by enconding the `SourceFile`'s `CrateNum` when we encode a `Span`. During decoding, we call `imported_source_files()` when we encounter a foreign `CrateNum`, which ensure that all `SourceFile`s from that crate are imported into the current session.
2021-12-29Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisabors-3/+58
Add codegen option for branch protection and pointer authentication on AArch64 The branch-protection codegen option enables the use of hint-space pointer authentication code for AArch64 targets.
2021-12-23Import `SourceFile`s from crate before decoding foreign `Span`Aaron Hill-0/+6
Fixes #92163 Fixes #92014 When writing to the incremental cache, we encode all `Span`s we encounter, regardless of whether or not their `SourceFile` comes from the local crate, or from a foreign crate. When we decode a `Span`, we use the `StableSourceFileId` we encoded to locate the matching `SourceFile` in the current session. If this id corresponds to a `SourceFile` from another crate, then we need to have already imported that `SourceFile` into our current session. This usually happens automatically during resolution / macro expansion, when we try to resolve definitions from other crates. In certain cases, however, we may try to load a `Span` from a transitive dependency without having ever imported the `SourceFile`s from that crate, leading to an ICE. This PR fixes the issue by calling `imported_source_files()` when we encounter a `SourceFile` with a foreign `CrateNum`. This ensures that all `SourceFile`s from that crate are imported into the current session.
2021-12-19Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgrbors-1/+1
Rollup of 7 pull requests Successful merges: - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts") - #91984 (Remove `in_band_lifetimes` from `rustc_middle`) - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets) - #92042 (Enable `#[thread_local]` for all windows-msvc targets) - #92071 (Update example code for Vec::splice to change the length) - #92077 (rustdoc: Remove unused `collapsed` field) - #92081 (rustdoc: Remove unnecessary `need_backline` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup