MSVC toolchain is not supported. Please use GNU toolchain
Asked Answered
G

3

25

I was trying to debug Rust in CLion when I was greeted with the aforementioned

enter image description here

I updated my toolchain setting to use the suggested default as such:

enter image description here

How can I fix this issue and get CLion to be able to debug Rust code?

I did some searching but haven't found a simple answer (at at least one I can understand easily).

Any help would be greatly appreciated.

Grandioso answered 21/8, 2019 at 3:33 Comment(1)
It is not clear what exactly you are actually asking. Please edit your question to state explicitly the question you would like to have answered.Kyleekylen
L
40

Error message is related about Rust toolchain, you need to use GNU based toolchain for Rust.

If you haven't installed it yet, please make sure that you are choosing the valid gnu based toolchain for your environment, if you are not sure please read the Note section. You can install it via:

> rustup toolchain install stable-x86_64-pc-windows-gnu

Then the easiest way to solve this problem is setting this toolchain as the default Rust Toolchain:

> rustup default stable-x86_64-pc-windows-gnu

Note : Toolchain stable-x86_64-pc-windows is selected as an example; it's a solution for 64-bit Windows via stable channel, another toolchain needs to be used for different architecture(Details: please follow the official jetbrains guide from other answer), also you are free to use nightly or beta.

Lavonia answered 21/8, 2019 at 5:50 Comment(3)
On attempting to debug I now get: com.jetbrains.cidr.execution.debugger.backend.gdb.GDBDriver$GDBCommandException: "C:/Users/Jonathan/CLionProjects/rust_proj/target/debug/rust_proj-587b28fba9c3bb8c.exe": not in executable format: File format not recognized. Any help?Grandioso
re: the not in executable format: File format not recognized error, I am now getting it one year later after your post. I have yet to figure it out, but it appears that psotos on GitHub here solved his issue by making sure his rust library and debugger were of the same bitness (in his case, x64). I corrected the setting for myself but am still experiencing the same error.Experimental
I discovered my mistake. Though I set the rustup toolchain correctly, I set up my mingw environment wrong. When you configure your mingw, make sure not only to select the correct environment folder but to also select the correct debugger from the dropdown list at the bottom. If you simply clone your mingw and only select the right folder at the top, the debugger won't have changed bitness... As a result I had the weird symptom that 32 bit rustup worked for both mingw 32 and 64 and couldn't figure out why 64 didn't work for either, despite that compilation was x64.Experimental
U
6

As well as Ömer Erden's answer it is worth pointing out that Jetbarins now has an article about how to configure Clion for Rust complete with some tips on what settings are applicable to Rust development.

Debugging Rust Code in CLion

Particularly this paragraph is relevant to the question:

On Windows, go to Settings | Build, Execution, Deployment | Toolchain and set either Cygwin or MinGW as your working environment. Then, run rustup toolchain list and check the first line: it should be one of the gnu versions matching the bitness of the debugger. For example, if you’re working on MinGW (32-bit), the default toolchain should be i686-pc-windows-gnu. If you’re on MinGW64, it should be x86_64-pc-windows-gnu. You can set the appropriate toolchain by running rustup default <toolchain_name>.

Underexposure answered 22/3, 2020 at 22:21 Comment(0)
P
4

For Jetbrain CLion Version 2022.2.1.

Go to | Setting -> Build,Execution,Deployment -> Click the '+' -> Click 'Visual Studio'.| Then, you are good to go.

enter image description here

Tips
For mycase, while I click the visual studio. My antivirus avast will treat the checking program as trojan malware. To avoid this, I need to create an exception for the folder over avast.
C:\Users[username]\AppData\Local\Temp\cmake_check_environment

Pancreas answered 7/9, 2022 at 0:52 Comment(1)
This worked for me, thanks. I had MinGW and Visual Studio listed as my options. I made Visual Studio the default, which I'd already configured to use the Bundled LLDB Debugger.Tinnitus

© 2022 - 2024 — McMap. All rights reserved.