summary refs log tree commit diff
path: root/compiler/rustc_driver/src
AgeCommit message (Collapse)AuthorLines
2021-11-22add rustc option for using LLVM stack smash protectionBenjamin A. Bjørnseth-1/+6
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-07Made temps-dir an unstable option.Tor Hovland-7/+0
2021-11-02Added the --temps-dir option.Tor Hovland-1/+11
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-2/+1
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-1/+2
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-18Auto merge of #89124 - cjgillot:owner-info, r=michaelwoeristerbors-10/+20
Index and hash HIR as part of lowering Part of https://github.com/rust-lang/rust/pull/88186 ~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~ Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner. r? `@michaelwoerister` cc `@petrochenkov`
2021-10-15allow `potential_query_instability` everywherelcnr-1/+2
2021-10-10Fix RUSTC_LOG handlingMatthew Jasper-1/+1
Rustc was incorrectly reading the value of `RUSTC_LOG` as the environment vairable with the logging configuration, rather than the logging configuration itself.
2021-10-09Stop referring to hir::Crate in hir_pretty.Camille GILLOT-10/+20
2021-10-07Update compiler/rustc_driver/src/lib.rsEliza Weisman-1/+1
Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-10-07rustc_driver: Enable the `WARN` log level by defaultEliza Weisman-8/+11
This commit changes the `tracing_subscriber` initialization in `rustc_driver` so that the `WARN` verbosity level is enabled by default when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env variable is set, the filter string in the environment variable is honored, instead. Fixes #76824 Closes #89623 cc @eddyb, @oli-obk
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-1/+1
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-04Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, r=nagisaJubilee-2/+2
Consistently use 'supertrait'. A subset of places referred to 'super-trait', so this changes them to all use 'supertrait'. This matches 'supertype' and some other usages. An exception is 'auto-trait' which is consistently used in that manner.
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-1/+1
2021-10-02Auto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillotbors-16/+15
Fix clippy lints I'm currently working on allowing clippy to run on librustdoc after a discussion I had with `@Mark-Simulacrum.` So in the meantime, I fixed a few lints on the compiler crates.
2021-10-02Consistently use 'supertrait'.Bruce Mitchener-2/+2
A subset of places referred to 'super-trait', so this changes them to all use 'supertrait'. This matches 'supertype' and some other usages. An exception is 'auto-trait' which is consistently used in that manner.
2021-10-01Fix clippy lintsGuillaume Gomez-16/+15
2021-09-29Move body_owners to tcx.hir().Camille GILLOT-1/+1
2021-09-17Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obkYuki Okushi-4/+1
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-4/+1
2021-09-07Move the dataflow framework to its own crate.Camille GILLOT-1/+1
2021-09-02Remove print_fuel_crate field of Sessionbjorn3-2/+2
2021-08-09Reduce verbosity of RUSTC_LOGjackh726-3/+0
2021-07-30Rollup merge of #87553 - bjorn3:fix_hotplug_codegen_version, r=wesleywiserYuki Okushi-7/+1
Fix typo in rustc_driver::version This caused rustc `-Zcodegen-backend=foo.so -vV` to look for `oo.so` instead of `foo.so`
2021-07-29Use strip_prefixbjorn3-7/+1
2021-07-28Fix typo in rustc_driver::versionbjorn3-1/+1
This caused rustc -Zcodegen-backend=foo.so -vV to look for oo.so instead of foo.so
2021-07-24Support -Z unpretty=thir-tree againSmitty-3/+13
2021-07-02Auto merge of #80182 - in42:stack_trace, r=tmandrybors-0/+50
Implement printing of stack traces on LLVM segfaults and aborts Implement #79153 Based on discussion, try to extend the rust_backtrace=1 feature to handle segfault or aborts in the llvm backend
2021-07-02Use signal handler only on supported platformsTyler Mandry-37/+42
2021-07-01Auto merge of #86757 - JohnTitor:rollup-acevhz7, r=JohnTitorbors-4/+13
Rollup of 8 pull requests Successful merges: - #85504 (the foundation owns rust trademarks) - #85520 (Fix typo and improve documentation for E0632) - #86680 (Improve error for missing -Z with debugging option) - #86728 (Check node kind to avoid ICE in `check_expr_return()`) - #86740 (copy rust-lld as ld in dist) - #86746 (Fix rustdoc query type filter) - #86750 (Test cross-crate usage of `feature(const_trait_impl)`) - #86755 (alloc: `RawVec<T, A>::shrink` can be in `no_global_oom_handling`.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-07-01Rollup merge of #86680 - camsteffen:dbg-opt-error, r=petrochenkovYuki Okushi-4/+13
Improve error for missing -Z with debugging option Before: ```text ❯ rustc --unpretty=hir error: Unrecognized option: 'unpretty' ``` After: ```text ❯ rustc --unpretty=hir error: Unrecognized option: 'unpretty'. Did you mean `-Z unpretty`? ```
2021-06-30Fix AST pretty.Camille GILLOT-2/+2
2021-06-30Move AST crate.Camille GILLOT-9/+2
2021-06-30Add suggestion for missing compile flag groupCameron Steffen-4/+13
2021-06-26Use `Option::map()` instead of `if let`Fabian Wolff-10/+6
2021-06-26Fix ICE with `-Zunpretty=hir,typed` when an expression occurs in a function ↵Fabian Wolff-16/+18
signature
2021-06-25Auto merge of #85640 - bjorn3:custom_ice_hook, r=jackh726bors-8/+11
Allow changing the bug report url for the ice hook cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/1174
2021-06-22Teach rustc to accept lowercase error codesAris Merchant-2/+6
2021-06-16Small fixesTyler Mandry-11/+11
2021-06-16Implement printing of stack traces on LLVM segfaults and abortsVikram Pal-0/+45
2021-06-04Rustfmtbjorn3-1/+5
2021-06-04Support --version and -Cpasses=list for other codegen backendsbjorn3-4/+16
2021-06-04Allow printing the version of the default codegen backend if it isn't llvmbjorn3-7/+3
2021-06-04Turn a regular comment on Compilation into a doc commentbjorn3-1/+1
2021-05-24Don't invoke the default panic hook from report_icebjorn3-8/+11
2021-05-19Auto merge of #83842 - LeSeulArtichaut:thir-vec, r=nikomatsakisbors-14/+2
Store THIR in `IndexVec`s instead of an `Arena` This is a necessary step to store the THIR in a query: #85273. See [relevant discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/278509-project-thir-unsafeck/topic/THIR-dependent.20queries.20design). r? `@ghost` cc `@cjgillot` `@nikomatsakis`
2021-05-19Store THIR in `IndexVec`s instead of an `Arena`LeSeulArtichaut-14/+2
2021-05-12Use () for analysis.Camille GILLOT-5/+3
2021-05-12Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillotbors-114/+86
rustc_driver cleanup Best reviewed one commit at a time.
2021-05-03Run save_analysis even when analysis returned an errorbjorn3-2/+2