Add hash of source files in debug info
LLVM supports placing the hash of source files inside the debug info.
This information can be used by a debugger to verify that the source code matches
the executable.
This change adds support for both hash algorithms supported by LLVM, MD5 and SHA1, controlled by a target option.
* DWARF only supports MD5
* LLVM IR supports MD5 and SHA1 (and SHA256 in LLVM 11).
* CodeView (.PDB) supports MD5, SHA1, and SHA256.
Fixes#68980.
Tracking issue: #70401
rustc dev guide PR with further details: https://github.com/rust-lang/rustc-dev-guide/pull/623
Make the rustc respect the `-C codegen-units` flag in incremental mode.
This PR implements (the as of yet unapproved) major change proposal at https://github.com/rust-lang/compiler-team/issues/245. See the description there for background and rationale.
The changes are pretty straightforward and should be easy to rebase if the proposal gets accepted at some point.
r? @nikomatsakis cc @pnkfelix
Rollup of 9 pull requests
Successful merges:
- #69860 (Use associated numeric consts in documentation)
- #70576 (Update the description of the ticket to point at RFC 1721)
- #70597 (Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new)
- #70640 (Hide `task_context` when lowering body)
- #70641 (Remove duplicated code in trait selection)
- #70707 (Remove unused graphviz emitter)
- #70720 (Place TLS initializers with relocations in .tdata)
- #70735 (Clean up E0502 explanation)
- #70741 (Add test for #59023)
Failed merges:
r? @ghost
Place TLS initializers with relocations in .tdata
Should fix#70673, although I'm not sure how to test this. Perhaps @joshlf could find a MCVE?
Also adds more context to the FIXME.
r? @oli-obk
Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new
While working on concurrency support for Miri, I found that the `libstd::syn::unix::Thread::new` method has two potential problems: double-free and undefined behaviour.
**Double-free** could occur if the following events happened (credit for pointing this out goes to @RalfJung):
1. The call to `pthread_create` successfully launched a new thread that executed to completion and deallocated `p`.
2. The call to `pthread_attr_destroy` returned a non-zero value causing the `assert_eq!` to panic.
3. Since `mem::forget(p)` was not yet executed, the destructor of `p` would be executed and cause a double-free.
As far as I understand, this code also violates the stacked-borrows aliasing rules and thus would result in **undefined behaviour** if these rules were adopted. The problem is that the ownership of `p` is passed to the newly created thread before the call to `mem::forget`. Since the call to `mem::forget` is still a call, it counts as a use of `p` and triggers UB.
This pull request changes the code to use `mem::ManuallyDrop` instead of `mem::forget`. As a consequence, in case of a panic, `p` would be potentially leaked, which while undesirable is probably better than double-free or undefined behaviour.
Use associated numeric consts in documentation
Now when the associated constants on int/float types are stabilized and the recommended way of accessing said constants (#68952). We can start using it in this repository, and recommend it via documentation example code.
This PR is the reincarnation of #67913 minus the actual adding + stabilization of said constants. (EDIT: Now it's only changing the documentation. So users will see the new consts, but we don't yet update the internal code)
Because of how fast bit rot happens to PRs that touch this many files, it does not try to replace 100% of the old usage of the constants in the entire repo, but a good chunk of them.
bootstrap: add `--json-output` for rust-analyzer
Motivation is that this allows us to customize rust-analyzer's "cargo watch" integration to run x.py. You simply have to set the command to run to be `x.py --json-output`
r? @Mark-Simulacrum -- feel free to make changes, this is quick and dirty for sure
Miri engine: stronger type-based sanity check for assignments
r? @oli-obk @eddyb
Fixes https://github.com/rust-lang/rust/issues/70405
That issue says
> be sure to also add appropriate mutability checks to the patterns (mutable for the source, immutable for the dest)
I decided not to do that because I see no good reason to do it. The engine does not care either way, the assignment will happen correctly.