about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/tests.rs
AgeCommit message (Collapse)AuthorLines
2024-05-29Rollup merge of #124655 - Darksonn:fixed-x18, r=lqd,estebankMatthias Krüger-0/+1
Add `-Zfixed-x18` This PR is a follow-up to #124323 that proposes a different implementation. Please read the description of that PR for motivation. See the equivalent flag in [the clang docs](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-ffixed-x18). MCP: https://github.com/rust-lang/compiler-team/issues/748 Fixes https://github.com/rust-lang/rust/issues/121970 r? rust-lang/compiler
2024-05-24remove proof tree formatter, make em shallowlcnr-4/+1
2024-05-03Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxuMichael Goulet-1/+2
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](https://github.com/rust-lang/rust/pull/120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](https://github.com/rust-lang/rust/pull/120832#issuecomment-2007394609) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-05-03Add -Zfixed-x18Alice Ryhl-0/+1
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
2024-05-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-1/+2
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern was raised related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was also raised, namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.
2024-04-29coverage: Replace boolean options with a `CoverageLevel` enumZalathar-7/+7
2024-04-25debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and ↵Vadim Petrochenkov-2/+1
`#[collapse_debuginfo]` `-Z debug-macros` is "stabilized" by enabling it by default and removing. `-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`. It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no. Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local). `#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
2024-04-23Mark @RUSTC_BUILTIN search path usage as unstableLukas Wirth-0/+1
2024-04-20Rollup merge of #123409 - ZhuUx:master, r=oli-obkMatthias Krüger-1/+1
Implement Modified Condition/Decision Coverage This is an implementation based on llvm backend support (>= 18) by `@evodius96` and branch coverage support by `@Zalathar.` ### Major changes: * Add -Zcoverage-options=mcdc as switch. Now coverage options accept either `no-branch`, `branch`, or `mcdc`. `mcdc` also enables `branch` because it is essential to work. * Add coverage mapping for MCDCBranch and MCDCDecision. Note that MCDCParameter evolves from llvm 18 to llvm 19. The mapping in rust side mainly references to 19 and is casted to 18 types in llvm wrapper. * Add wrapper for mcdc instrinc functions from llvm. And inject associated statements to mir. * Add BcbMappingKind::Decision, I'm not sure is it proper but can't find a better way temporarily. * Let coverage-dump support parsing MCDCBranch and MCDCDecision from llvm ir. * Add simple tests to check whether mcdc works. * Same as clang, currently rustc does not generate instrument for decision with more than 6 condtions or only 1 condition due to considerations of resource. ### Implementation Details 1. To get information about conditions and decisions, `MCDCState` in `BranchInfoBuilder` is used during hir lowering to mir. For expressions with logical op we call `Builder::visit_coverage_branch_operation` to record its sub conditions, generate condition ids for them and save their spans (to construct the span of whole decision). This process mainly references to the implementation in clang and is described in comments over `MCDCState::record_conditions`. Also true marks and false marks introduced by branch coverage are used to detect where the decision evaluation ends: the next id of the condition == 0. 2. Once the `MCDCState::decision_stack` popped all recorded conditions, we can ensure that the decision is checked over and push it into `decision_spans`. We do not manually insert decision span to avoid complexity from then_else_break in nested if scopes. 3. When constructing CoverageSpans, add condition info to BcbMappingKind::Branch and decision info to BcbMappingKind::Decision. If the branch mapping has non-zero condition id it will be transformed to MCDCBranch mapping and insert `CondBitmapUpdate` statements to its evaluated blocks. While decision bcb mapping will insert `TestVectorBitmapUpdate` in all its end blocks. ### Usage ```bash echo "[build]\nprofiler=true" >> config.toml ./x build --stage 1 ./x test tests/coverage/mcdc_if.rs ``` to build the compiler and run tests. ```shell export PATH=path/to/llvm-build:$PATH rustup toolchain link mcdc build/host/stage1 cargo +mcdc rustc --bin foo -- -Cinstrument-coverage -Zcoverage-options=mcdc cd target/debug LLVM_PROFILE_FILE="foo.profraw" ./foo llvm-profdata merge -sparse foo.profraw -o foo.profdata llvm-cov show ./foo -instr-profile=foo.profdata --show-mcdc ``` to check "foo" code. ### Problems to solve For now decision mapping will insert statements to its all end blocks, which may be optimized by inserting a final block of the decision. To do this we must also trace the evaluated value at each end of the decision and join them separately. This implementation is not heavily tested so there should be some unrevealed issues. We are going to check our rust products in the next. Please let me know if you had any suggestions or comments.
2024-04-19Auto merge of #117919 - daxpedda:wasm-c-abi, r=wesleywiserbors-1/+4
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: https://github.com/rust-lang/compiler-team/issues/703 Tracking issue: https://github.com/rust-lang/rust/issues/122532
2024-04-19coverage. Add coverage-options=mcdc as gate for MC/DC instrumentzhuyunxing-1/+1
2024-04-16Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkinGuillaume Gomez-50/+48
Move `SourceMap` initialization So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward. r? `@WaffleLapkin`
2024-04-16Rollup merge of #121694 - davidtwco:stabilize-relro-level, r=Mark-SimulacrumGuillaume Gomez-1/+1
sess: stabilize `-Zrelro-level` as `-Crelro-level` Stabilise `-Zrelro-level` as `-Crelro-level`. There's no tracking issue for this flag to close.
2024-04-16Move `initialize_checked_jobserver`.Nicholas Nethercote-2/+2
Currently it's a method on `EarlyDiagCtxt`, which is not the right place for it at all -- `EarlyDiagCtxt` is used to issue diagnostics, but shouldn't be doing any of the actual checking. This commit moves it into a standalone function that takes an `EarlyDiagCtxt` as an argument, which is more sensible. This does require adding `EarlyDiagCtxt::early_struct_warn`, so a warning can be returned and then modified with a note. (And that likely explains why somebody put `initialize_checked_jobserver` into `EarlyDiagCtxt` in the first place.)
2024-04-16Construct `SourceMap` at the same time as `SessionGlobals`.Nicholas Nethercote-2/+9
Currently `SourceMap` is constructed slightly later than `SessionGlobals`, and inserted. This commit changes things so they are done at the same time. Benefits: - `SessionGlobals::source_map` changes from `Lock<Option<Lrc<SourceMap>>>` to `Option<Lrc<SourceMap>>`. It's still optional, but mutability isn't required because it's initialized at construction. - `set_source_map` is removed, simplifying `run_compiler`, which is good because that's a critical function and it's nice to make it simpler. This requires moving things around a bit, so the necessary inputs are available when `SessionGlobals` is created, in particular the `loader` and `hash_kind`, which are no longer computed by `build_session`. These inputs are captured by the new `SourceMapInputs` type, which is threaded through various places.
2024-04-16Factor out common code in interface tests.Nicholas Nethercote-48/+39
Replacing `mk_session` with `sess_and_cfgs`, which does a bit more of the shared stuff -- the option parsing and the `build_configuration` call.
2024-04-06Put checks that detect UB under their own flag below debug_assertionsBen Kimock-0/+1
2024-04-03Remove MIR unsafe checkMatthew Jasper-1/+0
This also remove safety information from MIR.
2024-03-25Make sysroot mandatory for rustdocLukas Wirth-1/+1
2024-03-25Implement `-L builtin:$path`Lukas Wirth-23/+32
2024-03-21Rename some `target_cfg` variables as `target`.Nicholas Nethercote-2/+2
Because the underlying type is called `Target`. (There is also a separate type called `TargetCfg`.)
2024-03-21Remove `CodegenBackend::target_override`.Nicholas Nethercote-2/+1
Backend and target selection is a mess: the target can override the backend (via `Target::default_codegen_backend`), *and* the backend can override the target (via `CodegenBackend::target_override`). The code that handles this is ugly. It calls `build_target_config` twice, once before getting the backend and once again afterward. It also must check that both overrides aren't triggering at the same time. This commit removes the latter override. It's used in rust-gpu but @eddyb said via Zulip that removing it would be ok. This simplifies the code greatly, and will allow some nice follow-up refactorings.
2024-03-13coverage: Add `-Zcoverage-options` for fine control of coverageZalathar-5/+7
This new nightly-only flag can be used to toggle fine-grained flags that control the details of coverage instrumentation. Currently the only supported flag value is `branch` (or `no-branch`), which is a placeholder for upcoming support for branch coverage. Other flag values can be added in the future, to prototype proposed new behaviour, or to enable special non-default behaviour.
2024-03-12sess: stabilize relro-levelDavid Wood-1/+1
Signed-off-by: David Wood <david@davidtw.co>
2024-03-11Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillotJubilee-2/+9
Allow targets to override default codegen backend Implements https://github.com/rust-lang/compiler-team/issues/670.
2024-03-11Rollup merge of #116791 - WaffleLapkin:unparallel-backends, r=oli-obkJubilee-1/+1
Allow codegen backends to opt-out of parallel codegen This makes it a bit easier to write cursed codegen backends.
2024-03-10Introduce perma-unstable `wasm-c-abi` flagdaxpedda-1/+4
2024-03-06Change the documented implicit value of `-C instrument-coverage` to `=yes`Zalathar-1/+1
2024-03-01Add initial support for DataFlowSanitizerRamon de C Valle-0/+1
Adds initial support for DataFlowSanitizer to the Rust compiler. It currently supports `-Zsanitizer-dataflow-abilist`. Additional options for it can be passed to LLVM command line argument processor via LLVM arguments using `llvm-args` codegen option (e.g., `-Cllvm-args=-dfsan-combine-pointer-labels-on-load=false`).
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-1/+1
2024-02-15Use generic `NonZero` internally.Markus Reiter-2/+2
2024-02-15Rename `-Zno_parallel_llvm` -> `-Zno_parallel_backend`Maybe Waffle-1/+1
2024-02-15Refactor out a repeating pattern with `get_or_default_sysroot`Maybe Waffle-7/+2
2024-02-14Allow targets to override default codegen backendMaybe Waffle-1/+13
2024-02-07Rollup merge of #119162 - heiher:direct-access-external-data, r=petrochenkovGuillaume Boisseau-0/+1
Add unstable `-Z direct-access-external-data` cmdline flag for `rustc` The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707 Fixes #118053
2024-01-20Track `verbose` and `verbose_internals`jyn-1/+2
bjorn3 says: > On errors we don't finalize the incr comp cache, but non-fatal diagnostics are cached afaik. Otherwise we would have to replay the query in question, which we may not be able to do if the query key is not reconstructible from the dep node fingerprint. So we must track these flags to avoid replaying incorrect diagnostics.
2024-01-17Improved collapse_debuginfo attribute, added command-line flag (no|external|yes)Andrew Zhogin-4/+5
2024-01-16Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`WANG Rui-0/+1
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707
2024-01-09Rollup merge of #118680 - djkoloski:shell_argfiles, r=compiler-errorsGuillaume Gomez-0/+1
Add support for shell argfiles Closes https://github.com/rust-lang/compiler-team/issues/684
2024-01-09Remove `-Zdont-buffer-diagnostics`.Nicholas Nethercote-1/+0
It was added in #54232. It seems like it was aimed at NLL development, which is well in the past. Also, it looks like `-Ztreat-err-as-bug` can be used to achieve the same effect. So it doesn't seem necessary.
2024-01-08Add support for shell argfilesDavid Koloski-0/+1
2024-01-05Rollup merge of #119567 - nnethercote:rm-Zreport-delayed-bugs, r=oli-obkMichael Goulet-1/+0
Remove `-Zreport-delayed-bugs`. It's not used within the repository in any way (e.g. in tests), and doesn't seem useful. It was added in #52568. r? ````@oli-obk````
2024-01-05Rollup merge of #119566 - Zalathar:remove-spanview, r=Swatinem,NilstriebMichael Goulet-3/+2
Remove `-Zdump-mir-spanview` The `-Zdump-mir-spanview` flag was added back in #76074, as a development/debugging aid for the initial work on what would eventually become `-Cinstrument-coverage`. It causes the compiler to emit an HTML file containing a function's source code, with various spans highlighted based on the contents of MIR. When the suggestion was made to [triage and remove unnecessary `-Z` flags (Zulip)](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60-Z.60.20option.20triage), I noted that this flag could potentially be worth removing, but I wanted to keep it around to see whether I found it useful for my own coverage work. But when I actually tried to use it, I ran into various issues (e.g. it crashes on `tests/coverage/closure.rs`). If I can't trust it to work properly without a full overhaul, then instead of diving down a rabbit hole of trying to fix arcane span-handling bugs, it seems better to just remove this obscure old code entirely. --- ````@rustbot```` label +A-code-coverage
2024-01-05Stabilize THIR unsafeckMatthew Jasper-1/+1
2024-01-04Remove `-Zreport-delayed-bugs`.Nicholas Nethercote-1/+0
It's not used within the repository in any way (e.g. in tests), and doesn't seem useful.
2024-01-04Remove `-Zdump-mir-spanview`Zalathar-3/+2
2023-12-19rename to verbose-internalsjyn-1/+1
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