User:gYakovlev/Rust

From Gentoo Wiki
Jump to: navigation, search

Resources

This article provides an introduction to using app-lang/rust or dev-lang/rust-bin on Gentoo, optimizing compiled code using safe, sane RUSTFLAGS.

Installation

Emerge

Install

root #emerge --ask app-lang/rust

or

root #emerge --ask app-lang/rust-bin

USE fags

USE flags for dev-lang/rust Systems programming language from Mozilla

clippy Install clippy, Rust code linter
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
gtk-doc Build and install gtk-doc based developer documentation for dev-util/devhelp, IDE and offline use
libressl Use dev-libs/libressl instead of dev-libs/openssl when applicable (see also the ssl useflag)
miri Install miri, an interpreter for Rust's mid-level intermediate representation (requires USE=nightly)
nightly Enable nightly (UNSTABLE) features
parallel-compiler Build a multi-threaded rustc
rls Install rls, Rust Language Server (used with IDEs supporting RLS protocol)
rustfmt Install rustfmt, Rust code formatter
system-bootstrap Bootstrap using installed rust compiler
system-llvm Use the system LLVM install
wasm Build support for the wasm32-unknown-unknown target

USE flags for dev-lang/rust-bin Systems programming language from Mozilla

clippy Install clippy, Rust code linter
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
gtk-doc Build and install gtk-doc based developer documentation for dev-util/devhelp, IDE and offline use
libressl Use dev-libs/libressl instead of dev-libs/openssl when applicable (see also the ssl useflag)
rustfmt Install rustfmt, Rust code formatter

Switching between rust and rust-bin

root #eselect rust list
Available Rust versions:
  [1]   rust-1.40.0 *


Configuration for use with portage

RUSTFLAGS

CODE Setting RUSTFLAGS in /etc/portage/make.conf
RUSTFLAGS="-C target-cpu=native"

rustc --print target-cpus

Cargo configuration

Cargo can also be configured through environment variables. For each configuration key of the form foo.bar the environment variable CARGO_FOO_BAR can also be used to define the value. For example the build.jobs key can also be defined by CARGO_BUILD_JOBS.

Environment variables will take precedent over TOML configuration, and currently only integer, boolean, and string keys are supported to be defined by environment variables.

CODE Setting CARGO_* in /etc/portage/make.conf
#quiet build
CARGO_TERM_VERBOSE=false
# override autodetection of MAKEOPTS=-j parameter
CARGO_BUILD_JOBS=2

https://doc.rust-lang.org/cargo/reference/config.html

Describe to the user when the issue described in the "Synopsis" above is indeed applicable in this context.

Be clear in this matter, and use verifiable methods, such as checking output with grep or so...

Known problems

cargo-clippy not available after enabling USEflag and re-installing rust.

Resolution

root #eselect rust set 1

See also

(This is an optional part.)

If there are related topics the user can read to gather knowledge located inside this wiki, then list them each with a bullet point here under the a "See also" section:

External resources

(This is an optional part.)

If there are additional resources that can be view outside this wiki, list them each with a bullet point here under an "External resources" section: