User Tools

Site Tools


Rust install from tar.gz

  • Unpack rust-1.XX.X-<arch>-unknown-linux-gnu.tar.gz (after checking gpg signature)
  • Run –prefix=/usr/local/rust –disable-ldconfig (for minimal install –components=rustc,rust-std-armv7-unknown-linux-gnueabihf,cargo)
  • Make symlinks in /usr/local/bin (if not done previously - maybe avoid rls as emacs defaults to that instead of rust-analyzer)
  • Create /etc/ contents: /usr/local/rust/lib
  • Run ldconfig
  • Unpack rustc-1.XX.X-src.tar.gz (after checking gpg signature)
  • mkdir -p /usr/local/rust/lib/rustlib/src/rust
  • cp -dR –preserve=timestamps rustc-1.XX.X-src/library/ /usr/local/rust/lib/rustlib/src/rust/

Add WASM support

Found good info here Non-rustup setups

$ wget
$ wget
$ gpg --verify rust-std-1.66.0-wasm32-unknown-unknown.tar.xz.asc
$ tar xvaf rust-std-1.66.0-wasm32-unknown-unknown.tar.xz

$ rustc --print sysroot

# cd rust-std-1.66.0-wasm32-unknown-unknown/
# cp --preserve=timestamps -R rust-std-wasm32-unknown-unknown/lib/rustlib/wasm32-unknown-unknown/ /usr/local/rust/lib/rustlib/

Compiling Rust code with MSVC

  • Start Rust 1.63 (MSVC) Shell for 32-bit or 64-bit
  • Run the following command to setup the MSVC environment


"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars32.bat"


"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"

Cross compiling for ARMv7

Make sure to have the necessary external libraries available if needed. Example with librrd (and its dependencies)

# Needs librrd-dev:armhf for the last linking step

#| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
#|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
#||/ Name             Version      Architecture Description
#ii  librrd-dev:armhf 1.7.2-3+b7   armhf        time-series data storage and display system (development)

Then to compile for armv7-unknown-linux-gnueabihf

cargo build -r --target armv7-unknown-linux-gnueabihf --config target.armv7-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-gcc\"

Rust error handling

Use #[non_exhaustive] for error enums to avoid API breaks when just adding a new type of error.

Using C libraries

Rust guides

Rust memory

Perf and Rust

From Guide to Rustc Development The basic perf command is this:

perf record -F99 --call-graph dwarf XXX

The -F99 tells perf to sample at 99 Hz, which avoids generating too much data for longer runs (why 99 Hz you ask? It is often chosen because it is unlikely to be in lockstep with other periodic activity). The –call-graph dwarf tells perf to get call-graph information from debuginfo, which is accurate. The XXX is the command you want to profile. So, for example, you might do:

Find unused source files

rustc --emit=dep-info src/ 2> /dev/null; for file in $(find src/ -name '*.rs'); do grep -q -E "^${file}:$" main.d || echo "$file"; done; rm main.d
general/rust.txt · Last modified: 2024/05/15 07:49 by sunkan

Donate Powered by PHP Valid HTML5 Valid CSS Run on Debian Driven by DokuWiki