Hi, I am trying to compile the Rust language from its source code so that I can build Rust code that targets UWP (universal windows platform).
A disclaimer: I am not a systems programmer or Rust developer. I've never worked with C or C++ before, at least not in deeper level. I've read The Rust Book a year ago and that's it. Therefore, if I mistakenly misspell or confuse the terminology, I apologize.
More specifically, I need to consume a library that is written in Rust to build my app on XBOX, which is UWP. I need to target the x86_64-uwp-windows-msvc architecture so that I can consume it in UWP environment. Compiling this library against this target is apparently not an easy task because this architecture is not officially supported by the Rust team. It is in Tier 3.
I tried the -Z build-std flag (as described under the "build-std" title in "Unstable" section) in Cargo to build the standard library against the mentioned target. By following the instructions at bdbai/firstuwp-rs, I was able to compile a very very basic code and I was able to consume it in the XBOX environment. However, the instructions used a very old version of the nightly build. Therefore, as soon as I introduced the futures = "0.3" dependency in Cargo.toml, the build failed because one of its dependency uses the Cargo.toml edition 2021.
I don't want to use the nightly version of Rust because as documentation says it is very unstable and I "totally don't know what I am doing".
I would like to use the 1.79.0 version of rust, which is stable, to build and target the x86_64-uwp-windows-msvc. The installation instructions don't give me any information on how to do this. I fiddled with the x.py build script but no result from there either.
At this point I decided to ask in the Rust forum for how to do this. Would you please enlighten me?
If all you want to do is to compile it using the newest stable release of Rust, I'm assuming you just have to replace the commands in the first step of bdbai/firstuwp-rs with the following:
Then just follow the steps again. Disclaimer: I'm unable to test this right now and I'm still a pretty new Rust user so I'm sure there's much better advice out here on the forums!
Unfortunately build-std is a nightly only feature. However if you change the nightly date to a recent version that should fix the crate compatibility issues you are experiencing.
For a project that requires nightly, it is better to create a rust-toolchain.toml file rather than using rustup override. The advantage is that
it can be stored with the project in version control, rather than in the user's rustup configuration only
if used with a date, it documents exactly which nightly version to use, so that when you or others come to it in the future when nightly features might have changed, they know what to go back to or what to migrate the code away from.
Once you've done that, you don't need to execute any of those rustup commands; rustup will automatically download the toolchain and specified components.
(You'll want to remove the override, with rustup override unset, if you have one already. Otherwise the file will be ignored.)
Thanks for showing this. The advice @Jacob640 has worked out for me. Changing the nightly build for a newer version fixed my issue. Saving it in the rust-toolchain.toml file is a good idea.