about summary refs log tree commit diff
path: root/compiler/rustc_session/src/session.rs
AgeCommit message (Collapse)AuthorLines
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-14/+14
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-15/+35
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-20/+14
2022-01-23Remove DiagnosticBuilder.quietmark-4/+0
2021-12-05Auto merge of #91555 - matthiaskrgr:rollup-pq0iaq7, r=matthiaskrgrbors-1/+1
Rollup of 4 pull requests Successful merges: - #90529 (Skip reborrows in AbstractConstBuilder) - #91437 (Pretty print empty blocks as {}) - #91450 (Don't suggest types whose inner type is erroneous) - #91535 (Stabilize `-Z emit-future-incompat` as `--json future-incompat`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-05Rollup merge of #91535 - Aaron1011:stabilize-future-incompat, r=nagisaMatthias Krüger-1/+1
Stabilize `-Z emit-future-incompat` as `--json future-incompat` The FCP was completed in https://github.com/rust-lang/rust/issues/71249
2021-12-05Auto merge of #88611 - m-ou-se:array-into-iter-new-deprecate, r=joshtriplettbors-3/+2
Deprecate array::IntoIter::new.
2021-12-04Stabilize `-Z emit-future-incompat` as `--json future-incompat`Aaron Hill-1/+1
2021-12-04Use IntoIterator for array impl everywhere.Mara Bos-3/+2
2021-12-02Move instrument coverage config getters to `Options`Dylan MacKenzie-6/+3
2021-12-02Move `mir_opt_level` getter into `Options`Dylan MacKenzie-4/+1
2021-11-24Remove `-Z force-overflow-checks`Noah Lev-5/+1
It was replaced several years ago by the stable option `-C overflow-checks`. The goal was to delete the `-Z` flag once users had migrated [1]. Now that it's been several years, it makes sense to delete the old flag. See also the discussion on Zulip [2]. [1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097 [2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224
2021-11-22add rustc option for using LLVM stack smash protectionBenjamin A. Bjørnseth-1/+20
LLVM has built-in heuristics for adding stack canaries to functions. These heuristics can be selected with LLVM function attributes. This patch adds a rustc option `-Z stack-protector={none,basic,strong,all}` which controls the use of these attributes. This gives rustc the same stack smash protection support as clang offers through options `-fno-stack-protector`, `-fstack-protector`, `-fstack-protector-strong`, and `-fstack-protector-all`. The protection this can offer is demonstrated in test/ui/abi/stack-protector.rs. This fills a gap in the current list of rustc exploit mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html), originally discussed in #15179. Stack smash protection adds runtime overhead and is therefore still off by default, but now users have the option to trade performance for security as they see fit. An example use case is adding Rust code in an existing C/C++ code base compiled with stack smash protection. Without the ability to add stack smash protection to the Rust code, the code base artifacts could be exploitable in ways not possible if the code base remained pure C/C++. Stack smash protection support is present in LLVM for almost all the current tier 1/tier 2 targets: see test/assembly/stack-protector/stack-protector-target-support.rs. The one exception is nvptx64-nvidia-cuda. This patch follows clang's example, and adds a warning message printed if stack smash protection is used with this target (see test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3 targets has not been checked. Since the heuristics are applied at the LLVM level, the heuristics are expected to add stack smash protection to a fraction of functions comparable to C/C++. Some experiments demonstrating how Rust code is affected by the different heuristics can be found in test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is potential for better heuristics using Rust-specific safety information. For example it might be reasonable to skip stack smash protection in functions which transitively only use safe Rust code, or which uses only a subset of functions the user declares safe (such as anything under `std.*`). Such alternative heuristics could be added at a later point. LLVM also offers a "safestack" sanitizer as an alternative way to guard against stack smashing (see #26612). This could possibly also be included as a stack-protection heuristic. An alternative is to add it as a sanitizer (#39699). This is what clang does: safestack is exposed with option `-fsanitize=safe-stack`. The options are only supported by the LLVM backend, but as with other codegen options it is visible in the main codegen option help menu. The heuristic names "basic", "strong", and "all" are hopefully sufficiently generic to be usable in other backends as well. Reviewed-by: Nikita Popov <nikic@php.net> Extra commits during review: - [address-review] make the stack-protector option unstable - [address-review] reduce detail level of stack-protector option help text - [address-review] correct grammar in comment - [address-review] use compiler flag to avoid merging functions in test - [address-review] specify min LLVM version in fortanix stack-protector test Only for Fortanix test, since this target specifically requests the `--x86-experimental-lvi-inline-asm-hardening` flag. - [address-review] specify required LLVM components in stack-protector tests - move stack protector option enum closer to other similar option enums - rustc_interface/tests: sort debug option list in tracking hash test - add an explicit `none` stack-protector option Revert "set LLVM requirements for all stack protector support test revisions" This reverts commit a49b74f92a4e7d701d6f6cf63d207a8aff2e0f68.
2021-11-08Don't proceed to codegen if there are lint errorsJoshua Nelson-1/+1
2021-10-25Add LLVM CFI support to the Rust compilerRamon de C Valle-0/+13
This commit adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).
2021-10-06Enable AutoFDO.Michael Benfield-0/+10
This largely involves implementing the options debug-info-for-profiling and profile-sample-use and forwarding them on to LLVM. AutoFDO can be used on x86-64 Linux like this: rustc -O -Cdebug-info-for-profiling main.rs -o main perf record -b ./main create_llvm_prof --binary=main --out=code.prof rustc -O -Cprofile-sample-use=code.prof main.rs -o main2 Now `main2` will have feedback directed optimization applied to it. The create_llvm_prof tool can be obtained from this github repository: https://github.com/google/autofdo Fixes #64892.
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-1/+1
2021-10-01Rollup merge of #89322 - tmiasko:rm-optimization-fuel, r=michaelwoeristerManish Goregaokar-6/+1
Reapply "Remove optimization_fuel_crate from Session"
2021-09-28Reapply "Remove optimization_fuel_crate from Session"bjorn3-6/+1
2021-09-28rustc_session: Remove lint store from `Session`Vadim Petrochenkov-16/+1
2021-09-21Fix ICE with `--cap-lints=allow` and `-Zfuel=...=0`Fabian Wolff-1/+6
2021-09-17Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obkYuki Okushi-9/+21
Couple of changes to FileSearch and SearchPath * Turn a couple of regular comments into doc comments * Move `get_tools_search_paths` from `FileSearch` to `Session` * Use Lrc instead of Option to avoid duplication of a `SearchPath`
2021-09-08Use Lrc instead of Option to avoid duplication of a SearchPathbjorn3-8/+8
2021-09-08Move get_tools_search_paths from FileSearch to Sessionbjorn3-1/+13
It only uses fields of FileSearch that are stored in Session too
2021-09-08Revert "Remove optimization_fuel_crate from Session"bjorn3-1/+6
This reverts commit 5464b2e713d5366b3aec5c6eebbe1b84a782c51e.
2021-09-06Move `confused_type_with_std_module` to `ResolverOutputs`Aaron Hill-5/+0
This eliminates untracked global state from `Session`.
2021-09-02Add explanation for ctfe_backtrace lockbjorn3-0/+3
2021-09-02Remove print_fuel_crate field of Sessionbjorn3-6/+1
2021-09-02Remove optimization_fuel_crate from Sessionbjorn3-6/+1
2021-08-27Remove `Session.if_let_suggestions`Aaron Hill-4/+0
We can instead if either the LHS or RHS types contain `TyKind::Error`. In addition to covering the case where we would have previously updated `if_let_suggestions`, this might also prevent redundant errors in other cases as well.
2021-08-25Rollup merge of #88218 - Aaron1011:missing-method-dyn, r=nagisaLéo Lanteri Thauvin-4/+0
Remove `Session.trait_methods_not_found` Instead, avoid registering the problematic well-formed obligation to begin with. This removes global untracked mutable state, and avoids potential issues with incremental compilation.
2021-08-21Remove `Session.trait_methods_not_found`Aaron Hill-4/+0
Instead, avoid registering the problematic well-formed obligation to begin with. This removes global untracked mutable state, and avoids potential issues with incremental compilation.
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-33/+5
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-15Include (potentially remapped) working dir in crate hashAaron Hill-14/+1
Fixes #85019 A `SourceFile` created during compilation may have a relative path (e.g. if rustc itself is invoked with a relative path). When we write out crate metadata, we convert all relative paths to absolute paths using the current working direction. However, the working directory is not included in the crate hash. This means that the crate metadata can change while the crate hash remains the same. Among other problems, this can cause a fingerprint mismatch ICE, since incremental compilation uses the crate metadata hash to determine if a foreign query is green. This commit moves the field holding the working directory from `Session` to `Options`, including it as part of the crate hash.
2021-08-10Replace #[plugin_registrar] with exporting __rustc_plugin_registrarbjorn3-6/+0
2021-08-07Rollup merge of #87761 - rusticstuff:rustc_error_overflow, r=Mark-SimulacrumYuki Okushi-2/+1
Fix overflow in rustc happening if the `err_count()` is reduced in a stage. This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow checks. Fixes #84219. Background: I came across this independently by running `RUSTFLAGS="-C overflow-checks=on" ./x.py test`. Fixing this will allow us to move on and find further overflow errors with testing or fuzzing.
2021-08-05Remove warnings/errors from compiler when using typeck_body in rustdoc span ↵Guillaume Gomez-0/+4
map builder
2021-08-04Fix overflow in rustc happening if the `err_count()` is reduced in a stage.Hans Kratz-2/+1
This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow. Fixes #84219.
2021-07-29Remove unused field `Session.system_library_path`Aaron Hill-5/+0
2021-07-23Rename `known_attrs` to `expanded_inert_attrs` and move to rustc_expandAaron Hill-10/+0
There's no need for this to be (untracked) global state.
2021-07-20Allow combining -Cprofile-generate and -Cpanic=unwind when targetingMichael Woerister-20/+1
MSVC. The LLVM limitation that previously prevented this has been fixed in LLVM 9 which is older than the oldest LLVM version we currently support. See https://github.com/rust-lang/rust/issues/61002.
2021-07-11Simplify future incompatible reporting.Eric Huss-19/+2
2021-07-06Auto merge of #86572 - rylev:force-warnings-always, r=nikomatsakisbors-1/+11
Force warnings even when can_emit_warnings == false Fixes an issue mentioned in #85512 with --cap-lints overriding --force-warnings. Fixes https://github.com/rust-lang/rust/issues/86751 r? `@ehuss`
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-13/+13
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-07-04Combine individual limit queries into single `limits` queryAaron Hill-0/+14
2021-07-04Query-ify global limit attribute handlingAaron Hill-38/+2
2021-07-01New force_warn diagnostic builder and ensure cap-lints doesn't reduce ↵Ryan Levick-0/+10
force_warn level
2021-06-30Add support for leaf fn frame pointer eliminationSimonas Kazlauskas-12/+0
This PR adds ability for the target specifications to specify frame pointer emission type that's not just “always” or “whatever cg decides”. In particular there's a new mode that allows omission of the frame pointer for leaf functions (those that don't call any other functions). We then set this new mode for Aarch64-based Apple targets. Fixes #86196
2021-06-30Force warnings even when can_emit_warnings == falseRyan Levick-1/+1