I would like to set up a toolchain override for one of my rust projects to use the GNU toolchain instead of the default MSVC one. But somehow the configuration in rust-toolchain.toml
is ignored. (I am up to date it is not because of the extension.)
Here is how it goes:
λ rustup show
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\<username>\scoop\persist\rustup\.rustup
installed toolchains
--------------------
stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc (default)
installed targets for active toolchain
--------------------------------------
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
active toolchain
----------------
stable-x86_64-pc-windows-msvc (default)
rustc 1.57.0 (f1edd0429 2021-11-29)
As you can see I have the GNU toolchain installed.
So I created the following rust-toolchain.toml
file:
λ cat rust-toolchain.toml
[toolchain]
channel = "stable"
targets = ["x86_64-pc-windows-gnu"]
Now when I run rustup show
I get a result showing the tool is seeing the file, but it does not seem to be processing it correctly since it still wants to use msvc.
λ rustup show
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\<username>\scoop\persist\rustup\.rustup
installed toolchains
--------------------
stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc (default)
installed targets for active toolchain
--------------------------------------
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
active toolchain
----------------
stable-x86_64-pc-windows-msvc (overridden by 'C:\<project path>\rust-toolchain.toml')
rustc 1.57.0 (f1edd0429 2021-11-29)
My guess is that for some reason x86_64-pc-windows-gnu
is considered a valid target for the stable-x86_64-pc-windows-msvc
toolchain, but I do not understand why, how to prevent it, or how to write in the rust-toolchain.toml
file that I want to to use the x86_64-pc-windows-gnu
target of the stable-x86_64-pc-windows-gnu
toolchain and not the one of the stable-x86_64-pc-windows-msvc
toolchain.
How do you think I could solve this?
Note: using rustup default stable-gnu
works as expected but I would like to be able to commit something in the repository so that other contributors (and their tools) know they need to use this specific toolchain.
Edit: rustup version just in case.
λ rustup -V
rustup 1.24.3 (ce5817a94 2021-05-31)