-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redo cargo-miri logic #1540
Redo cargo-miri logic #1540
Conversation
CI says
Looks like Windows needs a special case. |
@oli-obk so regarding that check-build situation, I wonder if there isn't a better way than to mess with the flags... the best way of course would be to actually convince cargo to do a "check-build version of |
|
If we could pass I assume this means rustc would still produce both a .rlib and .rmeta file, so there is some unnecessary disk I/O, but I also assume that MIR-only .rlib are not big enough to make this a problem. |
I added |
Ah, that sounds like exactly what we'd need here. :) Could you point me to the relevant PRs? Will that code still work today? (If you have some time and want to just re-add it yourself that would be much appreciated. :D I can also do it though, just might take a few days until I get around to it.) |
It was removed in rust-lang/rust#58847. |
Uff, this will be annoying... to implement the Also I am getting errors like this:
Not sure where that is coming from. But this is much less clean than I expected... |
Oh, I forgot that we are also using Miri for "host" crates that need actual binaries. Those will need a proper codegen backend. That probably explains the "can't find crate for" issue. The problem with the target features remains, though. |
I think at least the stable target features should be moved out of |
6c260a4
to
5a6820e
Compare
Yeah, compiling that part of libstd is also where the errors show up for Miri. |
I did some more work on the hacky approach of messing with |
0e370ac
to
495aa93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems reasonable to me, though it does require quite some hacks (which has never been a blocker for me 😆 )
Getting rid of |
8e6575a
to
907de3a
Compare
I put some tests here. I observed two issues:
and
|
@alecmocatta thanks for testing! I also had just noticed the |
Ah, the workspace thing is annoying... the working directory is different between build-time and run-time. Miri now runs in the working directory the test runs, but then the relative path |
@alecmocatta all right, this should work now with the latest version. |
990b04e
to
ae859c3
Compare
(fixed conflict) |
@bors r+ nope I'm fine continuing with the current approach |
📌 Commit ae859c3 has been approved by |
☀️ Test successful - checks-travis, status-appveyor |
update Miri Let's get rust-lang/miri#1540 shipped. Cc @rust-lang/miri r? @ghost
update Miri Let's get rust-lang/miri#1540 shipped. Cc @rust-lang/miri r? @ghost
update Miri Let's get rust-lang/miri#1540 shipped. Cc @rust-lang/miri r? @ghost
update Miri Let's get rust-lang/miri#1540 shipped. Fixes rust-lang#76968. Cc `@rust-lang/miri` r? `@ghost`
also support old 'cargo miri run -- -- args' style I forgot this in #1540. Again this is just temporary, for backwards compatibility.
…li-obk Add option to pass a custom codegen backend from a driver This allows the driver to pass information to the codegen backend. For example the headcrab debugger may in the future want to use cg_clif to JIT code to be injected in the debuggee. This would PR make it possible to tell cg_clif which symbol can be found at which address and to tell it to inject the JITed code into the right process. This PR may also help with rust-lang/miri#1540 by allowing miri to provide a codegen backend that only emits metadata and doesn't perform any codegen. cc @nbaksalyar (headcrab) cc @RalfJung (miri)
…li-obk Add option to pass a custom codegen backend from a driver This allows the driver to pass information to the codegen backend. For example the headcrab debugger may in the future want to use cg_clif to JIT code to be injected in the debuggee. This would PR make it possible to tell cg_clif which symbol can be found at which address and to tell it to inject the JITed code into the right process. This PR may also help with rust-lang/miri#1540 by allowing miri to provide a codegen backend that only emits metadata and doesn't perform any codegen. cc @nbaksalyar (headcrab) cc @RalfJung (miri)
…li-obk Add option to pass a custom codegen backend from a driver This allows the driver to pass information to the codegen backend. For example the headcrab debugger may in the future want to use cg_clif to JIT code to be injected in the debuggee. This would PR make it possible to tell cg_clif which symbol can be found at which address and to tell it to inject the JITed code into the right process. This PR may also help with rust-lang/miri#1540 by allowing miri to provide a codegen backend that only emits metadata and doesn't perform any codegen. cc @nbaksalyar (headcrab) cc @RalfJung (miri)
Add option to pass a custom codegen backend from a driver This allows the driver to pass information to the codegen backend. For example the headcrab debugger may in the future want to use cg_clif to JIT code to be injected in the debuggee. This would PR make it possible to tell cg_clif which symbol can be found at which address and to tell it to inject the JITed code into the right process. This PR may also help with rust-lang/miri#1540 by allowing miri to provide a codegen backend that only emits metadata and doesn't perform any codegen. cc @nbaksalyar (headcrab) cc @RalfJung (miri)
remove compatibility code for passing miri flags via cargo arguments With #1540, we deprecated `cargo miri test -- -Zmiri-disable-stacked-borrows` as a style of passing flags to Miri, introducing `MIRIFLAGS="-Zmiri-disable-stacked-borrows" cargo miri test` instead. This made `cargo miri` more compatible with `cargo`; both now behave the same in terms of argument parsing. However, to avoid breaking things, I introduced some backwards compatibility hack such that the old way would still work. Six months later, I think it is time to remove that hack.
This rewrite the cargo-miri logic for running the requested crate(s) following what we outlined in #739:
cargo miri run/test $FLAGS
(almost) literally invokescargo 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 ofrustc
. 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 containlink
, 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 #1416).This PR is not ready yet, but the parts that are there I think can be reviewed already. TODO:
I am also worried about cases where(postponed that until we have a concrete example)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.cargo miri test
does not run doc-tests #584 is left for a future PR).-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.harness = false
aren't run #1516 is resolved.env::current_dir()
is not updated for non-root packages in a workspace #1514 are resolved.Fixes #700.
Fixes #739.
Fixes #1001.
Fixes #1312 (without a test, as we run without cargo's stdin/stdout wrapping now, as the test for stdin confirms).
Fixes #1416.
Fixes #1505.
Fixes #1512 (without a test, as cargo now does all that handling anyway, which various other tests confirm).
Fixes #1514.
Fixes #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