Skip to content
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

Support running cargo miri in situations where target != host (e.g. "cross-interpretation") #698

Open
thomcc opened this issue Apr 3, 2021 · 11 comments
Labels
enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions!

Comments

@thomcc
Copy link
Member

thomcc commented Apr 3, 2021

The playground has the ability to run code under miri, but it would nice to be able to choose other targets.

A somewhat unknown (but highly useful) feature of miri is that it can run as a cross-interpreter. That is, even on x86_64-apple-darwin (or whatever), if I have, say the powerpc-unknown-linux-gnu target installed, I can do:

cargo miri test --target=powerpc-unknown-linux-gnu

and it will simulate running the test on that architecture, including emulating 32-bit big-endian linux (well, the set of linux syscalls that miri supports, anyway).

Right now I can't do this on the playground, and it would be useful to do quick checks and examples of big-endian code.


The downside is needing UI for this, and needing to rustup target add on the playground servers. So I understand some hesitancy.

Personally, I think it's most valuable for targets that are very different than x86_64 — e.g. I feel like just saying having an option for big-endian 32 and 64 bit targets would be good enough.

(It would be nice to also have one for target_pointer_width="16", like msp430-* or avr-*, but these being no_std only, it's hard enough to actually run the code that users probably should just do it locally)


Anyway, I thought I'd mention it. I kind of suspect it's the kind of "that'd be nice but doing it in a non-hacky way is likely not worth the effort" thing, but figured I'd suggest anyway. No worries if you'd rather wontfix this.

Note that this is related to #446, but not the same, as --target isn't a RUSTFLAG (or a MIRIFLAG), its a flag for cargo.

@thomcc thomcc added the wontfix label Apr 3, 2021
@thomcc
Copy link
Member Author

thomcc commented Apr 7, 2021

Hm, I guess I did something wrong here, since it says I added wontfix. I didn't mean to.

If it's just github being weird, can I get some justification there?

EDIT: I see what happened. I missed the small link to not use the templat on the "new issue" page, so just started with the "plz add my crate" template and deleted it and started fresh. Unfortunately, That template also has you add a wontfix to your own issue.

@shepmaster shepmaster removed the wontfix label Apr 7, 2021
@shepmaster
Copy link
Member

I missed the small link

Yeah, you'd be surprised at how many people don't read the template before opening an issue.

@shepmaster shepmaster added enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions! labels Apr 7, 2021
@shepmaster
Copy link
Member

The downside is needing UI for this, and needing to rustup target add on the playground servers

Does cargo miri setup need to be run for each target?

@RalfJung
Copy link
Member

RalfJung commented Apr 9, 2021

if I have, say the powerpc-unknown-linux-gnu target installed

You don't even need to have the target installed. The docs don't tell you to install a target and I never said so either when advertising this feature, so I wonder how this implicit assumption crept in.^^

Does cargo miri setup need to be run for each target?

Yes (but this also happens automatically when needed).

@RalfJung
Copy link
Member

RalfJung commented Apr 9, 2021

Note that this is related to #446, but not the same, as --target isn't a RUSTFLAG (or a MIRIFLAG), its a flag for cargo.

Ah, good point... but in principle we could use similar infrastructure for both of these kinds of flags.

@shepmaster
Copy link
Member

happens automatically when needed

If I'm understanding you correctly, that'd be a bad thing on the playground, as the setup we do now takes ~150 seconds which would blow far past the request timeout of 10 seconds.

To make sure we are on the same page, what do you think the timing of each of these commands would be if run sequentially?

cargo miri setup
cargo miri test --target=x86_64-unknown-linux-gnu
cargo miri test --target=powerpc-unknown-linux-gnu

@RalfJung
Copy link
Member

RalfJung commented Apr 9, 2021

If I'm understanding you correctly, that'd be a bad thing on the playground, as the setup we do now takes ~150 seconds which would blow far past the request timeout of 10 seconds.

Yeah, it'd probably be way too long.

To make sure we are on the same page, what do you think the timing of each of these commands would be if run sequentially?

On a "x86_64-unknown-linux-gnu" host I assume? The last command doesn't benefit from the previous ones, it builds a new standard library, which takes around 50-60s on my system.

@shepmaster
Copy link
Member

So to make this performant, we'd need to do this when pre-building the container:

cargo miri setup --target=x86_64-unknown-linux-gnu
cargo miri setup --target=powerpc-unknown-linux-gnu
...

Once for each playground-supported target. Does that sound correct?

@RalfJung
Copy link
Member

RalfJung commented Apr 9, 2021

Yes, that sounds right. However, don't you also need to pre-build the dependencies? So you can just do cargo miri run --target=X and that will do the setup part automatically.

@shepmaster
Copy link
Member

Maybe, I dunno! I assume that's changed over time and the build has never been updated since it worked:

https://github.com/integer32llc/rust-playground/blob/d03009c20002b21d76f2f01b1efdd2749a0559f1/compiler/miri/Dockerfile#L6-L8

@RalfJung
Copy link
Member

RalfJung commented Apr 9, 2021

Yeah the cargo miri setup part of this is redundant (but doesn't hurt).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions!
Projects
None yet
Development

No branches or pull requests

3 participants