about summary refs log tree commit diff
path: root/compiler/rustc_session/src/config.rs
AgeCommit message (Collapse)AuthorLines
2024-06-23compiler: Accept -Cforce-frame-pointers=alwaysJubilee Young-1/+1
Also lands behind -Zunstable-options, for now. Take the opportunity to do some mild cleanup.
2024-06-23compiler: Support nightly -Cforce-frame-pointers=non-leafJubilee Young-1/+10
Requires -Zunstable-options as this is a -C flag already.
2024-06-23compiler(nfc): -Cforce-frame-pointers is a FramePointerJubilee Young-4/+3
2024-06-22Ensure careful consideration is given by implsAlan Egerton-1/+3
Added an associated `const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED` to the `StableOrd` trait to ensure that implementors carefully consider whether the trait's contract is upheld, as incorrect implementations can cause miscompilations.
2024-06-18Unconditionally warn on usage of `wasm32-wasi`Alex Crichton-0/+14
This commit is a continuation of the work originally proposed in rust-lang/compiler-team#607 and later amended in rust-lang/compiler-team#695. The end goal is to rename `wasm32-wasi` to `wasm32-wasip1` to reflect WASI's development and distinguish the preexisting target from the `wasm32-wasip2` target that WASI is now developing. Work for this transition began in #120468 which landed in Rust 1.78 which became stable on 2024-05-02. This implements the next phase of the transition plan to warn on usage of `wasm32-wasi`. This is intended to help alert users that a removal is pending and all release channels have the replacement available as well. This will reach stable on 2024-09-05. The next stage of the plan is to remove the `wasm32-wasi` target some time in October 2024 which means that the removal will reach stable on 2025-01-09. For reference a full schedule of this transition is listed [here]. Currently this implementation is a simple unconditional warning whenever `rustc --target wasm32-wasi` is invoked. As-implemented there's no way to turn off the warning other than to switch to the `wasm32-wasip1` target. [here]: https://github.com/rust-lang/rust/pull/120468#issuecomment-1977878747
2024-06-17coverage: Add debugging flag `-Zcoverage-options=no-mir-spans`Zalathar-1/+8
When set, this flag skips the code that normally extracts coverage spans from MIR statements and terminators. That sometimes makes it easier to debug branch coverage and MC/DC coverage, because the coverage output is less noisy. For internal debugging only. If other code changes would make it hard to keep supporting this flag, remove it.
2024-06-12Un-unsafe the `StableOrd` traitAlan Egerton-2/+2
Whilst incorrect implementations of this trait can cause miscompilation, they cannot cause memory unsafety in rustc.
2024-05-30coverage: Add CLI support for `-Zcoverage-options=condition`Dorian Péron-1/+17
2024-05-29Rollup merge of #124320 - Urgau:print-check-cfg, r=petrochenkov许杰友 Jieyou Xu (Joe)-1/+13
Add `--print=check-cfg` to get the expected configs This PR adds a new `--print` variant `check-cfg` to get the expected configs. Details and rational can be found on the MCP: https://github.com/rust-lang/compiler-team/issues/743 ``@rustbot`` label +F-check-cfg +S-waiting-on-MCP r? ``@petrochenkov``
2024-05-24remove proof tree formatter, make em shallowlcnr-10/+0
2024-05-22rustc_codegen_llvm: add support for writing summary bitcodeAugie Fackler-4/+20
Typical uses of ThinLTO don't have any use for this as a standalone file, but distributed ThinLTO uses this to make the linker phase more efficient. With clang you'd do something like `clang -flto=thin -fthin-link-bitcode=foo.indexing.o -c foo.c` and then get both foo.o (full of bitcode) and foo.indexing.o (just the summary or index part of the bitcode). That's then usable by a two-stage linking process that's more friendly to distributed build systems like bazel, which is why I'm working on this area. I talked some to @teresajohnson about naming in this area, as things seem to be a little confused between various blog posts and build systems. "bitcode index" and "bitcode summary" tend to be a little too ambiguous, and she tends to use "thin link bitcode" and "minimized bitcode" (which matches the descriptions in LLVM). Since the clang option is thin-link-bitcode, I went with that to try and not add a new spelling in the world. Per @dtolnay, you can work around the lack of this by using `lld --thinlto-index-only` to do the indexing on regular .o files of bitcode, but that is a bit wasteful on actions when we already have all the information in rustc and could just write out the matching minimized bitcode. I didn't test that at all in our infrastructure, because by the time I learned that I already had this patch largely written.
2024-05-04Make `rustc_session::config::Input` clone-ableUrgau-0/+1
2024-05-03Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxuMichael Goulet-1/+4
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-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-1/+4
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-30Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-deadMatthias Krüger-0/+2
Remove many `#[macro_use] extern crate foo` items This requires the addition of more `use` items, which often make the code more verbose. But they also make the code easier to read, because `#[macro_use]` obscures where macros are defined. r? `@fee1-dead`
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-0/+1
2024-04-29coverage: Replace boolean options with a `CoverageLevel` enumZalathar-4/+20
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-0/+1
2024-04-25Add `--print=check-cfg` to get the expected configsUrgau-1/+13
2024-04-25Rollup merge of #124333 - Urgau:better-bad-print, r=fmeaseMatthias Krüger-3/+6
Improve diagnostic for unknown `--print` request This PR improves the diagnostic when encountering a unknown `--print` request. It also moves the run-make test to a simple UI test.
2024-04-24Improve diagnostic for unknown --print requestUrgau-3/+6
2024-04-23Mark @RUSTC_BUILTIN search path usage as unstableLukas Wirth-1/+7
2024-04-20Rollup merge of #123409 - ZhuUx:master, r=oli-obkMatthias Krüger-0/+2
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/+2
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-0/+2
2024-04-16Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkinGuillaume Gomez-1/+11
Move `SourceMap` initialization So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward. r? `@WaffleLapkin`
2024-04-16Construct `SourceMap` at the same time as `SessionGlobals`.Nicholas Nethercote-1/+11
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-15Stabilize checking of cfgs at compile-time: --check-cfg optionUrgau-1/+1
2024-04-14Stabilize --json unused-externs(-silent)Jeremy Fitzhardinge-7/+0
Implement https://github.com/rust-lang/compiler-team/issues/674
2024-04-12add `-Z linker-features` to toggle lld on the CLIRémy Rakic-1/+43
but don't expose `+/-cc` yet
2024-04-05Move cfg and check-cfg configuration in it's own module and add docsUrgau-342/+6
2024-03-29Auto merge of #123194 - matthiaskrgr:rollup-vhdc8hw, r=matthiaskrgrbors-4/+6
Rollup of 4 pull requests Successful merges: - #123176 (Normalize the result of `Fields::ty_with_args`) - #123186 (copy any file from stage0/lib to stage0-sysroot/lib) - #123187 (Forward port 1.77.1 release notes) - #123188 (compiler: fix few unused_peekable and needless_pass_by_ref_mut clippy lints) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-28Introduce `FileNameMapping::to_real_filename` and use it everywhereUrgau-7/+2
2024-03-28Simplify trim-paths feature by merging all debuginfo options togetherUrgau-16/+6
2024-03-28compiler: fix few needless_pass_by_ref_mut clippy lintsklensy-2/+2
warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_session\src\config.rs:2013:16 | 2013 | early_dcx: &mut EarlyDiagCtxt, | ^^^^^^^^^^^^^^^^^^ help: consider changing to: `&EarlyDiagCtxt` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_ast_passes\src\ast_validation.rs:1555:11 | 1555 | this: &mut AstValidator<'_>, | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&AstValidator<'_>` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_infer\src\infer\snapshot\fudge.rs:16:12 | 16 | table: &mut UnificationTable<'_, 'tcx, T>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&UnificationTable<'_, 'tcx, T>` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_expand\src\expand.rs:961:13 | 961 | parser: &mut Parser<'a>, | ^^^^^^^^^^^^^^^ help: consider changing to: `&Parser<'a>` | = warning: changing this function will impact semver compatibility = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28compiler: fix some clippy needless_pass_by_ref_mutklensy-2/+4
warning: this argument is a mutable reference, but not used mutably --> compiler\rustc_session\src\config.rs:2111:20 | 2111 | unstable_opts: &mut UnstableOptions, | ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&UnstableOptions` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-25Replace implementation with @RUSTC_BUILTIN prefix substitution varLukas Wirth-0/+1
2024-03-25Make sysroot mandatory for rustdocLukas Wirth-2/+1
2024-03-25Implement `-L builtin:$path`Lukas Wirth-5/+5
2024-03-25Rollup merge of #122842 - pacak:explicit_name, r=michaelwoeristerMatthias Krüger-0/+5
Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name Fixes #122509 You can ask `rustc` to produce some intermediate results with `--emit foo`, this operation comes in two flavors: `--emit asm` and `--emit asm=foo.s`. First one produces one or more `.s` files without any name guarantees, second one renames it into `foo.s`. Second version only works when compiler produces a single file - for asm files this means using a single compilation unit for example. In case compilation produced more than a single file `rustc` runs following check to emit some warnings: ```rust if crate_output.outputs.contains_key(&output_type) { // 2) Multiple codegen units, with `--emit foo=some_name`. We have // no good solution for this case, so warn the user. sess.dcx().emit_warn(errors::IgnoringEmitPath { extension }); } else if crate_output.single_output_file.is_some() { // 3) Multiple codegen units, with `-o some_name`. We have // no good solution for this case, so warn the user. sess.dcx().emit_warn(errors::IgnoringOutput { extension }); } else { // 4) Multiple codegen units, but no explicit name. We // just leave the `foo.0.x` files in place. // (We don't have to do any work in this case.) } ``` Comment in the final `else` branch implies that if user didn't ask for a specific name - there's no need to emit warnings. However because of the internal representation of `crate_output.outputs` - this doesn't work as expected: if user asked to produce an asm file without giving it an implicit name it will contain `Some(None)`. To fix the problem new code actually checks if user gave an explicit name. I think this was an original intentional behavior, at least comments imply that.
2024-03-22Don't emit an error about failing to produce a file with a specific nameMichael Baikov-0/+5
If user never gave an explicit name
2024-03-21Remove `CodegenBackend::target_override`.Nicholas Nethercote-27/+18
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-20Reduce `pub` usage in `rustc_session`.Nicholas Nethercote-28/+26
In particular, almost none of the errors in `errors.rs` are used outside the crate.
2024-03-17some minor code simplificationsMatthias Krüger-7/+1
2024-03-14coverage: `-Zcoverage-options=branch` is no longer a placeholderZalathar-1/+1
2024-03-13coverage: Add `-Zcoverage-options` for fine control of coverageZalathar-6/+20
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-13coverage: Remove all unstable values of `-Cinstrument-coverage`Zalathar-37/+1
2024-03-11Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillotJubilee-13/+5
Allow targets to override default codegen backend Implements https://github.com/rust-lang/compiler-team/issues/670.
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-4/+4
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-10Introduce perma-unstable `wasm-c-abi` flagdaxpedda-1/+2