User Tools

Site Tools


general:rust

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
general:rust [2024/09/18 17:03] sunkangeneral:rust [2024/10/30 15:09] (current) – [User cargo config] sunkan
Line 11: Line 11:
  
 ====== Script to update after verifying GPG signatures ====== ====== Script to update after verifying GPG signatures ======
-<code sh>+<code>
 #!/bin/sh #!/bin/sh
  
Line 23: Line 23:
     exit 1     exit 1
 fi fi
 +
 +TMPDIR_BASE=/tmp
  
 RUST_VERSION=$1 RUST_VERSION=$1
Line 29: Line 31:
 RUST_FILE="rust-${RUST_VERSION}-${TARGET}.tar.xz" RUST_FILE="rust-${RUST_VERSION}-${TARGET}.tar.xz"
 RUSTC_FILE="rustc-${RUST_VERSION}-src.tar.xz" RUSTC_FILE="rustc-${RUST_VERSION}-src.tar.xz"
-WASM_FILE="rust-std-${RUST_VERSION}-wasm32-unknown-unknown.tar.xz+ 
-ARMV7HF_FILE="rust-std-${RUST_VERSION}-armv7-unknown-linux-gnueabihf.tar.xz+ARMV7HF_EXT="armv7-unknown-linux-gnueabihf" 
-TMPDIR_BASE=/tmp+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() { create_rust_pgp_key_file() {
Line 111: Line 118:
  
     if [ -f $TMPDIR_BASE/$filename ]; then     if [ -f $TMPDIR_BASE/$filename ]; then
-        mv $TMPDIR_BASE/$filename $dest+ mv $TMPDIR_BASE/$filename $dest
     else     else
-        wget -c $RUST_REPO/$filename+ wget -c $RUST_REPO/$filename
     fi     fi
          
Line 127: Line 134:
 download_if_missing $RUSTC_FILE.asc $tmpdir download_if_missing $RUSTC_FILE.asc $tmpdir
  
-download_if_missing $WASM_FILE $tmpdir +for ext in $EXTENSIONS; do 
-download_if_missing $WASM_FILE.asc $tmpdir+    tarfile="rust-std-${RUST_VERSION}-$ext.tar.xz"
  
-download_if_missing $ARMV7HF_FILE $tmpdir +    download_if_missing $tarfile $tmpdir 
-download_if_missing $ARMV7HF_FILE.asc $tmpdir+    download_if_missing $tarfile.asc $tmpdir 
 +done
  
 create_rust_pgp_key_file create_rust_pgp_key_file
Line 137: Line 145:
 gpgv --keyring ./rust.key $RUST_FILE.asc $RUST_FILE || exit 2 gpgv --keyring ./rust.key $RUST_FILE.asc $RUST_FILE || exit 2
 gpgv --keyring ./rust.key $RUSTC_FILE.asc $RUSTC_FILE || exit 3 gpgv --keyring ./rust.key $RUSTC_FILE.asc $RUSTC_FILE || exit 3
-gpgv --keyring ./rust.key $WASM_FILE.asc $WASM_FILE || exit 4 + 
-gpgv --keyring ./rust.key $ARMV7HF_FILE.asc $ARMV7HF_FILE || exit 5+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 tar xaf $RUST_FILE
Line 153: Line 170:
 cd .. cd ..
  
-tar xaf $WASM_FILE +for ext in $EXTENSIONS; do 
-cd rust-std-${RUST_VERSION}-wasm32-unknown-unknown +    tarfile="rust-std-${RUST_VERSION}-$ext.tar.xz" 
-rm -rf /usr/local/rust/lib/rustlib/wasm32-unknown-unknown +    tar xaf $tarfile 
-cp -dR --preserve=timestamps rust-std-wasm32-unknown-unknown/lib/rustlib/wasm32-unknown-unknown /usr/local/rust/lib/rustlib/ +    cd rust-std-${RUST_VERSION}-$ext 
-cd .. +    rm -rf "/usr/local/rust/lib/rustlib/$ext" 
- +    cp -dR --preserve=timestamps "rust-std-$ext/lib/rustlib/$ext" /usr/local/rust/lib/rustlib/ 
-tar xaf $ARMV7HF_FILE +    cd .. 
-cd rust-std-${RUST_VERSION}-armv7-unknown-linux-gnueabihf +done
-rm -rf /usr/local/rust/lib/rustlib/armv7-unknown-linux-gnueabihf +
-cp -dR --preserve=timestamps rust-std-armv7-unknown-linux-gnueabihf/lib/rustlib/armv7-unknown-linux-gnueabihf /usr/local/rust/lib/rustlib/ +
-cd ..+
  
-read -p "Keep the downloaded archives? (y/n) " keep_archives+read -p "Keep the downloaded archives? (y/N) " keep_archives
  
-if [ $keep_archives = "y" -o $keep_archives = "Y" ]; then+if [ ${keep_archives}X = "yX" -o ${keep_archives}X = "YX" ]; then
     mv $tmpdir/$RUST_FILE $TMPDIR_BASE     mv $tmpdir/$RUST_FILE $TMPDIR_BASE
     mv $tmpdir/$RUST_FILE.asc $TMPDIR_BASE     mv $tmpdir/$RUST_FILE.asc $TMPDIR_BASE
Line 174: Line 188:
     mv $tmpdir/$RUSTC_FILE.asc $TMPDIR_BASE     mv $tmpdir/$RUSTC_FILE.asc $TMPDIR_BASE
  
-    mv $tmpdir/$WASM_FILE $TMPDIR_BASE +    for ext in $EXTENSIONS; do 
-    mv $tmpdir/$WASM_FILE.asc $TMPDIR_BASE+ tarfile="rust-std-${RUST_VERSION}-$ext.tar.xz"
  
-    mv $tmpdir/$ARMV7HF_FILE $TMPDIR_BASE + mv $tmpdir/$tarfile $TMPDIR_BASE 
-    mv $tmpdir/$ARMV7HF_FILE.asc $TMPDIR_BASE+ mv $tmpdir/$tarfile.asc $TMPDIR_BASE 
 +    done
 fi fi
  
Line 263: Line 278:
 </code> </code>
  
-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:+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.
  
 ====== Find unused source files ====== ====== Find unused source files ======
Line 270: Line 285:
 </code> </code>
  
 +====== User cargo config ======
 +~/.cargo/config.toml
 +<code>
 +[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
 +</code>
 +
 +To build release with debug info: ''cargo build --profile profiling''
general/rust.1726678985.txt.gz · Last modified: 2024/09/18 17:03 by sunkan

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