Auto merge of #1761 - hyd-dev:build-rs-proc-macro-no-default-args, r=RalfJung
Don't use `MIRI_DEFAULT_ARGS` to compile host crates
They (specifically, `--cfg=miri`) may cause procedural macros (and probably build scripts) to depend on Miri-only symbols, such as `miri_resolve_frame`.
This PR makes `miri` detect host crates inspecting the value of the `MIRI_BE_RUSTC` environment variable (`target` -> target crate, `host` -> host crate, other -> panic) and skip the insertion of `MIRI_DEFAULT_ARGS` if it's a host crate.
Auto merge of #1757 - RalfJung:rustdoc, r=RalfJung
add rustdoc support
`@teryror` did all the work in https://github.com/rust-lang/miri/pull/1671; I just finished things up and fixed conflicts. Also thanks to `@hyd-dev` for preemptively fixing a sysroot issue that would have taken me some time to diagnose.
Minor change: I changed the quotes around `<untagged>` into backticks, so they render correctly in markdown.
~~Significant change: I documented that `-Zmiri-track-raw-pointers` is a strictly more restrictive model that "normal" Stacked Borrows. **I am not confident this change is correct, please verify it.** If this change is not correct, let me know, and I'll update this PR to document that :-)~~
EDIT: I was wrong, `-Zmiri-track-raw-pointers` may not be strictly more restrictive. I added the following sentence to prevent others from making the same assumption that I did:
> Note that it is not currently guaranteed that code that works with `-Zmiri-track-raw-pointers` also works without `-Zmiri-track-raw-pointers`.
Improvements to the README item on `-Zmiri-track-raw-pointers`.
1. The double quotes around <untagged> are changed to backspaces, so <untagged>
will render correctly in markdown.
2. Clarify that -Zmiri-track-raw-pointers will never accept code that Miri
would not have accepted without -Zmiri-track-raw-pointers.
bors [Wed, 17 Mar 2021 17:47:51 +0000 (17:47 +0000)]
Auto merge of #1745 - hyd-dev:unsup-foreign-calls-are-not-ub, r=RalfJung
Improve error message of calling unsupported non-"C"/"system"-ABI foreign function
Miri currently reports the following `foo()` call has ABI-mismatch UB:
```rust
#[cfg(unix)]
extern "Rust" { // or any non-"C" ABI
fn foo();
}
#[cfg(windows)]
extern "C" { // or any non-"system" ABI
fn foo();
}
fn main() {
unsafe {
foo();
}
}
```
[Output when targeting Linux](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=72afc3bd4d9fdab962422cfc2c5a2166) (and maybe also macOS):
```
error: Undefined Behavior: calling a function with ABI C using caller ABI Rust
--> src/main.rs:13:9
|
13 | foo();
| ^^^^^ calling a function with ABI C using caller ABI Rust
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavio
```
Output when targeting Windows:
```
error: Undefined Behavior: calling a function with ABI system using caller ABI C
--> <anon>:13:9
|
13 | foo();
| ^^^^^ calling a function with ABI system using caller ABI C
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
```
However, to my knowledge, that's not UB -- it's just unsupported by Miri (and Miri can't assume the function has `"C"` or `"system"` ABI since Miri doesn't know about it). I believe that is because of the overzealous `check_abi()` call before the long `match` in `src/shims/{posix,windows}/foreign_items.rs`. The ABI is checked to match the system one (`"system"` on Windows, `"C"` otherwise) no matter the callee is recognized as a shim or an unsupported foreign function.
Therefore, this PR removes the `check_abi()` call before the `match` and inserts a `check_abi()` call to each non-wildcard match.
bors [Fri, 5 Mar 2021 12:29:32 +0000 (12:29 +0000)]
Auto merge of #1733 - Smittyvb:breakpoint-intrinsic, r=RalfJung
Support breakpoint intrinsic
The `breakpoint` intrinsic raises a `SIGTRAP` signal. If a debugger is attached to a normal program, then `SIGTRAP` can be used to trigger breakpoints in debuggers like `gdb`. If there is no debugger, then the program exits with a message like `Trace/breakpoint trap (core dumped)`. This adds support for the intrinsic in Miri. While actually passing through the `SIGTRAP` doesn't make sense in a Miri context (if it just raised the signal normally then it would allow for debugging Miri itself, not the program being evaluated). As such, it just raises an error.
bors [Tue, 2 Mar 2021 11:08:27 +0000 (11:08 +0000)]
Auto merge of #1730 - RalfJung:zulip, r=oli-obk
add date to Zulip notification subject
We sometimes have discussions in those threads; let's make sure we have a new thread for each new day (which likely means a new problem... or nobody got around to fixing things yet^^).
bors [Tue, 2 Mar 2021 10:51:12 +0000 (10:51 +0000)]
Auto merge of #1731 - RalfJung:ci, r=oli-obk
adjust CI test flags
`RUST_TEST_NOCAPTURE` seems to make no difference except for making compiletest output not use colors any more; `RUST_BACKTRACE` is already set by `compiletest.rs`.
bors [Tue, 2 Mar 2021 10:11:02 +0000 (10:11 +0000)]
Auto merge of #1729 - RalfJung:rustup, r=RalfJung
rustup; fix tests for new MIR optimization
Somehow https://github.com/rust-lang/rust/pull/78360 manages to mask UB. This would make sense if there were loops or things like that, but there are not, so really this is just very confusing...
bors [Sat, 27 Feb 2021 19:11:05 +0000 (19:11 +0000)]
Auto merge of #1725 - RalfJung:zst-reborrow, r=RalfJung
fix reborrowing of tagged ZST references
`@SkiFire13` [pointed out](https://github.com/rust-lang/rust/pull/82554#issuecomment-787088712) that Miri fails to detect illegal use of empty slices. This PR fixes that. In so doing, it uncovers a flaw of Stacked Borrows: it is incompatible with how the formatting machinery uses `extern type`, so for now we skip reborrowing when we cannot determine the exact size of the pointee.