-
Notifications
You must be signed in to change notification settings - Fork 13k
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
make miri usable as stage 0/1 tool #52856
Comments
Not really -- this is done so that the compiler can be more easily changed in how it handles SIMD. It would also be a degradation in overall compile times since stage 0 builds will take longer.
We do not set RUST_SYSROOT at all today -- I'm certain a patch to do so can be accepted, though. Should be relatively easy.
It looks like miri needs the codegen backends to function -- this is rather unexpected; the reason the test suite fails is that the codegen backends aren't built/linked into the right place. This should also be relatively easy to fix. I'm not clear on what MIRI needs to work properly, but I suspect that we can make the situation better here. I think what would be most useful at this point is a summary of what you expect to happen after changing std, test, and rustc_mir, for example (i.e., what needs to be rebuilt). Does miri use proc macros? |
I am also surprised that miri needs the codegen backends. It shouldn't codegen anything.
miri itself does not (AFAIK), but EDIT: Ah, miri's test suite needs compiletest which depends on serde as well, for some reason. EDIT:
Compile time impact is <10s for me, but while I do not understand what the first part of your sentence means, I get that it might be annoying for compiler/SIMD development in the future. |
Ah dang compiletest-rs uses serde to parse rustc JSON output. So I guess yes we need proc macros. That's a no-go currently for stages <2, right?
Ideally on a rustc_mir change, it should rebuild the stage0 compiler artifacts and then build a stage1 libstd with that compiler and then build miri with that. When changing std, it'd start with step 2 above, i.e. not touch the compiler at all. I guess that needs a I realize this is off-by-1-stage compared to now: I am imagining stage 1 miri to be built with the stage 0 compiler artifacts. This is in line with how @eddyb told me a "stage" is defined; it is consistent e.g. with |
@Mark-Simulacrum said the situation changed, so I re-tested this. My first command to run was So I went for Unfortunately,
This messages comes from xargo, which is not happy about the compiler we are using... which is strange because to build Miri it clearly used the compiler produced by the stage 0 compiler artifacts, but now xargo seems to pick up the bootstrap compiler and then bails out. |
it uses the compiler produced by stage 0 (as a library), but it's not compiled by that compiler. Maybe we need to teach xargo about |
Oh... 🤯
Or can we make xargo use the compiler produced by stage 0 to build libstd? Not sure if that was already assembled at this point. |
I think that will be even more confusing, as everything else is built by the stage 0 compiler (the beta compiler using |
With this xargo patch, it succeeds at building a libstd for Miri. However, later all tests fail when it tries to use that libstd:
That's expected I guess -- the libstd is loaded by the rustc built into Miri which is the one created by "stage 0 compiler artifacts", but that is not the rustc that built this libstd. So I think we have to make xargo use the compiler produced by stage 0 to build libstd. I do not know how to achieve that though. |
ah yes, that makes sense. Can we make xargo use the miri binary to produce the artifactsß |
uh... |
But yeah that is probably the cleanest solution. What is the best way to just say "behave like the The main thing I am worried about is that it means all the codegen stuff in Miri will be reachable, so the binary might become bigger. But OTOH I doubt that the linker currently is clever enough to actually remove all that stuff, so... whatever. |
the llvm backend is a dylib anyway, and the rest... yea, I doubt that gets optimized away.
Run Line 30 in 4802f09
|
I like making Miri behaving like rustc when told so, then actually cargo-miri can just always invoke the Miri binary and thus we never have the problem that the rustc and Miri we are using are incompatible! I think we can kill the sysroot check when/if this works. :D However, in the context of rustbuild it gets me all sort of build failures for the build scripts needed by libcore... they don't have a libstd, rather unsurprisingly. Almost as if we had a bootstrap problem here. ;) Right now I am setting the |
There's also the |
Yes, but one env var just takes precedence over the other, and either choice is wrong. We need the bootstrap |
Ah, we have That gets us through the xargo phase. Now we get:
That's the opposite error. Something somewhere is using the host rustc for target (Miri) things... |
Yay, I git it to work. :D |
I confirmed that with latest Miri master, This makes me so happy. :D |
Moving miri to the compiler made development with miri significantly harder. To avoid rebuilding the compiler twice on every change in
librustc_mir/interpret
, I usually do./x.py build src/rustc --keep-stage 0
. This still does unnecessary work, however, when changing libstd (but that is likely hard to avoid?). Also--keep-stage
is somewhat fragile. So overall, developing miri is much more cumbersome than previously (and that's not even talking about it being much harder to land patches, and much more likely to get merge conflicts, but that part is unavoidable).It would be great if one could build, test and run miri in earlier stages. The building part actually works, but only with a trick:
The env var is needed because stage 0 libstd does not contain
std::arch
. Could we change that?Running works but is not very straight-forward
Looks like
RUST_SYSROOT
is not properly set during build, so I have to give the sysroot manually?Running the test suite, however, fails:
How could we do better (other than maybe enabling
std::arch
in stage 0)? @eddyb suggested thattest src/tools/miri
should behave more liketest src/test/run-pass
, and test the stuff produced by the previous stage, but I find that somewhat strange. The compiler itself has strange "leveling issues" in a staged build, but the tools should be more consistent.I'd expect miri to behave more like libstd:
build --stage 1 src/libstd
builds using the compiler produced in stage 0, andtest --stage 1 src/libstd --no-doc
tests with that same compiler. So maybebuild --stage 1 src/tools/miri
should be built with the compiler produced in stage 0 and the libstd produced in stage 1 (similar tobuild --stage 1 src/rustc
).build --stage 0 src/tools/miri
would use the bootstrap compiler to build miri, which will likely not work but that's okay.test --stage 1 src/tools/miri
would first dobuild --stage 1 src/tools/miri
and then run the tests in thestage1
sysroot.Or does that not work because miri depends on librustc?
Cc @oli-obk @eddyb (and maybe we should get a bootstrap expert in the loop?)
The text was updated successfully, but these errors were encountered: