rust-playground icon indicating copy to clipboard operation
rust-playground copied to clipboard

Add a way to pass custom rustc flags

Open oli-obk opened this issue 5 years ago • 4 comments

The playground is often used for experimenting with features and/or creating minimal repros for feature requests and bugs. It would be great if we could make full use of the compiler by also being able to specify arbitrary flags.

My personal motivation is -Zunleash-the-miri-inside-of-you, which takes the brakes off the const evaluator and allows demonstrating why we are doing some things the way we are (because other ways are unsound or incoherent or ...).

oli-obk avatar Dec 11 '18 09:12 oli-obk

I think that @lqd might have had a prototype for this at some point. I remember that we had some light concerns around any options that could do "bad things" to the running process, but there's so many options and people keep adding them (eyes @oli-obk suspiciously) that it's difficult to know what works.

It would also be nice to have a list of them and a sentence of "documentation". If you have to open the terminal to figure out the exact name, it's a lot less useful. These can be used to populate an autocomplete/helper like thing.

Notably, any rustflags will also need to be added to the URL for sharing purposes.

shepmaster avatar Dec 11 '18 14:12 shepmaster

I was imagining that flags could be controlled by a comment in the file, similar to ui tests. Like, if the first line is

// compile-flags: FLAGS

then those will be passed to rustc/miri/... That would also mean we do not need a separate mechanism for sharing them in the URL, as they are shared with the code.

I think that @lqd might have had a prototype for this at some point. I remember that we had some light concerns around any options that could do "bad things" to the running process, but there's so many options and people keep adding them (eyes @oli-obk suspiciously) that it's difficult to know what works.

Given that playground already runs arbitrary code put in my the user, I cannot imagine anything beyond that that flags could achieve. You have to have it all sandboxed anyway.

RalfJung avatar Aug 08 '20 11:08 RalfJung

I'm hacking together a prototype implementation of this. It works pretty well to set MIRIFLAGS by just adding a --env to the Docker invocation.

But when I try to set RUSTFLAGS, a build command attempts to recompile the playground crate which has an incredible number of dependencies (which is the point). Tossing in PLAYGROUND_NO_DEPENDENCIES=true when I set RUSTFLAGS works, but seems pretty heavy-handed.

Does anyone have better ideas? @shepmaster ?

saethlin avatar Feb 21 '22 05:02 saethlin

Indeed RUSTFLAGS affects all crates, not just the current one. The semantically more correct option here would be to pass the flags via cargo rustc, I think, but that is probably harder to fit into the existing infrastructure.

RalfJung avatar Feb 21 '22 14:02 RalfJung