Hey. So I'm trying to get started hacking on rustc, but I can't even build the compiler. I've read CONTRIBUTING.md and the rustc-guide. I've unset
RUSTC_WRAPPER, I'm not using
RUSTFLAGS, and I'm not using a
config.toml. I've been chatting with @eddyb in #compiler on Discord. I had it working, then in running some experiments with Eddy, now I can't get it compiling any more. Here's what I'm seeing running
./x.py build -i --verbose: https://gist.github.com/dwijnand/2335a671d417a1e4d7a5a14d61cfde9c. Any ideas?
Is this on a clean checkout or do you have local modifications?
I doubt this is related, but if you're trying to get yourself off the ground, maybe kill off the
-i flag for now.
this definitely seems weird though
it looks like
cargo complained about an inability to parse the output from one of the
rustc commands it invoked; maybe try running that
rustc invocation yourself and see what output it produces
I'm referring to this line here: https://gist.github.com/dwijnand/2335a671d417a1e4d7a5a14d61cfde9c#file-gistfile1-txt-L616
I've seen similar messages after adding
println!() statements in the compiler. It's this issue https://github.com/rust-lang/rust/issues/43855
Ah yes, I've got printlns!
Re-running without :)
If you switch those to
eprintln!() that should fix it. Or you can use the
Any pros/cons there? When I tried all 3 last time only
I'm not aware of any real downsides to
eprintln!() other than it will always print.
debug!() gives you more control but you have to turn it on.
There's more info on
debug!() here https://rust-lang-nursery.github.io/rustc-guide/compiler-debugging.html#getting-logging-output
I'll just copy this here because it's easy to glance over and if you miss it, you'll waste 20+ minutes waiting for a rebuild:
make sure that debug-assertions=yes is turned on in your config.toml
RUST_LOG work with
./x.py test? I'd like to add some debug messages and see what they print while running my tests.
You need to compile with a
debug-assertions = true (I think that's the key, check the comments). After that,
RUST_LOG will work.
debug-assertions = true, but I'm not seeing my messages..
I found that I had to compile the whole compiler with it for it to work.
(that was a while ago, and I've just did it that way since, so there might be a quicker way)
Often you don't want that
RUST_LOG while running all the tests, you'll instead run them with no logging and
x.py and then run individual tests directly with
rustc and use
RUST_LOG then (saves your scrollback).
Yeah I guess I'll go that way
I've successfully avoid having to do the local/custom rustup toolchain till now
I've never needed to set up a local rustup toolchain when working on the compiler.
Normally you can just run
rustc from the build directory.
It's really pretty easy. The last time I did it, I wrote this up so I can just copy-paste in the future https://wesleywiser.github.io/post/custom-rust-toolchain/
(or in the guide as well)
I had no idea that was mentioned in the guide.
Yup, all setup. I was just lazy.
Are the toolchain paths relative so it would work in any of my rustc directories or do I need to make a toolchain per rustc directory?
1 think they're absolute so 1 per rustc directory would be my guess (but I don't know :)
Well your shell will expand relative paths before passing them to
rustup I think
Makes sense. In that case I'll stick with just specifying the path to rustc in the build directory.
I have one per rustc directory
~/.rustup/toolchains. They're absolute for me:
├── [lrwxr-xr-x dnw staff 40 Sep 12 17:15] stage1 -> /d/rust/build/x86_64-apple-darwin/stage1/ ├── [lrwxr-xr-x dnw staff 40 Sep 12 17:15] stage2 -> /d/rust/build/x86_64-apple-darwin/stage2/