Commit Graph

4854 Commits

Author SHA1 Message Date
Ralf Jung
88b9c2173e also support old 'cargo miri run -- -- args' style 2020-09-21 09:10:04 +02:00
bors
5a15c8a6dd Auto merge of #1554 - RalfJung:rustup, r=RalfJung
rustup; support panic=abort on Windows

Fixes https://github.com/rust-lang/miri/issues/1058
2020-09-20 13:56:59 +00:00
Ralf Jung
4b5e78052a rustup; support panic=abort on Windows 2020-09-20 15:55:36 +02:00
bors
1f6ce43721 Auto merge of #1553 - RalfJung:rustup, r=RalfJung
rustup

Cc `@oli-obk`
2020-09-20 11:14:29 +00:00
Ralf Jung
b0baa151b2 rustup 2020-09-20 13:13:57 +02:00
bors
7942e7797b Auto merge of #1552 - RalfJung:rustup, r=RalfJung
rustup; make sure the generator moves even with smarter optimizations
2020-09-20 10:18:29 +00:00
Ralf Jung
08e076c658 account for mir-opts masking more errors 2020-09-20 12:18:02 +02:00
Ralf Jung
83a339e5a9 rustup; make sure the iterator moves even with smarter optimizations 2020-09-20 10:26:22 +02:00
bors
e086ae5d45 Auto merge of #1551 - RalfJung:readme, r=RalfJung
list two more aliasing problems we found in BTreeMap and VecDeque
2020-09-19 09:40:24 +00:00
Ralf Jung
5652052e23 list two more aliasing problems we found in BTreeMap and VecDeque 2020-09-19 11:39:13 +02:00
bors
84a4514254 Auto merge of #1549 - RalfJung:panic-abort, r=oli-obk
support panic=abort

This adds support for abort-on-panic (https://github.com/rust-lang/miri/issues/1058). To achieve this, we insert `cargo-miri` as `RUSTC` when building the standard library, and patch the rustc flags in a way similar to what bootstrap does.

However, this is currently not supported on Windows as the Windows code uses inline assembly to cause an abort (?!?). I'll submit a rustc PR with some `cffg(miri)` to make that work. (EDIT: that would be https://github.com/rust-lang/rust/pull/76871)

Cc `@Aaron1011` r? `@oli-obk`
2020-09-18 11:41:04 +00:00
Ralf Jung
97a71c0c77
fmt
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2020-09-18 13:34:25 +02:00
Ralf Jung
32cdb7131b support panic=abort 2020-09-18 13:10:18 +02:00
bors
ce3d1a654a Auto merge of #1548 - RalfJung:update, r=RalfJung
Update dependencies
2020-09-18 10:19:04 +00:00
Ralf Jung
6be8761e47 update for major version bumps 2020-09-18 12:17:09 +02:00
Ralf Jung
055e90dd6f 'cargo update' test-cargo-miri 2020-09-18 12:12:02 +02:00
Ralf Jung
e9e67c97cc cargo update main crates 2020-09-17 20:08:18 +02:00
bors
ce29fbf406 Auto merge of #1540 - RalfJung:cargo-miri-redone, r=oli-obk
Redo cargo-miri logic

This rewrite the cargo-miri logic for running the requested crate(s) following what we outlined in https://github.com/rust-lang/miri/issues/739: `cargo miri run/test $FLAGS` (almost) literally invokes `cargo run/test $FLAGS` but with some environment variables set so that we can control what happens:
* `RUSTC_WRAPPER` is set so that we get invoked instead of `rustc`. We use that power to mess with the flags being used for the build (things to be interpreted by Miri use a different sysroot), and when we are detecting a binary crate meant to be run by Miri, we grab the info we care about and put it into a JSON file for later use.
* `CARGO_TARGET_$TARGET_RUNNER` is set so what we get invoked when cargo wants to run a binary. At that point we take that JSON info from before and use it to invoke Miri.

Overall this works great! We get all sorts of cargo magic for free, and do not even need `cargo-metadata` any more. There's one annoying point though, which I have not managed to entirely work around yet: this means we are doing a full build, not just a check-build. Given that our sysroot is MIR-only, I was surprised that this even worked, but still -- this means we are doing more work than we should. So I also added some patching of arguments to make sure `--emit` does not contain `link`, and then more patching was required of the `--extern` flags for the binary because those referenced the `.rlib` files but now only `.rmeta` exists, and that is still not fully working because cargo seems to expect those `.rmeta` files and now triggers a rebuild each time as those files are still missing. My current plan is to make our wrapper create some empty dummy files with the right names, but the amount of hacks we are stacking on top of each other here is getting worrysome.^^ `@ehuss` your input would be welcome on this issue.

Due to re-using cargo more literally, this also changes flag parsing to match `cargo`. So `-Zmiri` flags now have to be passed via an environment variable (Cc https://github.com/rust-lang/miri/issues/1416).

This PR is not ready yet, but the parts that are there I think can be reviewed already. TODO:
* [x] [Fix Windows](https://github.com/rust-lang/miri/pull/1540#issuecomment-688733741).
* [x] Figure out how we can do check-only builds without the rebuild problem above. ~~I am also worried about cases where `build.rs` script might detect check-only builds and then do less work; I think some crates in rustc are doing that and if this is a thing in the wider ecosystem we need to find a way to support this as well.~~ (postponed that until we have a concrete example)
* [x] Currently cargo runs doctests as well, and they are not run in Miri. We should at least figure out a way to not run them at all (resolving https://github.com/rust-lang/miri/issues/584 is left for a future PR).
* [x] For some time, detect the old way of passing `-Zmiri` flags and warn that this will need updating. For some simple situations we can probably make it still support the old way, but I plan to remove those hacks after a bit. This is just to give people and me time to go around and send PRs to all projects that use Miri on CI, and update their use of the flags.
* [x] Add a test for stdin handling (https://github.com/rust-lang/miri/issues/1505). This should work now but we should be sure.
* [x] Add a test for cargo env vars (https://github.com/rust-lang/miri/issues/1515).
* [x] Check if https://github.com/rust-lang/miri/issues/1516 is resolved.
* [x] Check if https://github.com/rust-lang/miri/issues/1001 and https://github.com/rust-lang/miri/issues/1514 are resolved.
* [x] Check if https://github.com/rust-lang/miri/issues/1312 is resolved (not sure if it is wort adding a test).
* [x] Check if https://github.com/rust-lang/miri/issues/1512 is resolved (not sure if it is wort adding a test).

Fixes https://github.com/rust-lang/miri/issues/700.
Fixes https://github.com/rust-lang/miri/issues/739.
Fixes https://github.com/rust-lang/miri/issues/1001.
Fixes https://github.com/rust-lang/miri/issues/1312 (without a test, as we run without cargo's stdin/stdout wrapping now, as the test for stdin confirms).
Fixes https://github.com/rust-lang/miri/issues/1416.
Fixes https://github.com/rust-lang/miri/issues/1505.
Fixes https://github.com/rust-lang/miri/issues/1512 (without a test, as cargo now does all that handling anyway, which various other tests confirm).
Fixes https://github.com/rust-lang/miri/issues/1514.
Fixes https://github.com/rust-lang/miri/issues/1516.

Cc `@alecmocatta` who reported many of the bugs above; would be great if you could help with the tests e.g. by providing some small examples I could try.
r? `@oli-obk`
2020-09-17 16:52:23 +00:00
bors
79f023eeb1 Auto merge of #1547 - RalfJung:rustup, r=RalfJung
rustup; no need to special-case the guaranteed_eq/ne intrinsics any more
2020-09-17 15:43:29 +00:00
Ralf Jung
3163242ff1 rustup; no need to special-case the guaranteed_eq/ne intrinsics any more 2020-09-17 17:42:52 +02:00
Ralf Jung
ae859c3f7b add comment mentioning alternative approach 2020-09-17 17:33:47 +02:00
Ralf Jung
db067f4a3e test-cargo-miri: normalize slashes before comparing paths 2020-09-17 17:33:47 +02:00
Ralf Jung
05f5c3d078 make sure tests pass even with RUST_TEST_NOCAPTURE set 2020-09-17 17:33:47 +02:00
Ralf Jung
18483b4d5e make (not yet actually used) doctest actually use the crate, and fix a comment 2020-09-17 17:33:47 +02:00
Ralf Jung
f7612f71bc more consistent error capitalization 2020-09-17 17:33:47 +02:00
Ralf Jung
192b535adc cleaner output for cargo-miri-test harness 2020-09-17 17:33:47 +02:00
Ralf Jung
b244a2ddaa make sure subcrate tests have the right cwd 2020-09-17 17:33:47 +02:00
Ralf Jung
c99fb102b8 test 'cargo miri run' CWD, also for subcrate in a workspace 2020-09-17 17:33:47 +02:00
Ralf Jung
113a335c3e test propagating env vars from build.rs to binary 2020-09-17 17:33:47 +02:00
Ralf Jung
33c669679e test 'harness=false' tests 2020-09-17 17:33:47 +02:00
Ralf Jung
174a92c39a detect when the user passes Miri's flags the old way, and support this for now 2020-09-17 17:33:47 +02:00
Ralf Jung
93bedd0a09 fix cargo-miri-test for cross-runs 2020-09-17 17:33:47 +02:00
Ralf Jung
2205ed5bbb show proper warning about not running doctests 2020-09-17 17:33:47 +02:00
Ralf Jung
ba3b354af9 update comment
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2020-09-17 17:33:47 +02:00
Ralf Jung
504c617cd4 test reading from stdin 2020-09-17 17:33:47 +02:00
Ralf Jung
74fdb5cf2c patch away --error-format and --json so that errors are rendered properly 2020-09-17 17:33:47 +02:00
Ralf Jung
119bf4d607 forward build-time env vars to binary, and test that we do 2020-09-17 17:33:46 +02:00
Ralf Jung
10f58b3eab fix Miri script on macOS 2020-09-17 17:29:19 +02:00
Ralf Jung
c793d6036a handle binary suffices (for Windows); stop deleting fake binary 2020-09-17 17:29:19 +02:00
Ralf Jung
53eab7195a make our filename handling work better across platforms 2020-09-17 17:29:19 +02:00
Ralf Jung
147330cc36 even when not linking, create stub .rlib files to fool cargo 2020-09-17 17:29:19 +02:00
Ralf Jung
0019fe2459 fix typo
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2020-09-17 17:29:19 +02:00
Ralf Jung
9a9988a4b0 update docs, and also use MIRIFLAGS for the test suite 2020-09-17 17:29:19 +02:00
Ralf Jung
ee7d589530 test respecting 'test=false', and what happens with doctests 2020-09-17 17:29:19 +02:00
Ralf Jung
c41a039c56 patch --extern and --emit; test suite passes now! 2020-09-17 17:29:19 +02:00
Ralf Jung
7ee2729824 it actually runs tests now! 2020-09-17 17:29:19 +02:00
Ralf Jung
e2119dc94d stub JSON information flow from cargo-build-time to run-time 2020-09-17 17:29:19 +02:00
Ralf Jung
16afe1a234 towards letting cargo do binary selection: wrappers and runners set up 2020-09-17 17:29:19 +02:00
Ralf Jung
2b3b83eb2c canonicalize miri's directory 2020-09-17 17:29:19 +02:00
bors
09e6ccc580 Auto merge of #1546 - Aaron1011:fix/windows-panic, r=RalfJung
Enable some panic tests on Windows
2020-09-17 13:49:44 +00:00