Rust: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
(Marked this version for translation)
No edit summary
Line 17: Line 17:


<!--T:5-->
<!--T:5-->
2. Build and install locally the crate. This must be done from a login node.
2. Build and install the crate locally. This must be done from a login node.
{{Command|cargo install ungoliant}}
{{Command|cargo install ungoliant}}


Line 25: Line 25:


<!--T:7-->
<!--T:7-->
You can also add <tt>.cargo/bin</tt> to your <tt>$PATH</tt> with: <tt>export PATH="$HOME/.cargo/bin:$PATH"</tt>.
You can also add <code>.cargo/bin</code> to your <code>$PATH</code> with: <code>export PATH="$HOME/.cargo/bin:$PATH"</code>.


== Using the rust-nightly compiler ==  <!--T:8-->
== Using the Rust nightly compiler ==  <!--T:8-->
Since some optimization features are not yet stable they are not part of the stable release, but nonetheless some crates make use of them.
Since some optimization features are not yet stable they are not part of the stable release, but nonetheless some crates make use of them.
If you require the rust-nightly compiler, you can install it locally.
If you require the Rust nightly compiler, you can install it locally.


<!--T:9-->
<!--T:9-->

Revision as of 17:10, 30 January 2023

Other languages:

Rust is a multi-paradigm, high-level, general-purpose programming language. Rust emphasizes performance, type safety, and concurrency. Rust enforces memory safety — that is, that all references point to valid memory — without requiring the use of a garbage collector or reference counting present in other memory-safe languages.

Module

The Rust compiler is available as a module.

Question.png
[name@server ~]$ module spider rust

Installing a crate

A package written in Rust is called a crate.

1. Load the required modules.

Question.png
[name@server ~]$ module load gcc/9.3.0 rust

2. Build and install the crate locally. This must be done from a login node.

Question.png
[name@server ~]$ cargo install ungoliant

3. Test the binary.

Question.png
[name@server ~]$ $HOME/.cargo/bin/ungoliant -h

You can also add .cargo/bin to your $PATH with: export PATH="$HOME/.cargo/bin:$PATH".

Using the Rust nightly compiler

Since some optimization features are not yet stable they are not part of the stable release, but nonetheless some crates make use of them. If you require the Rust nightly compiler, you can install it locally.

1. Install the compiler as a local module.

Question.png
[name@server ~]$ eb Rust-1.53.0.eb --try-software-version=nightly --disable-enforce-checksums

2. Load the local module.

Question.png
[name@server ~]$ module load rust/nightly