Commit Graph

249267 Commits

Author SHA1 Message Date
bors
5a6c1aa2bc Auto merge of #121421 - saethlin:smarter-mono, r=oli-obk
Avoid lowering code under dead SwitchInt targets

The objective of this PR is to detect and eliminate code which is guarded by an `if false`, even if that `false` is a constant which is not known until monomorphization, or is `intrinsics::debug_assertions()`.

The effect of this is that we generate no LLVM IR the standard library's unsafe preconditions, when they are compiled in a build where they should be immediately optimized out. This mono-time optimization ensures that builds which disable debug assertions do not grow a linkage requirement against `core`, which compiler-builtins currently needs: https://github.com/rust-lang/rust/issues/121552

This revives the codegen side of https://github.com/rust-lang/rust/pull/91222 as planned in https://github.com/rust-lang/rust/issues/120848.
2024-03-13 05:07:26 +00:00
bors
d3555f3d8e Auto merge of #122227 - Zoxc:query-hash-verify, r=michaelwoerister
Verify that query keys result in unique dep nodes

This implements checking that query keys result into unique dep nodes as mentioned in https://github.com/rust-lang/rust/pull/112469.

We could do a perf check to see how expensive this is.

r? `@michaelwoerister`
2024-03-13 02:01:56 +00:00
bors
e61dcc7a0a Auto merge of #122220 - saethlin:ppc-can-into-atomicptr, r=oli-obk
Only generate a ptrtoint in AtomicPtr codegen when absolutely necessary

This special case was added in this PR: https://github.com/rust-lang/rust/pull/77611 in response to this error message:
```
Intrinsic has incorrect argument type!
void ({}*)* `@llvm.ppc.cfence.p0sl_s`
in function rust_oom
LLVM ERROR: Broken function found, compilation aborted!
[RUSTC-TIMING] std test:false 20.161
error: could not compile `std`
```
But when I tried searching for more information about that intrinsic I found this: https://github.com/llvm/llvm-project/issues/55983 which is a report of someone hitting this same error and a fix was landed in LLVM, 2 years after the above Rust PR.
2024-03-13 00:03:50 +00:00
Ben Kimock
81d630453b Avoid lowering code under dead SwitchInt targets 2024-03-12 19:01:04 -04:00
bors
a165f1f650 Auto merge of #122394 - weihanglo:update-cargo, r=weihanglo
Update cargo

9 commits in a4c63fe5388beaa09e5f91196c86addab0a03580..7065f0ef4aa267a7455e1c478b5ccacb7baea59c
2024-03-06 22:15:17 +0000 to 2024-03-12 13:25:15 +0000
- chore: remove repetitive word (rust-lang/cargo#13575)
- refactor(lockfile): Make diffing/printing more reusable (rust-lang/cargo#13564)
- test: Add tests for using worktrees and sparse checkouts (rust-lang/cargo#13567)
- util/network/http: Use `cargo/1.2.3` user-agent header (rust-lang/cargo#13548)
- fix: Consistently compare MSRVs (rust-lang/cargo#13537)
- refactor(shell): Use alternate to close links (rust-lang/cargo#13562)
- fix(doc): Collapse down Generated statuses without --verbose (rust-lang/cargo#13557)
- doc: Add doc for -Zpublic-dependency (rust-lang/cargo#13556)
- docs: add link to the exported_private_dependencies lint (rust-lang/cargo#13547)

r? ghost
2024-03-12 19:01:58 +00:00
Weihang Lo
e322fef0c2
Update cargo 2024-03-12 13:19:25 -04:00
bors
6b1e5d9db3 Auto merge of #122389 - workingjubilee:rollup-vbdniap, r=workingjubilee
Rollup of 12 pull requests

Successful merges:

 - #121754 ([bootstrap] Move the `split-debuginfo` setting to the per-target section)
 - #121953 (Add tests for the generated assembly of mask related simd instructions.)
 - #122081 (validate `builder::PATH_REMAP`)
 - #122245 (Detect truncated DepGraph files)
 - #122354 (bootstrap: Don't eagerly format verbose messages)
 - #122355 (rustdoc: fix up old test)
 - #122363 (tests: Add ui/attributes/unix_sigpipe/unix_sigpipe-str-list.rs)
 - #122366 (Fix stack overflow with recursive associated types)
 - #122377 (Fix discriminant_kind copy paste from the pointee trait case)
 - #122378 (Properly rebuild rustbooks)
 - #122380 (Fix typo in lib.rs of proc_macro)
 - #122381 (llvm-wrapper: adapt for LLVM API changes)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-12 16:31:43 +00:00
Jubilee
3e9c1d7253
Rollup merge of #122381 - krasimirgg:llvm-19-mar, r=durin42
llvm-wrapper: adapt for LLVM API changes

Adapts rust for 9997e03971.

`@rustbot` label: +llvm-main
r? `@durin42`
2024-03-12 09:04:04 -07:00
Jubilee
8efdef6900
Rollup merge of #122380 - Isotope-235:fork, r=petrochenkov
Fix typo in lib.rs of proc_macro

I believe I discovered a typo in the documentation of TokenStream while writing a procedural macro.
2024-03-12 09:04:04 -07:00
Jubilee
cf3d178e2d
Rollup merge of #122378 - clubby789:rustbook-rebuild, r=onur-ozkan
Properly rebuild rustbooks

Fixes #122367

If the book was out of date but the tool was up to date, this would evaluate to `!(false || true)` == `!true` == `false` and not rebuild.
2024-03-12 09:04:03 -07:00
Jubilee
bca8c62776
Rollup merge of #122377 - zetanumbers:discriminant_kind_copypaste_fix, r=oli-obk
Fix discriminant_kind copy paste from the pointee trait case

r? `@oli-obk`
2024-03-12 09:04:03 -07:00
Jubilee
0b31375248
Rollup merge of #122366 - oli-obk:opaques_defined_by_overflow, r=lcnr
Fix stack overflow with recursive associated types

fixes #122364
2024-03-12 09:04:02 -07:00
Jubilee
778c76c6a7
Rollup merge of #122363 - Enselic:unix_sigpipe-str-list, r=oli-obk
tests: Add ui/attributes/unix_sigpipe/unix_sigpipe-str-list.rs

Which is a variant of [`unix_sigpipe-list.rs`][1] but where a string is used instead of an identifier. This makes it more similar to the proper form `#[unix_sigpipe = "sig_dfl"]` and thus more likely to be written by users by mistake. Having a test for this case gives peace of mind.

Also rename the first test to be more in line with the terminology of [The Reference][2].

[1]: https://github.com/rust-lang/rust/blob/master/tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs
[2]: https://doc.rust-lang.org/reference/attributes.html#meta-item-attribute-syntax

Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-03-12 09:04:02 -07:00
Jubilee
1aef2fb259
Rollup merge of #122355 - fmease:rustdoc-fix-up-old-test, r=notriddle
rustdoc: fix up old test

`tests/rustdoc/line-breaks.rs` had several issues:

1. It used `//`@count`` instead of `// `@count`` (notice the space!) which gets treated as a `ui_test` directive instead of a `htmldocck` one. `compiletest` didn't flag it as an error because it's allowlisted ([#121561](https://github.com/rust-lang/rust/pull/121561)) presumably precisely because of this test. And before the compiletest→ui_test migration, these directives must've been ignored, too, because …
2. … the checks themselves no longer work either: The count of `<br>`s is actually 0 in all 3 cases because – well – we no longer generate any `<br>`s inside `<pre>`s.

Since I don't know how to ``@count`` `\n`s instead of `<br>`s, I've turned them into ``@matches`.` Btw, I don't know if this test is still desirable or if we have other tests that cover this (I haven't checked).

r? rustdoc
2024-03-12 09:04:01 -07:00
Jubilee
7b5c63b69a
Rollup merge of #122354 - clubby789:bootstrap-eager-verbose, r=albertlarsan68
bootstrap: Don't eagerly format verbose messages

We `format!` a lot of messages which are only used when we are at some level of verbosity - do this lazily instead
2024-03-12 09:04:01 -07:00
Jubilee
f54350a9ba
Rollup merge of #122245 - saethlin:check-dep-graph-size, r=petrochenkov
Detect truncated DepGraph files

I suspect that the following issues are caused by truncated incr comp files:

* https://github.com/rust-lang/rust/issues/120582
* https://github.com/rust-lang/rust/issues/121499
* https://github.com/rust-lang/rust/issues/122210

We fail with an allocation failure or capacity overflow in this case because we assume that the ending bytes of an DepGraph file are the lengths of arrays. If the file has somehow been truncated then the ending bytes are probably some of our varint encoding, which tries to eliminate zero bytes, so interpreting a random 8 bytes as an array length has a very high chance of producing a byte capacity over `isize::MAX`.

Now theoretically since https://github.com/rust-lang/rust/pull/119510 merged I have fixed the out-of-disk issues and yet in https://github.com/rust-lang/rust/issues/120894#issuecomment-1945126700 I still see some decoding failures that look like out-of-disk ICEs, for example https://crater-reports.s3.amazonaws.com/beta-1.77-1/beta-2024-02-10/gh/scottfones.aoc_2022/log.txt

So this PR should ensure that we get an ICE that clearly identifies if the file in question is truncated.
2024-03-12 09:04:00 -07:00
Jubilee
45cc461bfd
Rollup merge of #122081 - onur-ozkan:validate-path-remaps, r=clubby789
validate `builder::PATH_REMAP`

self-explanatory

r? clubby789
2024-03-12 09:04:00 -07:00
Jubilee
947d960243
Rollup merge of #121953 - jhorstmann:assembly-tests-for-masked-simd-instructions, r=workingjubilee
Add tests for the generated assembly of mask related simd instructions.

The tests show that the code generation currently uses the least significant bits of <iX x N> vector masks when converting to <i1 xN>. This leads to an additional left shift operation in the assembly for x86, since mask operations on x86 operate based on the most significant bit.

The exception is simd_bitmask, which already uses the most-significant bit.

This additional instruction would be removed by the changes in #104693, which makes all mask operations consistently use the most significant bits.

By using the "C" calling convention the tests should be stable regarding changes in register allocation, but it is possible that future llvm updates will require updating some of the checks.
2024-03-12 09:03:59 -07:00
Jubilee
7a45c72f24
Rollup merge of #121754 - TimNN:split-target, r=Mark-Simulacrum,onur-ozkan
[bootstrap] Move the `split-debuginfo` setting to the per-target section

As described in #112406, bootstrap currently applies the global `split-debuginfo` setting to all artifacts, irrespective of their target triple.

This doesn't cause problems when the "build" triple defaults `split-debuginfo` to `off` (as is the case on Linux, for example).

However, when the "build" triple has `split-debuginfo` enabled and additional target triples are configured, then artifacts for the additional triples will also be built with `split-debuginfo` (despite not necessarily supporting `split-debuginfo`).

#112406 mentions `riscv32imc-unknown-none-elf` as one target where this happens, and I've run into this with Wasm as well.

This PR does **not** implement `@ehuss's` suggestion that "bootstrap not try to guess how to configure split-debuginfo, and instead use cargo profiles to set it", because that seemed like a lot more significant change.

---

After this PR, anyone explicitly setting `rust.split-debuginfo` should update their configuration to specify the setting in the `target.<triple>` section, though `rust.split-debuginfo` will still be honored for the "build" triple for now.

This PR changes the behavior when `rust.split-debuginfo` was **not** explicitly set **and** bootstrap is configured to cross-compile to a triple that has a different `split-debuginfo` than the "build" triple.

---

If there's a reasonable way to add additional tests for this, please let me know (I didn't find any tests checking cargo arguments in [`builder/tests.rs`](https://github.com/rust-lang/rust/blob/master/src/bootstrap/src/core/builder/tests.rs)).
2024-03-12 09:03:59 -07:00
bors
7de1a1f6db Auto merge of #122218 - Zoxc:no-interleave-panics, r=michaelwoerister
Lock stderr in panic handler

Fixes https://github.com/rust-lang/rust/issues/119789.
2024-03-12 14:01:38 +00:00
Krasimir Georgiev
0a2ddcd46b llvm-wrapper: adapt for LLVM API changes
Adapts rust for 9997e03971.
2024-03-12 12:39:25 +00:00
Jonathan Jensen
34e59f49d5 Fix typo in lib.rs of proc_macro 2024-03-12 13:35:14 +01:00
clubby789
e8cef43dd8 Properly rebuild rustbooks 2024-03-12 12:10:24 +00:00
Daria Sukhonina
5336a02d28 Fix discriminant_kind copy paste from the pointee trait case 2024-03-12 14:37:22 +03:00
bors
3b85d2c7fc Auto merge of #121644 - oli-obk:unique_static_innards2, r=RalfJung,nnethercote
Ensure nested allocations in statics neither get deduplicated nor duplicated

This PR generates new `DefId`s for nested allocations in static items and feeds all the right queries to make the compiler believe these are regular `static` items. I chose this design, because all other designs are fragile and make the compiler horribly complex for such a niche use case.

At present this wrecks incremental compilation performance *in case nested allocations exist* (because any query creating a `DefId` will be recomputed and never loaded from the cache). This will be resolved later in https://github.com/rust-lang/rust/pull/115613 . All other statics are unaffected by this change and will not have performance regressions (heh, famous last words)

This PR contains various smaller refactorings that can be pulled out into separate PRs. It is best reviewed commit-by-commit. The last commit is where the actual magic happens.

r? `@RalfJung` on the const interner and engine changes

fixes https://github.com/rust-lang/rust/issues/79738
2024-03-12 10:29:15 +00:00
Oli Scherer
e2773733f3 Some comment nits 2024-03-12 08:51:20 +00:00
bors
5b7343b966 Auto merge of #122170 - alexcrichton:rename-wasi-threads, r=petrochenkov
Rename `wasm32-wasi-preview1-threads` to `wasm32-wasip1-threads`

This commit renames the current `wasm32-wasi-preview1-threads` target to `wasm32-wasip1-threads`. The need for this rename is a bit unfortunate as the previous name was chosen in an attempt to be future-compatible with other WASI targets. Originally this target was proposed to be `wasm32-wasi-threads`, and that's what was originally implemented in wasi-sdk as well. After discussion though and with the plans for the upcoming component-model target (now named `wasm32-wasip2`) the "preview1" naming was chosen for the threads-based target. The WASI subgroup later decided that it was time to drop the "preview" terminology and recommends "pX" instead, hence previous PRs to add `wasm32-wasip2` and rename `wasm32-wasi` to `wasm32-wasip1`.

So, with all that history, the "proper name" for this target is different than its current name, so one way or another a rename is required. This PR proposes renaming this target cold-turkey, unlike `wasm32-wasi` which is having a long transition period to change its name. The threads-based target is predicted to see only a fraction of the traffic of `wasm32-wasi` due to the unstable nature of the WASI threads proposal itself.

While I was here I updated the in-tree documentation in the target spec file itself as most of the documentation was copied from the original WASI target and wasn't as applicable to this target.

Also, as an aside, I can at least try to apologize for all the naming confusion here, but this is hopefully the last WASI-related rename.
2024-03-12 08:30:46 +00:00
Jörn Horstmann
e91f937779 Add tests for the generated assembly of mask related simd instructions.
The tests show that the code generation currently uses the least
significant bits of <iX x N> vector masks when converting to <i1 xN>.
This leads to an additional left shift operation in the assembly for
x86, since mask operations on x86 operate based on the most significant
bit. On aarch64 the left shift is followed by a comparison against zero,
which repeats the sign bit across the whole lane.

The exception, which does not introduce an unneeded shift, is
simd_bitmask, because the code generation already shifts before
truncating.

By using the "C" calling convention the tests should be stable regarding
changes in register allocation, but it is possible that future llvm
updates will require updating some of the checks.

This additional instruction would be removed by the fix in #104693,
which uses the most significant bit for all mask operations.
2024-03-12 08:52:54 +01:00
bors
b0170b693e Auto merge of #122365 - matthiaskrgr:rollup-4i350h6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #115141 (Update Windows platform support)
 - #121865 (Add FileCheck annotations to MIR-opt unnamed-fields tests)
 - #122000 (Fix 32-bit overflows in LLVM composite constants)
 - #122194 (Enable creating backtraces via -Ztreat-err-as-bug when stashing errors)
 - #122319 (Don't ICE when non-self part of trait goal is constrained in new solver)
 - #122339 (Update books)
 - #122342 (Update /NODEFAUTLIB comment for msvc)
 - #122343 (Remove some unnecessary `allow(incomplete_features)` in the test suite)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-12 06:29:06 +00:00
Oli Scherer
783490da70 Fix stack overflow with recursive associated types 2024-03-12 06:03:43 +00:00
Oli Scherer
bbedde835e Exhaustively match on the mutability and nestedness 2024-03-12 05:53:47 +00:00
Oli Scherer
bbbf06d5e9 Manual rustfmt 2024-03-12 05:53:46 +00:00
Oli Scherer
926bfe5078 s/mt/mutability/ 2024-03-12 05:53:46 +00:00
Oli Scherer
d3514a036d Ensure nested allocations in statics do not get deduplicated 2024-03-12 05:53:46 +00:00
Oli Scherer
92414ab25d Make some functions private that are only ever used in the same module 2024-03-12 05:53:46 +00:00
Oli Scherer
0b4cbee660 Add nested bool to DefKind::Static.
Will be used in the next commit
2024-03-12 05:53:46 +00:00
Oli Scherer
9816915954 Change DefKind::Static to a struct variant 2024-03-12 05:53:46 +00:00
Oli Scherer
12e2846514 Stop requiring a type when codegenning types. We can get all the type info we need from the ConstAllocation 2024-03-12 05:53:46 +00:00
Oli Scherer
0ef52380a5 Check whether a static is mutable instead of passing it down 2024-03-12 05:53:46 +00:00
Oli Scherer
f0fa06bb7a Swap the order of a piece of code to make follow up diffs simpler 2024-03-12 05:50:11 +00:00
Oli Scherer
fcb890ea0c Use information from allocation instead of from the static's type 2024-03-12 05:50:11 +00:00
Oli Scherer
6719a8ef95 Move codegen_static function body to an inherent method in preparation of splitting it.
This should make the diff easier to read, as this commit does no functional changes at all.
2024-03-12 05:50:11 +00:00
Oli Scherer
d4b30aa96c Reduce some duplicate work that is being done around statics 2024-03-12 05:50:11 +00:00
Oli Scherer
dd1e27120d Share the llvm type computation between both arms of a condition 2024-03-12 05:50:10 +00:00
Amanjeev Sethi
0a2475c50a Add tests showing how we duplicate allocations when we shouldn't 2024-03-12 05:50:10 +00:00
Matthias Krüger
39e00760ec
Rollup merge of #122343 - compiler-errors:rando, r=fmease
Remove some unnecessary `allow(incomplete_features)` in the test suite

A useless change, but I like things to be clean.
2024-03-12 06:29:05 +01:00
Matthias Krüger
7b29381c8a
Rollup merge of #122342 - ChrisDenton:defautlib, r=petrochenkov
Update /NODEFAUTLIB comment for msvc

I've tried to explain a bit more about the effects of `/NODEFAULTLIB` when using msvc link.exe (or compatible) as they're different from `-nodefaultlib` on gnu.

I also removed the part about licensing as I'm not sure licensing is an issue? Or rather, it's no more or less of an issue no matter how you link msvc libraries. The license is the one you get if using VS at all and even dynamic linking includes static code (e.g. startup/shutdown code, etc).

r? petrochenkov
2024-03-12 06:29:05 +01:00
Matthias Krüger
3d5d83911f
Rollup merge of #122339 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/reference

3 commits in 3417f866932cb1c09c6be0f31d2a02ee01b4b95d..5afb503a4c1ea3c84370f8f4c08a1cddd1cdf6ad
2024-03-06 21:29:54 UTC to 2024-02-28 04:06:45 UTC

- Input format (rust-lang/reference#1459)
- Lexer: say that lifetime-like tokens can't be immediately followed by ' (rust-lang/reference#1479)
- Patterns and enums (rust-lang/reference#1460)

## rust-lang/rust-by-example

2 commits in 57f1e708f5d5850562bc385aaf610e6af14d6ec8..e093099709456e6fd74fecd2505fdf49a2471c10
2024-03-08 23:30:57 UTC to 2024-02-26 21:10:20 UTC

- While-Let Unable to compile code example on page (rust-lang/rust-by-example#1819)
- Update new_types.md wording (rust-lang/rust-by-example#1823)

## rust-lang/rustc-dev-guide

14 commits in 7b0ef5b0bea5e3ce3b9764aa5754a60e2cc05c52..8a5d647f19b08998612146b1cb2ca47083db63e0
2024-03-11 10:37:18 UTC to 2024-02-29 09:46:28 UTC

- update rustc-driver-interacting-with-the-ast.md (rust-lang/rustc-dev-guide#1930)
- Update rustc-driver-getting-diagnostics.md (rust-lang/rustc-dev-guide#1931)
- Document that test names cannot contain dots (rust-lang/rustc-dev-guide#1927)
- Update overview.md (rust-lang/rustc-dev-guide#1898)
- actually need to fix two occurances (rust-lang/rustc-dev-guide#1925)
- fix broken links (rust-lang/rustc-dev-guide#1924)
- next-solver: document caching (rust-lang/rustc-dev-guide#1923)
- Add compiletest docs for FileCheck prefixes and `//@ filecheck-flags:` (rust-lang/rustc-dev-guide#1914)
- Use different type in an example (rust-lang/rustc-dev-guide#1908)
- Update run-make test description (rust-lang/rustc-dev-guide#1920)
- Add some more details on feature gating (rust-lang/rustc-dev-guide#1891)
- make shell.nix better (rust-lang/rustc-dev-guide#1858)
- opaque types in new solver (rust-lang/rustc-dev-guide#1918)
- add implied bounds doc (rust-lang/rustc-dev-guide#1915)
2024-03-12 06:29:04 +01:00
Matthias Krüger
cd2efff518
Rollup merge of #122319 - compiler-errors:next-solver-normalizing-self-constrains-args, r=lcnr
Don't ICE when non-self part of trait goal is constrained in new solver

Self-explanatory. See test for example when this can happen.
2024-03-12 06:29:04 +01:00
Matthias Krüger
0b127d82f3
Rollup merge of #122194 - oli-obk:stash_delay_bug, r=nnethercote
Enable creating backtraces via -Ztreat-err-as-bug when stashing errors

r? `@nnethercote`

Otherwise I can't debug stashed errors because I can't find their source
2024-03-12 06:29:03 +01:00