#!/bin/sh # Update to rust release by downloading and verifying GPG keys set -u if [ $# -ne 1 ]; then echo "Usage: $0 <version>" echo "Example: $0 1.67.1" exit 1 fi TMPDIR_BASE=/tmp RUST_VERSION=$1 TARGET="x86_64-unknown-linux-gnu" RUST_REPO="https://static.rust-lang.org/dist" RUST_FILE="rust-${RUST_VERSION}-${TARGET}.tar.xz" RUSTC_FILE="rustc-${RUST_VERSION}-src.tar.xz" ARMV7HF_EXT="armv7-unknown-linux-gnueabihf" MUSL_EXT="x86_64-unknown-linux-musl" WASM_EXT="wasm32-unknown-unknown" WINX64_EXT="x86_64-pc-windows-gnu" #EXTENSIONS="$ARMV7HF_EXT $MUSL_EXT $WASM_EXT $WINX64_EXT" EXTENSIONS="" create_rust_pgp_key_file() { echo | base64 -d > rust.key <<EOF mQINBFJEwMkBEADlPACa2K7reD4x5zd8afKx75QYKmxqZwywRbgeICeD4bKiQoJZdUjmn1LgrGaX uBMKXJQhyA34e/1YZel/8et+HPE5XpljBfNYXWbVocE1UMUTnFU9CKXa4AhJ33f7we2/QmNRMUif w5adPwGMg4D8cDKXk02NdnqQlmFByv0vSaArR5kngZKnLY6o0zZ9Buyy761Im/ShXqv4ATUgYiFc 48z33G4j+BDmn0ryGr1aFdP58tHpgjWtLZs0iWeFNRDYDje6ODyu/MjOyuAWb2pYDH47Xu7XedMZ zenH2TLM9yt/hyOVxReDPhvoGkaO8xqHioJMoPQi1gBjuBeewmFyTSPS4deASukhCFOcTsw/enzJ agiSZAq6Imehduke+peAL1z4PuRmzDPO2LPhVS7CDXtuKAYqUV2YakTq8MZUempVhw5nLqVaJ5/X iyOcv405PnkT25eIVVVghxAgyz6bOU/UMjGQYlkUxI7YZ9tdreLlFyPROUL30E8q/aCd4PGJV24y J1uit+yS8xjyUiMKm4J7oMP2XdBN98TUfLGw7SKeAxyU92BHlxg7yyPfI4TglsCzoSgEIV6xoGOV RRCYlGzSjUfz0bCMCclhTQRBkegKcjB3sMTyG3SPZbjTlCqrFHy13e6hG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QfTDJfE/IljwjrhDa9Mi+odtnMWq8vlwOZZ24/8/BNK5q XuCYL67O7AJB4ZQ6BT+g4z96iRLbupzu/XJyXkQFrOY/Ghegvn7fDrnt2KC9MpgeFBXzUp+k5rzU dF8jbCx5apVjA1sWXB9Kh3L+DUwFMve696B5tlHyc1KxjHR6w9GRsh4= EOF } download_if_missing () { local filename=$1 local dest=$2 if [ -f $TMPDIR_BASE/$filename ]; then mv $TMPDIR_BASE/$filename $dest else wget -c $RUST_REPO/$filename fi } tmpdir=$( mktemp -d $TMPDIR_BASE/rust-update-tmp.XXXXXXXXXX ) cd $tmpdir download_if_missing $RUST_FILE $tmpdir download_if_missing $RUST_FILE.asc $tmpdir download_if_missing $RUSTC_FILE $tmpdir download_if_missing $RUSTC_FILE.asc $tmpdir for ext in $EXTENSIONS; do tarfile="rust-std-${RUST_VERSION}-$ext.tar.xz" download_if_missing $tarfile $tmpdir download_if_missing $tarfile.asc $tmpdir done create_rust_pgp_key_file gpgv --keyring ./rust.key $RUST_FILE.asc $RUST_FILE || exit 2 gpgv --keyring ./rust.key $RUSTC_FILE.asc $RUSTC_FILE || exit 3 exitcode=10 for ext in $EXTENSIONS; do tarfile="rust-std-${RUST_VERSION}-$ext.tar.xz" gpgv --keyring ./rust.key $tarfile.asc $tarfile || exit $exitcode exitcode=$((exitcode + 1)) done # Remove previously installed rustlibs find /usr/local/rust/lib/rustlib -depth -mindepth 1 -maxdepth 1 -type d \! -name $TARGET \! -name 'etc' \! -name 'src' | xargs --no-run-if-empty rm -r tar xaf $RUST_FILE cd rust-${RUST_VERSION}-${TARGET} ./install.sh --prefix=/usr/local/rust cd .. rm -rf rust-${RUST_VERSION}-${TARGET} tar xaf $RUSTC_FILE cd rustc-${RUST_VERSION}-src rm -rf /usr/local/rust/lib/rustlib/src/rust/library mkdir -p /usr/local/rust/lib/rustlib/src/rust cp -dR --preserve=timestamps library /usr/local/rust/lib/rustlib/src/rust/ cd .. for ext in $EXTENSIONS; do tarfile="rust-std-${RUST_VERSION}-$ext.tar.xz" tar xaf $tarfile cd rust-std-${RUST_VERSION}-$ext rm -rf "/usr/local/rust/lib/rustlib/$ext" cp -dR --preserve=timestamps "rust-std-$ext/lib/rustlib/$ext" /usr/local/rust/lib/rustlib/ cd .. done read -p "Keep the downloaded archives? (y/N) " keep_archives if [ ${keep_archives}X = "yX" -o ${keep_archives}X = "YX" ]; then mv $tmpdir/$RUST_FILE $TMPDIR_BASE mv $tmpdir/$RUST_FILE.asc $TMPDIR_BASE mv $tmpdir/$RUSTC_FILE $TMPDIR_BASE mv $tmpdir/$RUSTC_FILE.asc $TMPDIR_BASE for ext in $EXTENSIONS; do tarfile="rust-std-${RUST_VERSION}-$ext.tar.xz" mv $tmpdir/$tarfile $TMPDIR_BASE mv $tmpdir/$tarfile.asc $TMPDIR_BASE done fi rm -rf $tmpdir
Found good info here Non-rustup setups
$ wget https://static.rust-lang.org/dist/rust-std-1.66.0-wasm32-unknown-unknown.tar.xz $ wget https://static.rust-lang.org/dist/rust-std-1.66.0-wasm32-unknown-unknown.tar.xz.asc $ 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 /usr/local/rust # 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/
32-bit
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars32.bat"
64-bit
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
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 #Desired=Unknown/Install/Remove/Purge/Hold #| 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\"
Use #[non_exhaustive] for error enums to avoid API breaks when just adding a new type of error.
Wrapping Unsafe C Libraries in Rust (1/2)
Wrapping Unsafe C Libraries in Rust (2/2)
Tutorial: Generating bzip2 bindings with bindgen at cargo build time in build.rs
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.
rustc --emit=dep-info src/main.rs 2> /dev/null; for file in $(find src/ -name '*.rs'); do grep -q -E "^${file}:$" main.d || echo "$file"; done; rm main.d
~/.cargo/config.toml
[registries.crates-io] protocol = "sparse" [target.x86_64-unknown-linux-gnu] # linker = "clang" # rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold"] rustflags = ["-C", "link-arg=-fuse-ld=mold"] [profile.profiling] inherits = "release" debug = true
To build release with debug info: cargo build –profile profiling