Commit Graph

1574 Commits

Author SHA1 Message Date
Daniel Paoliello
b2fd8a0192 Test fixing raw-dylib 2024-09-24 10:10:31 -07:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Matthias Krüger
fe3428d9ac
Rollup merge of #128961 - GKFX:issue-128930-explain-missing-option, r=jieyouxu
Fix #128930: Print documentation of CLI options missing their arg

Fix #128930. Failing to give an argument to CLI options which require it now prints something like:
```
$ rustc --print
error: Argument to option 'print' missing
       Usage:
           --print [crate-name|file-names|sysroot|target-libdir|cfg|check-cfg|calling-conventions|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|all-target-specs-json|native-static-libs|stack-protector-strategies|link-args|deployment-target]
                               Compiler information to print on stdout
```
2024-09-17 17:28:31 +02:00
Matthias Krüger
0daa636b93
Rollup merge of #129897 - RalfJung:soft-float-ignored, r=Urgau
deprecate -Csoft-float because it is unsound (and not fixable)

See  https://github.com/rust-lang/rust/issues/129893 for details. The general sentiment there seems to be that this flag has no use and sound alternatives exist, so let's add this warning and see if anyone out there disagrees.

Also show a different warning on targets where it does nothing (as documented since https://github.com/rust-lang/rust/pull/36261): it seems to correspond to `-mfloat-abi` in GCC/clang, which is an ARM-specific option. To be really sure it does nothing, only forward the flag to LLVM for eabihf targets. This should not change behavior but makes me sleep better ;)
2024-09-15 20:55:12 +02:00
Vetle Rasmussen
bde1f4dd57 Add set_dcx to ParseSess 2024-09-13 11:15:19 +02:00
bors
f753bc769b Auto merge of #130249 - compiler-errors:sad-new-solver-coherence, r=lcnr
Revert "Stabilize `-Znext-solver=coherence`"

This is a clean revert of #121848, prepared by running:

```
$ git revert 17b322fa69 -m1
```

Which effectively reverts:
* a138a92615, 69fdd1457d, d93e047c9f, 1a893ac648

see: https://rust-lang.zulipchat.com/#narrow/stream/364551-t-types.2Ftrait-system-refactor/topic/nalgebra.20hang

Closes #130056

r? lcnr
2024-09-12 10:17:32 +00:00
bors
1f51450c68 Auto merge of #117465 - paulmenage:small-data-limit, r=compiler-errors
Add -Z small-data-threshold

This flag allows specifying the threshold size above which LLVM should not consider placing small objects in a `.sdata` or `.sbss` section.

Support is indicated in the target options via the
small-data-threshold-support target option, which can indicate either an
LLVM argument or an LLVM module flag.  To avoid duplicate specifications
in a large number of targets, the default value for support is
DefaultForArch, which is translated to a concrete value according to the
target's architecture.
2024-09-12 04:27:08 +00:00
Jubilee
a31a8fe0cf
Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errors
Remove needless returns detected by clippy in the compiler
2024-09-11 15:53:22 -07:00
Michael Goulet
e866f8a97d Revert 'Stabilize -Znext-solver=coherence' 2024-09-11 17:57:04 -04:00
Vetle Rasmussen
9566163364 Make SearchPath::new public 2024-09-11 11:40:01 +02:00
Paul Menage
3810386bbe Add -Z small-data-threshold
This flag allows specifying the threshold size above which LLVM should
not consider placing small objects in a .sdata or .sbss section.

Support is indicated in the target options via the
small-data-threshold-support target option, which can indicate either an
LLVM argument or an LLVM module flag.  To avoid duplicate specifications
in a large number of targets, the default value for support is
DefaultForArch, which is translated to a concrete value according to the
target's architecture.
2024-09-10 12:19:16 -07:00
Eduardo Sánchez Muñoz
0b20ffcb63 Remove needless returns detected by clippy in the compiler 2024-09-09 13:32:22 +02:00
lcnr
1a893ac648 stabilize -Znext-solver=coherence 2024-09-05 07:57:16 +00:00
Ralf Jung
914d8f4bca add rustc_lint_opt_deny_field_access to options that are documented to do nothing 2024-09-03 12:22:56 +02:00
Ralf Jung
df38e644ce deprecate -Csoft-float because it is unsound (and not fixable) 2024-09-03 12:19:50 +02:00
bors
6199b69c53 Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau
Add `unreachable_pub`, round 4

A follow-up to #129732.

r? `@Urgau`
2024-09-03 01:27:20 +00:00
Nicholas Nethercote
19ff6e6e63 Add warn(unreachable_pub) to rustc_session. 2024-09-03 08:49:54 +10:00
Alexander Cyon
00de006f22
chore: Fix typos in 'compiler' (batch 2) 2024-09-02 07:50:22 +02:00
Rémy Rakic
e0bb1c7291 make -Z mir-include-spans a dedicated enum
We want to allow setting this on the CLI, override it only in MIR
passes, and disable it altogether in mir-opt tests.

The default value is "only for NLL MIR dumps", which is considered off
for all intents and purposes, except for `rustc_borrowck` when an NLL
MIR dump is requested.
2024-08-30 07:14:19 +00:00
Guillaume Gomez
d5c40d03dc
Rollup merge of #128970 - DianQK:lint-llvm-ir, r=nikic
Add `-Zlint-llvm-ir`

This flag is similar to `-Zverify-llvm-ir` and allows us to lint the generated IR.

r? compiler
2024-08-29 16:21:47 +02:00
DianQK
9589eb95d2
Add -Zlint-llvm-ir 2024-08-29 18:12:31 +08:00
Kornel
88b9edc9db
fmt-debug option
Allows disabling `fmt::Debug` derive and debug formatting.
2024-08-28 23:32:40 +01:00
Matthias Krüger
472c9645fb
Rollup merge of #129667 - dev-ardi:rustc_driver-cleanup, r=michaelwoerister
Rustc driver cleanup

This adds a few comments to the driver to clarify a bit what's happening and does some cleanup.
2024-08-28 17:12:19 +02:00
Orion Gonzalez
a007d349a1 clarify a few things 2024-08-28 13:11:02 +02:00
Trevor Gross
42cd3c60df
Rollup merge of #129418 - petrochenkov:libsearch2, r=jieyouxu
rustc: Simplify getting sysroot library directory

It was very non-obvious that `sess.target_tlib_path`, `make_target_lib_path(...)`, and `sess.target_filesearch(...).search_paths()` result in the same sysroot library directory paths.
They are however, indeed the same, because `sess.target_tlib_path` is initialized to `make_target_lib_path(...)` on `Session` creation, and they are used interchangeably.

There are still some redundant calls to `make_target_lib_path` and other inconsistent ways to obtain sysroot directories, but fixing that requires some behavior changes, while this PR is a pure refactoring.
Some places in the compiler even disagree on the number of sysroots - 1 (explicit `--sysroot` *or* default sysroot), 2 (explicit `--sysroot` *and* default sysroot), or an unclear number of `sysroot_candidates` every of which is considered.
The logic currently using `sess.target_tlib_path` or equivalents assumes one sysroot.
2024-08-27 01:46:51 -05:00
Trevor Gross
9c26ebe32e
Rollup merge of #126985 - Mrmaxmeier:dwarf-embed-source, r=davidtwco
Implement `-Z embed-source` (DWARFv5 source code embedding extension)

Implement https://github.com/rust-lang/compiler-team/issues/764 MCP which adds an unstable flag that exposes LLVM's [DWARFv5 source code embedding](https://dwarfstd.org/issues/180201.1.html) support.
2024-08-27 01:46:49 -05:00
Vadim Petrochenkov
f62b9e0179 rustc: Simplify getting sysroot library directory 2024-08-22 19:57:27 +03:00
Matthias Krüger
3075644a3d
Rollup merge of #128348 - dingxiangfei2009:allow-shadow-call-stack-sanitizer, r=tmandry
Unconditionally allow shadow call-stack sanitizer for AArch64

It is possible to do so whenever `-Z fixed-x18` is applied.

cc ``@Darksonn`` for context

The reasoning is that, as soon as reservation on `x18` is forced through the flag `fixed-x18`, on AArch64 the option to instrument with [Shadow Call Stack sanitizer](https://clang.llvm.org/docs/ShadowCallStack.html) is then applicable regardless of the target configuration.

At the every least, we would like to relax the restriction on specifically `aarch64-unknonw-none`. For this option, we can include a documentation change saying that users of compiled objects need to ensure that they are linked to runtime with Shadow Call Stack instrumentation support.

Related: #121972
2024-08-15 19:32:35 +02:00
Slanterns
aec9116757
stabilize option_get_or_insert_default 2024-08-14 18:35:58 +08:00
George Bateman
6360287fd9
Fix #128930: Print documentation of CLI options missing their arg 2024-08-11 09:10:30 +01:00
Matthias Krüger
32e0fe129d
Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors
Use more slice patterns inside the compiler

Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'.

r? ghost
2024-08-11 07:51:51 +02:00
Ding Xiang Fei
b368dcb246
unconditionally allow shadow call-stack for AArch64 whenever fixed-x18 is applied 2024-08-09 19:35:02 +08:00
Matthias Krüger
f106496b82
Rollup merge of #128806 - estebank:color-config, r=jieyouxu
Split `ColorConfig` off of `HumanReadableErrorType`

The previous setup tied two unrelated things together. Splitting these two is a better model.

Identified by https://github.com/rust-lang/rust/pull/126597/files#r1667800754
2024-08-09 00:03:36 +02:00
Esteban Küber
95c1c34fff review comments 2024-08-08 14:58:52 +00:00
Esteban Küber
ae696f847d Split ColorConfig off of HumanReadableErrorType
The previous setup tied two unrelated things together. Splitting these two is a better model.
2024-08-08 14:41:33 +00:00
Trevor Gross
ca5e8a7c4d
Rollup merge of #128702 - yaahc:metrics-flag, r=estebank
Add -Zmetrics-dir=PATH to save diagnostic metadata to disk

r? ``@estebank``
2024-08-07 20:49:03 -05:00
Jane Losare-Lusby
5212c75907 Add -Zerror-metrics=PATH to save diagnostic metadata to disk 2024-08-07 11:16:55 -07:00
Urgau
c0c57b3e29 Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
Urgau
eedb32dd12 Make Span optional in BufferedEarlyLint 2024-08-07 14:08:34 +02:00
León Orell Valerian Liehr
c4c518d2d4
Use more slice patterns inside the compiler 2024-08-07 13:37:52 +02:00
Mrmaxmeier
6899f5a8e1 -Zembed-source: Don't try to warn about incompatible codegen backends 2024-08-06 20:31:12 +02:00
Chris Denton
c6d94821f0
Don't ICE if getting the input's file_stem fails 2024-08-05 22:30:13 +00:00
Vadim Petrochenkov
35977b47cc linker: Pass fewer search directories to the linker 2024-08-03 14:20:18 +03:00
Mrmaxmeier
0b87af9d4f Add -Z embed-source=yes to embed source code in DWARF debug info 2024-07-29 12:35:36 +02:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
bors
88fa119c77 Auto merge of #127670 - compiler-errors:no-type-length-limit, r=jackh726
Gate the type length limit check behind a nightly flag

Effectively disables the type length limit by introducing a `-Zenforce-type-length-limit` which defaults to **`false`**, since making the length limit actually be enforced ended up having a worse fallout than expected. We still keep the code around, but the type length limit attr is now a noop (except for its usage in some diagnostics code?).

r? `@lcnr` -- up to you to decide what team consensus we need here since this reverses an FCP decision.

Reopens #125460 (if we decide to reopen it or keep it closed)
Effectively reverses the decision FCP'd in #125507
Closes #127346
2024-07-14 12:44:07 +00:00
Jubilee
1d59d22ac1
Rollup merge of #127434 - onur-ozkan:use-bootstrap-instead-of-rustbuild, r=Mark-Simulacrum
use "bootstrap" instead of "rustbuild" in comments and docs

Let's stick with the single name "bootstrap" to refer to the bootstrap project to avoid confusion. This should make it clearer, especially for new contributors.
2024-07-13 20:19:45 -07:00
Michael Goulet
938ed369ad Gate the type length limit check behind a nightly flag 2024-07-12 21:16:09 -04:00
Jubilee
5d56572f06
Rollup merge of #126502 - cuviper:dump-mir-exclude-alloc-bytes, r=estebank
Ignore allocation bytes in some mir-opt tests

This adds `rustc -Zdump-mir-exclude-alloc-bytes` to skip writing allocation bytes in MIR dumps, and applies it to tests that were failing on s390x due to its big-endian byte order.

Fixes #126261
2024-07-12 13:47:05 -07:00
onur-ozkan
48192701e0 use "bootstrap" instead of "rustbuild" in comments and docs
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-07-07 00:07:08 +03:00
Trevor Gross
c15a698f56 Rename the asm-comments compiler flag to verbose-asm
Since this codegen flag now only controls LLVM-generated comments rather than
all assembly comments, make the name more accurate (and also match Clang).
2024-07-02 21:42:01 -04:00
Scott McMurray
23c8ed14c9 Avoid MIR bloat in inlining
In 126578 we ended up with more binary size increases than expected.

This change attempts to avoid inlining large things into small things, to avoid that kind of increase, in cases when top-down inlining will still be able to do that inlining later.
2024-07-01 05:17:13 -07:00
Matthias Krüger
02629325f6
Rollup merge of #124741 - nebulark:patchable-function-entries-pr, r=estebank,workingjubilee
patchable-function-entry: Add unstable compiler flag and attribute

Tracking issue: #123115

Add the -Z patchable-function-entry compiler flag and the #[patchable_function_entry(prefix_nops = m, entry_nops = n)] attribute.
Rebased and adjusted the canditate implementation to match changes in the RFC.
2024-06-28 08:34:07 +02:00
Josh Stone
31851d4770 Add -Zdump-mir-exclude-alloc-bytes 2024-06-26 15:05:01 -07:00
Florian Schmiderer
7c56398e91 Updated code for changes to RFC, added additional error handling, added
tests
2024-06-25 19:00:02 +02:00
Matthew Maurer
ac7595fdb1 Support for -Z patchable-function-entry
`-Z patchable-function-entry` works like `-fpatchable-function-entry`
on clang/gcc. The arguments are total nop count and function offset.

See MCP rust-lang/compiler-team#704
2024-06-25 18:21:42 +02:00
bors
c290e9de32 Auto merge of #126326 - eggyal:ununsafe-StableOrd, r=michaelwoerister
Un-unsafe the `StableOrd` trait

Whilst incorrect implementations of this trait can cause miscompilation, they cannot cause memory unsafety in rustc.

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Policy.20of.20.60unsafe.60.20within.20the.20compiler).

cc [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), #105175, `@michaelwoerister`

r? `@Nilstrieb`
2024-06-25 15:51:35 +00:00
Michael Goulet
faa28be2f1
Rollup merge of #124712 - Enselic:deprecate-inline-threshold, r=pnkfelix
Deprecate no-op codegen option `-Cinline-threshold=...`

This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago.

Recommend using `-Cllvm-args=--inline-threshold=...` instead.

Closes #89742 which is E-help-wanted.
2024-06-24 15:51:00 -04:00
Jubilee Young
761ba5bb07 compiler: parse the empty frame-pointer 2024-06-23 02:22:55 -07:00
Jubilee Young
598e265d43 compiler: Accept -Cforce-frame-pointers=always
Also lands behind -Zunstable-options, for now.
Take the opportunity to do some mild cleanup.
2024-06-23 00:36:34 -07:00
Jubilee Young
7d160ae61a compiler: Support nightly -Cforce-frame-pointers=non-leaf
Requires -Zunstable-options as this is a -C flag already.
2024-06-23 00:36:34 -07:00
Jubilee Young
b3a1975cdc compiler(nfc): -Cforce-frame-pointers is a FramePointer 2024-06-23 00:36:33 -07:00
Alan Egerton
0e73e7095a
Ensure careful consideration is given by impls
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-22 07:17:02 +01:00
Michael Goulet
ffd72b1700 Fix remaining cases 2024-06-21 19:00:18 -04:00
Nicholas Nethercote
665821cb60 Add blank lines after module-level //! comments.
Most modules have such a blank line, but some don't. Inserting the blank
line makes it clearer that the `//!` comments are describing the entire
module, rather than the `use` declaration(s) that immediately follows.
2024-06-20 09:23:20 +10:00
Alex Crichton
e003a12ad5 Unconditionally warn on usage of wasm32-wasi
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-18 21:05:56 -07:00
bors
dd104ef163 Auto merge of #126623 - oli-obk:do_not_count_errors, r=davidtwco
Replace all `&DiagCtxt` with a `DiagCtxtHandle<'_>` wrapper type

r? `@davidtwco`

This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle

Basically I will add a field to the `DiagCtxtHandle` that refers back to the `InferCtxt`'s (and others) `Option<ErrorHandled>`, allowing us to immediately taint these contexts when emitting an error and not needing manual tainting anymore (which is easy to forget and we don't do in general anyway)
2024-06-18 16:49:19 +00:00
Oli Scherer
3f34196839 Remove redundant argument from subdiagnostic method 2024-06-18 15:42:11 +00:00
Oli Scherer
7ba82d61eb Use a dedicated type instead of a reference for the diagnostic context
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18 15:42:11 +00:00
Oli Scherer
c91edc3888 Prefer dcx methods over fields or fields' methods 2024-06-18 13:45:08 +00:00
Zalathar
abc2c702af coverage: Add debugging flag -Zcoverage-options=no-mir-spans
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-17 21:16:15 +10:00
Martin Nordholts
f5f067bf9d Deprecate no-op codegen option -Cinline-threshold=...
This deprecates `-Cinline-threshold` since using it has no effect. This
has been the case since the new LLVM pass manager started being used,
more than 2 years ago.
2024-06-14 20:25:17 +02:00
Alan Egerton
114dd2061e
Un-unsafe the StableOrd trait
Whilst incorrect implementations of this trait can cause miscompilation,
they cannot cause memory unsafety in rustc.
2024-06-12 13:01:22 +01:00
Nicholas Nethercote
75b164d836 Use tidy to sort crate attributes for all compiler crates.
We already do this for a number of crates, e.g. `rustc_middle`,
`rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`.

For the ones we don't, in many cases the attributes are a mess.
- There is no consistency about order of attribute kinds (e.g.
  `allow`/`deny`/`feature`).
- Within attribute kind groups (e.g. the `feature` attributes),
  sometimes the order is alphabetical, and sometimes there is no
  particular order.
- Sometimes the attributes of a particular kind aren't even grouped
  all together, e.g. there might be a `feature`, then an `allow`, then
  another `feature`.

This commit extends the existing sorting to all compiler crates,
increasing consistency. If any new attribute line is added there is now
only one place it can go -- no need for arbitrary decisions.

Exceptions:
- `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`,
  because they have no crate attributes.
- `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's
  ignored in `rustfmt.toml`).
2024-06-12 15:49:10 +10:00
Nilstrieb
b4c439c3de Improve naming and path operations in crate loader
Simplify the path operation with `join`, clarify some of the names.
2024-06-06 21:53:29 +02:00
Dorian Péron
fa563c1384 coverage: Add CLI support for -Zcoverage-options=condition 2024-05-30 15:38:46 +10:00
Matthias Krüger
d0311c1303
Rollup merge of #124655 - Darksonn:fixed-x18, r=lqd,estebank
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-29 20:12:32 +02:00
许杰友 Jieyou Xu (Joe)
7e441a11a1
Rollup merge of #124320 - Urgau:print-check-cfg, r=petrochenkov
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-29 03:25:07 +01:00
Alice Ryhl
40f0172c6a Add -Zfixed-x18
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
2024-05-03 14:32:08 +02:00
Matthias Krüger
784316eadc
Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-dead
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-30 15:04:08 +02:00
Nicholas Nethercote
6341935a13 Remove extern crate tracing from numerous crates. 2024-04-30 16:47:49 +10:00
Zalathar
f9263374fb coverage: Replace boolean options with a CoverageLevel enum 2024-04-29 20:04:22 +10:00
Nicholas Nethercote
4814fd0a4b Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
Vadim Petrochenkov
98804c1786 debuginfo: Stabilize -Z debug-macros, -Z collapse-macro-debuginfo and #[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-25 22:14:47 +03:00
Urgau
ac59bdc20c Add --print=check-cfg to get the expected configs 2024-04-25 07:58:31 +02:00
Matthias Krüger
fc6070cd8e
Rollup merge of #124324 - nnethercote:minor-ast-cleanups, r=estebank
Minor AST cleanups

r? ``@estebank``
2024-04-25 06:31:04 +02:00
Matthias Krüger
f46b828b55
Rollup merge of #124333 - Urgau:better-bad-print, r=fmease
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-25 00:19:55 +02:00
Urgau
153b1f0421 Improve diagnostic for unknown --print request 2024-04-24 15:52:01 +02:00
Nicholas Nethercote
78e7c7b9f9 Whitespace fixes. 2024-04-24 16:28:49 +10:00
bors
244da22fab Auto merge of #123126 - oli-obk:feed_crate_num, r=davidtwco
Enable `CrateNum` query feeding via `TyCtxt`

Instead of having a magic function that violates some `TyCtxtFeed` invariants, add a `create_def` equivalent for `CrateNum`s.

Note that this still isn't tracked by the query system (unlike `create_def`), and that feeding most `CrateNum` queries for crates other than the local one will likely cause performance regressions.

These things should be attempted on their own separately, but this PR should stand on its own
2024-04-23 20:46:48 +00:00
Lukas Wirth
481515500a Mark @RUSTC_BUILTIN search path usage as unstable 2024-04-23 11:01:47 +02:00
Markus Reiter
33e68aadc9
Stabilize generic NonZero. 2024-04-22 18:48:47 +02:00
Matthias Krüger
efb264fa78
Rollup merge of #123409 - ZhuUx:master, r=oli-obk
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-20 11:10:31 +02:00
Oli Scherer
fbc9b94064 Move stable_crate_ids from CrateStore to Untracked
This way it's like `Definitions`, which creates `DefId`s by interning `DefPathData`s, but for interning stable crate hashes
2024-04-19 14:16:18 +00:00
bors
13e63f7490 Auto merge of #117919 - daxpedda:wasm-c-abi, r=wesleywiser
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-19 03:35:10 +00:00
zhuyunxing
68f86381ee coverage. Add coverage-options=mcdc as gate for MC/DC instrument 2024-04-19 10:43:53 +08:00
Scott McMurray
90b4c86335 Ensure [rust] debuginfo-level-std doesn't change core's MIR 2024-04-18 09:35:36 -07:00
Guillaume Gomez
14496d561e
Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkin
Move `SourceMap` initialization

So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward.

r? `@WaffleLapkin`
2024-04-16 21:41:23 +02:00
Matthias Krüger
f54219c473
Rollup merge of #123501 - Urgau:stabilize-check-cfg, r=petrochenkov
Stabilize checking of cfgs at compile-time: `--check-cfg` option

This PR stabilize the `--check-cfg` CLI option of `rustc` (and `rustdoc`) 🎉.

In particular this PR does two things:
  1. it makes the `--check-cfg` option stable
  2. and it moves the documentation to the stable books

FCP: https://github.com/rust-lang/rust/issues/82450#issuecomment-1965328542

Resolves #82450

``@rustbot`` labels +S-blocked +F-check-cfg
r? ``@petrochenkov``
2024-04-16 17:54:41 +02:00
Guillaume Gomez
26b6a234a1
Rollup merge of #121694 - davidtwco:stabilize-relro-level, r=Mark-Simulacrum
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-16 15:19:10 +02:00