How to get rid of rust target [Windows] - windows

For some reason the thumbv7m-none-eabi target is in every rust project i create
I have reinstalled rust completely (from the uninstaller and deleting .cargo and .rustup)
rustup show:
rustup home: C:\Users\USER\.rustup
stable-x86_64-pc-windows-msvc (default)
rustc 1.61.0 (fe5b13d68 2022-05-18)
rustup target list does not list thumbv7m-none-eabi as installed
rustup target remove does not work either.
This results in me not being able to use the std library in any project whatsoever.

SOLVED:
Vscode settings.json was set to add --target thumbv7m-none-eabi for some reason.
Thats why reinstalls fixed nothing and i was just going insane

Related

Substrate node template error#E0463 - can't find crate for std

I am following the tutorial [importing contracts pallet crate]. Installed nightly-2020-10-06 and cargo build. When I run code get error - "cant find std"_"the wasm32-unknown-unknown target may not be installed". Can not work out where I am going wrong... Have added [dependencies] and [features] runtime code - then ran cargo check... where I get error... Would like to know where I am going wrong, and how too solve issue..
depending on the toolchain you're building with you can write
rustup target add wasm32-unknown-unknown --toolchain nightly
or
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-06
and specify the toolchain with a +<toolchain> in your cargo commands like cargo +nightly build

Debugging Rust in Clion results in "Error creating process"

I'm new to rust and would like to debug my Rust code using Clion (19.3 currently) and followed this answer to switch the compiler from MSVC to GNU, Now when I run my program (in debug) I get this error from Clion:
com.jetbrains.cidr.execution.debugger.backend.gdb.GDBDriver$GDBCommandException: Error creating process <Program Path>, (error 50).
Though running without debugging works fine.
If I google the error I get this issue on github which essentially says use a 64bit compiler on a 64bit app. The compiler I added is 64 bit and since I installed the 64 bit version of rust I assume that the programs that it outputs are 64bit... (though I don't know enough about rust to be 100% sure)
Running rustup show returns this:
rustup show
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\User\.rustup
installed toolchains
--------------------
stable-x86_64-pc-windows-gnu (default)
stable-x86_64-pc-windows-msvc
active toolchain
----------------
stable-x86_64-pc-windows-gnu (default)
rustc 1.42.0 (b8cedc004 2020-03-09)
Which is where I'm getting the idea that the correct toolchain is being used (as it says x86_64 all over the place).
Where as I going wrong? and what is miss configured?
Turns out that I'm super dumb and had the Clion pointing at a 32 bit install rather than the 64 bit install. I ended up following this guide by Jetbrains themselves: https://blog.jetbrains.com/clion/2019/10/debugging-rust-code-in-clion/
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".
Update October 2021
Jetbrains have release an updated blog post that shows some improvements they have made to the debug process, for example on windows you no longer need to change settings in order to get debugging to work! https://blog.jetbrains.com/rust/2021/10/19/debugging-rust-in-jetbrains-ides-state-of-affairs/

Step by step instruction to install Rust and Cargo for mingw with Msys2?

I tried to install Rust on Cygwin but failed to be able link with mingw. Now I am trying to install it with Msys2. I already installed Msys2 and Mingw. I tried to follow this wiki page but I got lost at number 2:
Download and install Rust+Cargo using the installer but be sure to disable the Linker and platform libraries option.
Is it referring to the "rustup-init.exe" on the install page? Should I double click to run this file or run it from Msys2? I tried to run from Msys2 and got the options:
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
I don't know what to do next.
The Using Rust on Windows page you linked to dates from before rustup replaced the installer as the default option to install Rust. Installers are still available, but you should use rustup if possible, because it makes it easy to update and to use multiple toolchains at once (e.g. stable, beta and nightly). If you must use the installer, just select the x86_64-pc-windows-gnu installer and follow the step from the Using Rust on Windows page. If you're using rustup, read on.
By default, rustup on Windows installs the compiler and tools targeting the MSVC toolchain, rather than the GNU/MinGW-w64 toolchain. At the initial menu, select 2) Customize installation. When asked for a host triple, enter x86_64-pc-windows-gnu. Then make a choice for the other questions, then proceed with the installation.
Note: If rustup is already installed, then rerunning rustup-init won't actually install the requested toolchain. Instead, run rustup toolchain install stable-x86_64-pc-windows-gnu if you already have the MSVC-based toolchain. Then run rustup default stable-x86_64-pc-windows-gnu to set the GNU-based toolchain as the default.
Rustup will install the MinGW linker and platform libraries automatically (as part of the rust-mingw component) and refuses to let you remove them. If you prefer to use the MinGW linker and libraries you installed with MSYS2, you'll need to create a .cargo/config file (either in your profile directory, i.e. C:\Users\you\.cargo\config, or in your project's directory if this configuration is specific to a project). The contents of that file might look like this:
[target.x86_64-pc-windows-gnu]
linker = "C:\\msys2\\mingw64\\bin\\gcc.exe"
ar = "C:\\msys2\\mingw64\\bin\\ar.exe"
Rustup will modify the PATH environment variable unless you told it not to. However, MSYS2 resets PATH by default when you launch, so when you try to invoke cargo or rustc from your MSYS2 shell, it might not find it. You'll need to edit your .profile/.bash_profile script to set the PATH correctly (you need to prepend /c/Users/yourname/.cargo/bin: to PATH).
my problem resolved by following way
Run rustup toolchain install stable-x86_64-pc-windows-gnu
Second open .rustup folder
Open settings.toml file
Change first line with: default_toolchain = "stable-x86_64-pc-windows-gnu"
done!
I wrote a complete guide on how to
install Rust on windows with Visual Studio Code and MSYS2 MinGW
on the page found here:
https://stackoverflow.com/a/68835925/4230643

CLion build process does not start make install [duplicate]

I'm evaluating CLion 1.2.1 on an existing project which is already using CMake. The project is made up of a few library modules and a single executable.
I have an install target which I use to collect the executable and a configuration file together in a bin folder for debugging:
...
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
install(FILES config.xml DESTINATION ${CMAKE_BINARY_DIR}/bin/)
When building on the command line I'd just run:
make install
which as expected builds the binaries and if successful then runs the above install commands.
My problem is that I can't get CLion to run the 'install' target. I expected to be able to create a new Run/Debug configuration but the Target: dropdown only contains those targets added using add_executable() and add_library().
I also tried adding 'install' to the Build options in the Settings dialog. That however runs install for every target now including 'clean' which is not right.
UPDATE: As of 2018.1 EAP, build 181.3741.16, CLion supports running cmake install if your project defines install targets:
(source: cloudfront.net)
Original Answer:
I don't think that CLion implements this feature yet. However, you can work around this limitation by adding a CMake "custom target" (using add_custom_target()) that will execute the make install command:
add_custom_target(install_${PROJECT_NAME}
$(MAKE) install
DEPENDS ${PROJECT_NAME}
COMMENT "Installing ${PROJECT_NAME}")
Now, all you have to do is "build" the install_YOUR_PROJECT_NAME target from the "targets" menu in CLion.
Update:
A more cross-platform technique might be the following:
add_custom_target(install_${PROJECT_NAME}
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target install
DEPENDS ${PROJECT_NAME}
COMMENT "Installing ${PROJECT_NAME}")
#maddouri 's comment already addresses your question. Alternatively, Under Settings -> Build, Execution, Deployment -> CMake, you can also set Build Option for Debug or Release build type to something like -j 2 install. With this setting, whenever CLion builds the code, it will install your targets, too!

Is it possible to have multiple coexisting Rust installations?

Would it be possible to have a nightly build Rust compiler for convenience (faster build cycle, auto-update) and a dev version of Rust cloned from GitHub for experimentation purposes?
The idea is I have a binary version of Rust for my various project and a version of Rust I can hack on, without them causing havoc between each other.
If it matters, assume my OS is Ubuntu 64-bit.
The current solution is to use rustup. Once installed, you can install multiple toolchains:
rustup install nightly
rustup install stable
rustup install 1.7
If you have a local build of Rust, you can link it as a toolchain
rustup toolchain link my-development /path/to/rust/code
You can pick a default toolchain
rustup default stable
Or add an override toolchain for a specific directory on your machine only via rustup
cd /my/cool/project
rustup override set nightly
Or add an override toolchain that lives with a specific directory, like a repository, via a rust-toolchain file
cd /my/cool/project
echo "nightly" > rust-toolchain
If you want to just use a different toolchain temporarily, you can use the "plus syntax":
rustc +1.7 --help
cargo +nightly build
In other cases you can use rustup run to run any arbitrary command in a specific toolchain:
rustup run nightly any command you want here
See also:
How to execute cargo test using the nightly channel?
Sure. In the development version, use the --prefix option to ./configure, e.g. --prefix=~/opt/rust-dev, and then its installed files will be contained entirely inside that directory.
Try to configure your IDE. Though I am working on Windows computer, I think the idea is similar to Ubuntu.
First, I've installed 3 versions of Rust into:
C:\Rust\64 beta MSVC 1.9
C:\Rust\64 nightly MSVC 1.10
C:\Rust\64 stable MSVC 1.8
Then I configured my IDE (in this case, IntelliJ IDEA 2016 + Rust Plug-In) to use different versions of Rust depending on build selector.
After this I can compile my code with different Rust versions just by selecting build-config from toolbar.
You also don't need to install your development version. You could just make symlink from somewhere in your $PATH to the rustc binary that lives somewhere inside the source tree/build directory, the compiler will find its dynamically linked dependencies and it will emit binaries that know about that path too (if even dynamically linked).
Try envirius.
It allows you to create any number of environments with any version of the rust.
For the first time it will download the source code of the rust and will compile it.
And it will take some time. But second and subsequent attempts will takes under 10 seconds as it just will copy the binaries into the target environment.
For example:
➥ nv mk --rust=0.9
Creating environment: rust-0.9 ...
* installing rust==0.9 ...
* done (in 5 secs.)
➥ nv ls
Available environment(s):
rust-0.9
➥ nv on rust-0.9
Environment rust-0.9 activated.
(rust-0.9) ➥ rustc -v
rustc 0.9
Usually when dealing with rustup, you're dealing with toolchains–a single installation of the Rust compiler. There are 3 major release channels:
stable
beta
nightly
The channel can be appended with optional date and host names: channel[-date][-host].
You can install multiple toolchains using rustup:
rustup toolchain install nightly
rustup toolchain install stable-x86_64-pc-windows-msvc
Be careful when nightly is installed as any updates using rustup update will also update stable.
You can have different level of overrides:
# command level
rustc +beta <command>
cargo +beta <command>
# environment level
export RUSTUP_TOOLCHAIN=nightly-2019-05-22
# directory level
rustup override set stable
The toolchain configuration can also be version controlled using a rust-toolchain file, which contains just the toolchain name.
$ cat rust-toolchain
nightly-2019-05-22
No host name can be configured in the rust-toolchain file.
The override precedence is:
An explicit toolchain, e.g. cargo +beta
The RUSTUP_TOOLCHAIN environment variable
A directory override, ala rustup override set beta
The rust-toolchain file
The default toolchain
Reference: https://github.com/rust-lang/rustup.rs#toolchain-specification

Resources