User:gYakovlev/Rust
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 dev-lang/rust
or
root #
emerge --ask dev-lang/rust-bin
USE fags
USE flags for dev-lang/rust Systems programming language from Mozilla
big-endian
|
Big-endian toolchain support |
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 |
dist
|
Install dist tarballs (used for bootstrapping) |
doc
|
Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally |
llvm-libunwind
|
Use llvm-runtimes/libunwind instead of sys-libs/libunwind |
lto
|
Enable Link-Time Optimization (LTO) to optimize the build |
miri
|
Install miri, an interpreter for Rust's mid-level intermediate representation (requires USE=nightly, sometimes is broken) |
mrustc-bootstrap
|
Use dev-lang/mrustc to build the bootstrap Rust sysroot from this package's source |
nightly
|
Enable nightly (UNSTABLE) features (NOTE: it does not install nightly version, just enables features marked as nightly at time of release) |
parallel-compiler
|
Build a multi-threaded rustc (experimental, not tested by upstream) |
rust-analyzer
|
Install rust-analyzer, A Rust compiler front-end for IDEs (language server) |
rust-src
|
Install rust-src, needed by developer tools and for build-std (cross) |
rustfmt
|
Install rustfmt, Rust code formatter |
system-llvm
|
Use the system LLVM installation |
test
|
Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently) |
verify-sig
|
Verify upstream signatures on distfiles |
wasm
|
Build support for the wasm32-unknown-unknown target |
USE flags for dev-lang/rust-bin Systems programming language from Mozilla
big-endian
|
Big-endian toolchain support |
clippy
|
Install clippy, Rust code linter |
doc
|
Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally |
prefix
|
Defines if a Gentoo Prefix offset installation is used |
rust-analyzer
|
Install rust-analyzer, A Rust compiler front-end for IDEs (language server) |
rust-src
|
Install rust-src, needed by developer tools and for build-std (cross) |
rustfmt
|
Install rustfmt, Rust code formatter |
verify-sig
|
Verify upstream signatures on distfiles |
Switching between rust and rust-bin
root #
eselect rust list
Available Rust versions: [1] rust-1.40.0 *
Configuration for use with portage
RUSTFLAGS
RUSTFLAGS="-C target-cpu=native"
CARGO_TARGET_x86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C target-cpu=znver1"
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.
#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:
- Knowledge Base - The front page to the Knowledge Base
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:
- Visit the Gentoo Forums to acquire even more knowledge!