rust

文書の過去の版を表示しています。


Rust 関連

Rust ロゴ
Rust (ラスト) は、性能、メモリ安全性、安全な並行性を目指して設計されたマルチパラダイムのプログラミング言語である。C 言語、C++ に代わるシステムプログラミング言語を目指しており、構文的にはC++に似ているが、「ボローチェッカー」(borrow checker) で参照の有効性を検証することによってメモリ安全性を保証できる。Rust はガベージコレクションなしでのメモリ安全性を達成しており、必要な場面で参照カウントを使うこともできる。
出典: Rust (プログラミング言語) - Wikiwand

本家: Rustプログラミング言語
  Rust の日本語情報
ソースコード: The Rust Programming Language
ドキュメント: Rustを学ぶ/Rustプログラミング言語
       Rustの日本語ドキュメント/Japanese Docs for Rust
       The Rust Programming Language 日本語版 - The Rust Programming Language 日本語版(非公式日本語訳)
       The Rust Programming Language - The Rust Programming Language(公式英語)

Fedora (dnf)

$ sudo dnf install rust cargo

メタデータの期限切れの最終確認: 3:39:05 時間前の 2022年06月13日 08時15分37秒 に実施しました。
依存関係が解決しました。
========================================================================================================================
 パッケージ                       アーキテクチャー        バージョン                     リポジトリー             サイズ
========================================================================================================================
インストール:
 cargo                            x86_64                  1.61.0-2.fc36                  updates                  4.5 M
 rust                             x86_64                  1.61.0-2.fc36                  updates                   26 M
依存関係のインストール:
 rust-std-static                  x86_64                  1.61.0-2.fc36                  updates                   27 M

トランザクションの概要
========================================================================================================================
インストール  3 パッケージ

ダウンロードサイズの合計: 57 M
インストール後のサイズ: 218 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/3): cargo-1.61.0-2.fc36.x86_64.rpm                                                   3.4 MB/s | 4.5 MB     00:01
(2/3): rust-1.61.0-2.fc36.x86_64.rpm                                                    5.0 MB/s |  26 MB     00:05
(3/3): rust-std-static-1.61.0-2.fc36.x86_64.rpm                                         5.1 MB/s |  27 MB     00:05
------------------------------------------------------------------------------------------------------------------------
合計                                                                                     10 MB/s |  57 MB     00:05
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                                                                1/1
  インストール中   : rust-std-static-1.61.0-2.fc36.x86_64                                                           1/3
  インストール中   : rust-1.61.0-2.fc36.x86_64                                                                      2/3
  インストール中   : cargo-1.61.0-2.fc36.x86_64                                                                     3/3
  scriptletの実行中: cargo-1.61.0-2.fc36.x86_64                                                                     3/3
  検証             : cargo-1.61.0-2.fc36.x86_64                                                                     1/3
  検証             : rust-1.61.0-2.fc36.x86_64                                                                      2/3
  検証             : rust-std-static-1.61.0-2.fc36.x86_64                                                           3/3

インストール済み:
  cargo-1.61.0-2.fc36.x86_64          rust-1.61.0-2.fc36.x86_64          rust-std-static-1.61.0-2.fc36.x86_64

完了しました!

動作確認

$ rustc --version
rustc 1.61.0 (Fedora 1.61.0-2.fc36)
$ cargo --version
cargo 1.61.0

Fedora

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

info: downloading installer
warning: it looks like you have an existing installation of Rust at:
warning: /usr/bin
warning: rustup should not be installed alongside Rust. Please uninstall your existing Rust first.
warning: Otherwise you may have confusion unless you are careful with your PATH
warning: If you are sure that you want both rustup and your already installed Rust
warning: then please reply `y' or `yes' or set RUSTUP_INIT_SKIP_PATH_CHECK to yes
warning: or pass `-y' to ignore all ignorable checks.
error: cannot install while Rust is installed

Continue? (y/N) y


Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/tomoyan/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /home/tomoyan/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/tomoyan/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/tomoyan/.profile
  /home/tomoyan/.bash_profile
  /home/tomoyan/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
> Enter で続行

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2022-05-19, rust version 1.61.0 (fe5b13d68 2022-05-18)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 19.7 MiB /  19.7 MiB (100 %)  11.1 MiB/s in  1s ETA:  0s
info: downloading component 'rust-std'
 26.9 MiB /  26.9 MiB (100 %)  11.3 MiB/s in  2s ETA:  0s
info: downloading component 'rustc'
 55.4 MiB /  55.4 MiB (100 %)  11.0 MiB/s in  5s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 19.7 MiB /  19.7 MiB (100 %)   1.5 MiB/s in 14s ETA:  0s
info: installing component 'rust-std'
 26.9 MiB /  26.9 MiB (100 %)  10.4 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 55.4 MiB /  55.4 MiB (100 %)  11.8 MiB/s in  4s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - rustc 1.61.0 (fe5b13d68 2022-05-18)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source $HOME/.cargo/env

warning: it looks like you have an existing installation of Rust at:
warning: /usr/bin
warning: rustup should not be installed alongside Rust. Please uninstall your existing Rust first.
warning: Otherwise you may have confusion unless you are careful with your PATH
warning: If you are sure that you want both rustup and your already installed Rust
warning: then please reply `y' or `yes' or set RUSTUP_INIT_SKIP_PATH_CHECK to yes
warning: or pass `-y' to ignore all ignorable checks.
Rust の既存のインストールがあるようです:
/usr/bin
rustup は Rust と一緒にインストールしないでください。最初に既存の Rust をアンインストールしてください。
そうしないと、PATH に注意しない限り、混乱する可能性があります。
rustup とすでにインストールされているRustの両方が必要な場合は、`y' または `yes' と応答するか、RUSTUP_INIT_SKIP_PATH_CHECK を yes に設定するか、`-y' を渡してすべてのチェックを無視できます。
Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/tomoyan/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /home/tomoyan/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/tomoyan/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/tomoyan/.profile
  /home/tomoyan/.bash_profile
  /home/tomoyan/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Rust へようこそ!

これにより、Rust プログラミング言語の公式コンパイラとそのパッケージマネージャーである Cargo がダウンロードおよびインストールされます。

Rustupメタデータとツールチェーンは、次の場所にあるRustupホームディレクトリにインストールされます。

  /home/tomoyan/.rustup

これは、RUSTUP_HOME 環境変数を使用して変更できます。

次の場所にある Cargo ホームディレクトリ:

  /home/tomoyan/.cargo

これは、CARGO_HOME 環境変数を使用して変更できます。

cargo、rustc、rustup、およびその他のコマンドは、次の場所にある Cargo の bin ディレクトリに追加されます。

  /home/tomoyan/.cargo/bin

このパスは、次の場所にあるプロファイルファイルを変更することにより、PATH 環境変数に追加されます。

  /home/tomoyan/.profile
  /home/tomoyan/.bash_profile
  /home/tomoyan/.bashrc

rustup セルフアンインストールを使用すると、いつでもアンインストールでき、これらの変更は元に戻されます。

.bashrc に自動ロードの設定を追加する。

$ echo 'source $HOME/.cargo/env' >> ~/.bashrc

bash の設定を反映させる。

$ . ~/.bashrc

動作確認

$ rustup --version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.61.0 (fe5b13d68 2022-05-18)`
$ rustc --version
rustc 1.61.0 (fe5b13d68 2022-05-18)
$ cargo --version
cargo 1.61.0 (a028ae4 2022-04-29)

DietPi

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/dietpi/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /home/dietpi/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/dietpi/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/dietpi/.profile
  /home/dietpi/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: arm-unknown-linux-gnueabihf
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
> Enter で続行

info: profile set to 'default'
info: setting default host triple to arm-unknown-linux-gnueabihf
info: syncing channel updates for 'stable-arm-unknown-linux-gnueabihf'
info: latest update on 2022-05-19, rust version 1.61.0 (fe5b13d68 2022-05-18)
info: downloading component 'cargo'
  5.9 MiB /   5.9 MiB (100 %) 570.1 KiB/s in 12s ETA:  0s
info: downloading component 'clippy'
  2.5 MiB /   2.5 MiB (100 %) 567.7 KiB/s in  5s ETA:  0s
info: downloading component 'rust-docs'
 19.7 MiB /  19.7 MiB (100 %) 741.7 KiB/s in 28s ETA:  0s
info: downloading component 'rust-std'
 23.5 MiB /  23.5 MiB (100 %) 666.3 KiB/s in 39s ETA:  0s
info: downloading component 'rustc'
 77.3 MiB /  77.3 MiB (100 %) 647.2 KiB/s in  2m  2s ETA:  0s
info: downloading component 'rustfmt'
  3.5 MiB /   3.5 MiB (100 %) 597.6 KiB/s in  6s ETA:  0s
info: installing component 'cargo'
  5.9 MiB /   5.9 MiB (100 %)   1.5 MiB/s in  4s ETA:  0s
info: installing component 'clippy'
  2.5 MiB /   2.5 MiB (100 %)   1.6 MiB/s in  2s ETA:  0s
info: installing component 'rust-docs'
 19.7 MiB /  19.7 MiB (100 %) 619.2 KiB/s in  1m 38s ETA:  0s
info: installing component 'rust-std'
 23.5 MiB /  23.5 MiB (100 %)   1.3 MiB/s in 19s ETA:  0s
info: installing component 'rustc'
 77.3 MiB /  77.3 MiB (100 %)   1.4 MiB/s in 57s ETA:  0s
info: installing component 'rustfmt'
  3.5 MiB /   3.5 MiB (100 %)   1.6 MiB/s in  2s ETA:  0s
info: default toolchain set to 'stable-arm-unknown-linux-gnueabihf'

  stable-arm-unknown-linux-gnueabihf installed - rustc 1.61.0 (fe5b13d68 2022-05-18)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. This has not been done automatically.

To configure your current shell, run:
source $HOME/.cargo/env

$HOME/.cargo/env
#!/bin/sh
# rustup shell setup
# affix colons on either side of $PATH to simplify matching
case ":${PATH}:" in
    *:"$HOME/.cargo/bin":*)
        ;;
    *)
        # Prepending path in case a system-installed rustc needs to be overridden
        export PATH="$HOME/.cargo/bin:$PATH"
        ;;
esac

.profile に自動ロードの設定を追加する。

$ echo 'source $HOME/.cargo/env' >> ~/.profile

動作確認

$ rustc --version
rustc 1.61.0 (fe5b13d68 2022-05-18)
$ cargo --version
cargo 1.61.0 (a028ae42f 2022-04-29)

$ scoop install rustup

Installing 'rustup' (1.24.3) [64bit]
rustup-init.exe (12.0 MB) [===================================================================================] 100%
Checking hash of rustup-init.exe ... ok.
Running installer script...
info: profile set to 'default'
info: setting default host triple to x86_64-pc-windows-gnu
info: syncing channel updates for 'stable-x86_64-pc-windows-gnu'
info: latest update on 2022-05-19, rust version 1.61.0 (fe5b13d68 2022-05-18)
info: downloading component 'cargo'
  7.0 MiB /   7.0 MiB (100 %)   3.0 MiB/s in  2s ETA:  0s
info: downloading component 'clippy'
  3.3 MiB /   3.3 MiB (100 %)   2.8 MiB/s in  1s ETA:  0s
info: downloading component 'rust-docs'
 19.6 MiB /  19.6 MiB (100 %)   2.4 MiB/s in  7s ETA:  0s
info: downloading component 'rust-mingw'
  4.2 MiB /   4.2 MiB (100 %)   2.8 MiB/s in  2s ETA:  0s
info: downloading component 'rust-std'
 25.3 MiB /  25.3 MiB (100 %)   3.6 MiB/s in  8s ETA:  0s
info: downloading component 'rustc'
 70.1 MiB /  70.1 MiB (100 %)   3.4 MiB/s in 20s ETA:  0s
info: downloading component 'rustfmt'
  6.2 MiB /   6.2 MiB (100 %)   3.1 MiB/s in  2s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 19.6 MiB /  19.6 MiB (100 %) 912.0 KiB/s in 38s ETA:  0s
info: installing component 'rust-mingw'
info: installing component 'rust-std'
 25.3 MiB /  25.3 MiB (100 %)   6.8 MiB/s in  4s ETA:  0s
info: installing component 'rustc'
 70.1 MiB /  70.1 MiB (100 %)   6.8 MiB/s in 10s ETA:  0s
info: installing component 'rustfmt'
  6.2 MiB /   6.2 MiB (100 %)   4.9 MiB/s in  1s ETA:  0s
info: default toolchain set to 'stable-x86_64-pc-windows-gnu'

  stable-x86_64-pc-windows-gnu installed - rustc 1.61.0 (fe5b13d68 2022-05-18)


Rust is installed now. Great!

To get started you need Cargo's bin directory (C:\Users\tomoyan\scoop\persist
\rustup\.cargo\bin) in your PATH
environment variable. This has not been done automatically.
Linking ~\scoop\apps\rustup\current => ~\scoop\apps\rustup\1.24.3
Persisting .cargo
Persisting .rustup
'rustup' (1.24.3) was installed successfully!
Notes
-----
To use the MSVC ABI without Visual Studio 2015 (or higher) installed, you will need the Visual Studio 2017 Build Tools:
https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017

To get started you need Cargo's bin directory (C:\Users\tomoyan\scoop\persist
\rustup\.cargo\bin) in your PATH
environment variable. This has not been done automatically.
開始するには、PATH 環境変数に Cargo の bin ディレクトリ (C:\Users\tomoyan\scoop\persist\rustup\.cargo\bin) が必要です。
これは自動的には行われません。
Notes
-----
To use the MSVC ABI without Visual Studio 2015 (or higher) installed, you will need the Visual Studio 2017 Build Tools:
https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017
Visual Studio 2015 (またはそれ以降) をインストールせずにMSVC ABIを使用するには、Visual Studio 2017ビルドツールが必要です。
https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017

環境変数の設定

$ cat ~\scoop\buckets\main\bucket\rustup.json

{
    "version": "1.24.3",
    "description": "Manage multiple rust installations with ease",
    "homepage": "https://rustup.rs",
    "license": "MIT|Apache-2.0",
    "notes": "To use the MSVC ABI without Visual Studio 2015 (or higher) installed, you will need the Visual Studio 2017 Build Tools: https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017",
    "architecture": {
        "64bit": {
            "url": "https://static.rust-lang.org/rustup/archive/1.24.3/x86_64-pc-windows-gnu/rustup-init.exe",
            "hash": "5a4e8d6193f4239cd81c02350949c73b6ce4ac52839d204f9552a132b552cc41"
        },
        "32bit": {
            "url": "https://static.rust-lang.org/rustup/archive/1.24.3/i686-pc-windows-gnu/rustup-init.exe",
            "hash": "89f529d6e17d688bf5f2c2af25281da504c24830c794564287bf760c0e6e2e9b"
        }
    },
    "installer": {
        "script": [
            "[Environment]::SetEnvironmentVariable('CARGO_HOME', \"$persist_dir\\.cargo\", 'Process')",
            "[Environment]::SetEnvironmentVariable('RUSTUP_HOME', \"$persist_dir\\.rustup\", 'Process')",
            "$host_arch = if ($architecture -eq '64bit') {'x86_64'} else {'i686'}",
            "Invoke-ExternalCommand -Path \"$dir\\rustup-init.exe\" -Args \"-y --no-modify-path --default-host $host_arch-pc-windows-gnu\" | Out-Null"
        ]
    },
    "env_add_path": ".cargo\\bin",
    "env_set": {
        "CARGO_HOME": "$persist_dir\\.cargo",
        "RUSTUP_HOME": "$persist_dir\\.rustup"
    },
    "persist": [
        ".cargo",
        ".rustup"
    ],
    "checkver": {
        "url": "https://raw.githubusercontent.com/rust-lang-nursery/rustup.rs/master/Cargo.toml",
        "regex": "version = \"([\\d.]+)\""
    },
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://static.rust-lang.org/rustup/archive/$version/x86_64-pc-windows-gnu/rustup-init.exe"
            },
            "32bit": {
                "url": "https://static.rust-lang.org/rustup/archive/$version/i686-pc-windows-gnu/rustup-init.exe"
            }
        },
        "hash": {
            "url": "$url.sha256"
        }
    }
}

インストーラはレジストリのPath 環境変数を自動で設定していないので、PowerShell を再起動すると消える🤔
PowerShell を終了する前にレジストリのユーザー環境変数に Path を設定するには以下のコマンドを実行する😉

$ [Environment]::SetEnvironmentVariable('Path', $env:CARGO_HOME + '\bin;' + $env:Path, 'User')


動作確認

$ rustc --version

rustc 1.61.0 (fe5b13d68 2022-05-18)

$ cargo --version

cargo 1.61.0 (a028ae42f 2022-04-29)

ソースコード: mozilla/sccache: sccache is ccache with cloud storage

$ TMPDIR=/var/tmp cargo install sccache

    Updating crates.io index
  Downloaded sccache v0.3.0
  Downloaded 1 crate (272.5 KB) in 0.70s
  Installing sccache v0.3.0
  Downloaded async-trait v0.1.56
  Downloaded crypto-common v0.1.3
  Downloaded ar v0.9.0
  Downloaded digest v0.10.3
  Downloaded bincode v1.3.3
  Downloaded base64 v0.13.0
  Downloaded directories v4.0.1
  Downloaded zstd-safe v3.0.1+zstd.1.4.9
  Downloaded try-lock v0.2.3
  Downloaded hyper v0.14.19
  Downloaded unix_socket v0.5.0
  Downloaded xattr v0.2.3
  Downloaded daemonize v0.4.1
  Downloaded boxfnonce v0.1.1
  Downloaded md5 v0.3.8
  Downloaded language-tags v0.3.2
  Downloaded thiserror-impl v1.0.31
  Downloaded hyperx v1.4.0
  Downloaded openssl-sys v0.9.74
  Downloaded pulldown-cmark v0.0.3
  Downloaded mio v0.8.3
  Downloaded pin-project v1.0.10
  Downloaded openssl-macros v0.1.0
  Downloaded native-tls v0.2.10
  Downloaded bufstream v0.1.4
  Downloaded mime v0.3.16
  Downloaded openssl v0.10.40
  Downloaded getopts v0.2.21
  Downloaded blake3 v0.3.8
  Downloaded retry v1.3.1
  Downloaded redis v0.21.5
  Downloaded spin v0.5.2
  Downloaded tokio-native-tls v0.3.0
  Downloaded vte_generate_state_changes v0.1.1
  Downloaded tokio-serde v0.8.0
  Downloaded skeptic v0.4.0
  Downloaded constant_time_eq v0.1.5
  Downloaded futures-locks v0.7.0
  Downloaded dtoa v0.4.8
  Downloaded hmac v0.12.1
  Downloaded conhash v0.4.0
  Downloaded tokio-util v0.6.10
  Downloaded tower v0.4.12
  Downloaded untrusted v0.7.1
  Downloaded tower-layer v0.3.1
  Downloaded toml v0.5.9
  Downloaded tokio-util v0.7.3
  Downloaded memcached-rs v0.4.2
  Downloaded ipnet v2.5.0
  Downloaded httparse v1.7.1
  Downloaded http v0.2.8
  Downloaded aho-corasick v0.7.18
  Downloaded zstd-sys v1.4.20+zstd.1.4.9
  Downloaded tar v0.4.38
  Downloaded futures-macro v0.3.21
  Downloaded futures-sink v0.3.21
  Downloaded pin-utils v0.1.0
  Downloaded itoa v0.4.8
  Downloaded humantime v2.1.0
  Downloaded semver-parser v0.7.0
  Downloaded rand_chacha v0.2.2
  Downloaded rand_chacha v0.3.1
  Downloaded signal-hook-registry v1.4.0
  Downloaded rand_core v0.6.3
  Downloaded futures-task v0.3.21
  Downloaded foreign-types-shared v0.1.1
  Downloaded want v0.3.0
  Downloaded hyper-tls v0.5.0
  Downloaded slab v0.4.6
  Downloaded strip-ansi-escapes v0.1.1
  Downloaded sha-1 v0.10.0
  Downloaded semver v0.9.0
  Downloaded openssl-probe v0.1.5
  Downloaded tokio-macros v1.8.0
  Downloaded socket2 v0.4.4
  Downloaded flate2 v1.0.24
  Downloaded futures-channel v0.3.21
  Downloaded rand v0.8.5
  Downloaded futures-util v0.3.21
  Downloaded rand v0.7.3
  Downloaded zip v0.5.13
  Downloaded serde_urlencoded v0.7.1
  Downloaded pin-project-internal v1.0.10
  Downloaded rand v0.4.6
  Downloaded bytes v1.1.0
  Downloaded tower-service v0.3.1
  Downloaded thiserror v1.0.31
  Downloaded reqwest v0.11.11
  Downloaded termcolor v1.1.3
  Downloaded httpdate v1.0.2
  Downloaded crc32fast v1.3.2
  Downloaded block-buffer v0.10.2
  Downloaded linked-hash-map v0.5.4
  Downloaded sha2 v0.10.2
  Downloaded jobserver v0.1.24
  Downloaded arrayvec v0.5.2
  Downloaded foreign-types v0.3.2
  Downloaded byteorder v1.4.3
  Downloaded futures-io v0.3.21
  Downloaded futures v0.3.21
  Downloaded rand_core v0.5.1
  Downloaded cfg-if v0.1.10
  Downloaded ppv-lite86 v0.2.16
  Downloaded getrandom v0.1.16
  Downloaded http-body v0.4.5
  Downloaded futures-core v0.3.21
  Downloaded futures-executor v0.3.21
  Downloaded fnv v1.0.7
  Downloaded env_logger v0.9.0
  Downloaded md-5 v0.10.1
  Downloaded counted-array v0.1.2
  Downloaded combine v4.6.4
  Downloaded zstd v0.6.1+zstd.1.4.9
  Downloaded vte v0.10.1
  Downloaded local-encoding v0.2.0
  Downloaded crypto-mac v0.8.0
  Downloaded number_prefix v0.4.0
  Downloaded h2 v0.3.13
  Downloaded arrayref v0.3.6
  Downloaded tempdir v0.3.7
  Downloaded tokio v1.19.2
  Downloaded encoding_rs v0.8.31
  Downloaded ring v0.16.20
  Downloaded 123 crates (13.1 MB) in 3.04s (largest was `ring` at 5.1 MB)
  Downloaded parity-tokio-ipc v0.9.0
  Downloaded 1 crate (15.9 KB) in 0.36s
  Downloaded winapi v0.3.9
  Downloaded 1 crate (1.2 MB) in 0.37s
   Compiling libc v0.2.126
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.39
   Compiling unicode-ident v1.0.1
   Compiling syn v1.0.96
   Compiling autocfg v1.1.0
   Compiling log v0.4.17
   Compiling memchr v2.5.0
   Compiling once_cell v1.12.0
   Compiling version_check v0.9.4
   Compiling pin-project-lite v0.2.9
   Compiling futures-core v0.3.21
   Compiling bytes v1.1.0
   Compiling futures-sink v0.3.21
   Compiling typenum v1.15.0
   Compiling futures-channel v0.3.21
   Compiling futures-task v0.3.21
   Compiling pkg-config v0.3.25
   Compiling futures-util v0.3.21
   Compiling itoa v1.0.2
   Compiling pin-utils v0.1.0
   Compiling futures-io v0.3.21
   Compiling slab v0.4.6
   Compiling openssl v0.10.40
   Compiling serde v1.0.137
   Compiling bitflags v1.3.2
   Compiling fnv v1.0.7
   Compiling foreign-types-shared v0.1.1
   Compiling subtle v2.4.1
   Compiling getrandom v0.1.16
   Compiling percent-encoding v2.1.0
   Compiling matches v0.1.9
   Compiling ppv-lite86 v0.2.16
   Compiling native-tls v0.2.10
   Compiling tinyvec_macros v0.1.0
   Compiling unicode-width v0.1.9
   Compiling remove_dir_all v0.5.3
   Compiling httparse v1.7.1
   Compiling openssl-probe v0.1.5
   Compiling hashbrown v0.11.2
   Compiling tower-service v0.3.1
   Compiling unicode-bidi v0.3.8
   Compiling httpdate v1.0.2
   Compiling try-lock v0.2.3
   Compiling crc32fast v1.3.2
   Compiling arrayvec v0.5.2
   Compiling encoding_rs v0.8.31
   Compiling zstd-safe v3.0.1+zstd.1.4.9
   Compiling ryu v1.0.10
   Compiling serde_json v1.0.81
   Compiling cfg-if v0.1.10
   Compiling async-trait v0.1.56
   Compiling byteorder v1.4.3
   Compiling utf8parse v0.2.0
   Compiling adler v1.0.2
   Compiling semver-parser v0.7.0
   Compiling cpufeatures v0.2.2
   Compiling anyhow v1.0.57
   Compiling mime v0.3.16
   Compiling regex-syntax v0.6.26
   Compiling hyperx v1.4.0
   Compiling serde_derive v1.0.137
   Compiling md5 v0.3.8
   Compiling base64 v0.13.0
   Compiling ipnet v2.5.0
   Compiling termcolor v1.1.3
   Compiling same-file v1.0.6
   Compiling untrusted v0.7.1
   Compiling boxfnonce v0.1.1
   Compiling lazy_static v1.4.0
   Compiling constant_time_eq v0.1.5
   Compiling tower-layer v0.3.1
   Compiling fastrand v1.7.0
   Compiling itoa v0.4.8
   Compiling bufstream v0.1.4
   Compiling strsim v0.8.0
   Compiling ansi_term v0.12.1
   Compiling arrayref v0.3.6
   Compiling either v1.6.1
   Compiling dtoa v0.4.8
   Compiling humantime v2.1.0
   Compiling vec_map v0.8.2
   Compiling spin v0.5.2
   Compiling language-tags v0.3.2
   Compiling linked-hash-map v0.5.4
   Compiling counted-array v0.1.2
   Compiling number_prefix v0.4.0
   Compiling ar v0.9.0
   Compiling indexmap v1.8.2
   Compiling num-traits v0.2.15
   Compiling num-integer v0.1.45
   Compiling tracing-core v0.1.27
   Compiling generic-array v0.14.5
   Compiling unicase v2.6.0
   Compiling http v0.2.8
   Compiling foreign-types v0.3.2
   Compiling form_urlencoded v1.0.1
   Compiling tinyvec v1.6.0
   Compiling getopts v0.2.21
   Compiling textwrap v0.11.0
   Compiling miniz_oxide v0.5.3
   Compiling semver v0.9.0
   Compiling walkdir v2.3.2
   Compiling http-body v0.4.5
   Compiling unicode-normalization v0.1.19
   Compiling pulldown-cmark v0.0.3
   Compiling quote v1.0.18
   Compiling num_cpus v1.13.1
   Compiling signal-hook-registry v1.4.0
   Compiling socket2 v0.4.4
   Compiling getrandom v0.2.7
   Compiling atty v0.2.14
   Compiling time v0.1.44
   Compiling unix_socket v0.5.0
   Compiling dirs-sys v0.3.7
   Compiling xattr v0.2.3
   Compiling filetime v0.2.16
   Compiling tempfile v3.3.0
   Compiling jobserver v0.1.24
   Compiling daemonize v0.4.1
   Compiling which v4.2.5
   Compiling rand v0.4.6
   Compiling mio v0.8.3
   Compiling tracing v0.1.35
   Compiling want v0.3.0
   Compiling conhash v0.4.0
   Compiling aho-corasick v0.7.18
   Compiling idna v0.2.3
   Compiling serde_urlencoded v0.7.1
   Compiling bincode v1.3.3
   Compiling toml v0.5.9
   Compiling flate2 v1.0.24
   Compiling vte_generate_state_changes v0.1.1
   Compiling rand_core v0.6.3
   Compiling uuid v0.8.2
   Compiling rand_core v0.5.1
   Compiling clap v2.34.0
   Compiling directories v4.0.1
   Compiling tar v0.4.38
   Compiling cc v1.0.73
   Compiling tempdir v0.3.7
   Compiling tower v0.4.12
   Compiling regex v1.5.6
   Compiling crypto-common v0.1.3
   Compiling block-buffer v0.10.2
   Compiling digest v0.9.0
   Compiling crypto-mac v0.8.0
   Compiling url v2.2.2
   Compiling vte v0.10.1
   Compiling rand_chacha v0.3.1
   Compiling rand_chacha v0.2.2
   Compiling tokio-macros v1.8.0
   Compiling futures-macro v0.3.21
   Compiling openssl-macros v0.1.0
   Compiling thiserror-impl v1.0.31
   Compiling pin-project-internal v1.0.10
   Compiling openssl-sys v0.9.74
   Compiling zstd-sys v1.4.20+zstd.1.4.9
   Compiling blake3 v0.3.8
   Compiling ring v0.16.20
   Compiling skeptic v0.4.0
   Compiling chrono v0.4.19
   Compiling env_logger v0.9.0
   Compiling digest v0.10.3
   Compiling strip-ansi-escapes v0.1.1
   Compiling rand v0.8.5
   Compiling rand v0.7.3
   Compiling tokio v1.19.2
   Compiling thiserror v1.0.31
   Compiling pin-project v1.0.10
   Compiling local-encoding v0.2.0
   Compiling md-5 v0.10.1
   Compiling hmac v0.12.1
   Compiling sha-1 v0.10.0
   Compiling sha2 v0.10.2
   Compiling retry v1.3.1
   Compiling memcached-rs v0.4.2
   Compiling futures-executor v0.3.21
   Compiling tokio-util v0.7.3
   Compiling tokio-util v0.6.10
   Compiling futures-locks v0.7.0
   Compiling zip v0.5.13
   Compiling tokio-serde v0.8.0
   Compiling futures v0.3.21
   Compiling h2 v0.3.13
   Compiling combine v4.6.4
   Compiling hyper v0.14.19
   Compiling tokio-native-tls v0.3.0
   Compiling hyper-tls v0.5.0
   Compiling redis v0.21.5
   Compiling reqwest v0.11.11
   Compiling zstd v0.6.1+zstd.1.4.9
   Compiling sccache v0.3.0
    Finished release [optimized] target(s) in 5m 56s
  Installing /home/tomoyan/.cargo/bin/sccache
   Installed package `sccache v0.3.0` (executable `sccache`)

動作確認

$ sccache -h

sccache 0.3.0

USAGE:
    sccache [FLAGS] [OPTIONS] [cmd]...

FLAGS:
        --dist-auth       authenticate for distributed compilation
        --dist-status     show status of the distributed client
    -h, --help            Prints help information
    -s, --show-stats      show cache statistics
        --start-server    start background server
        --stop-server     stop background server
    -V, --version         Prints version information
    -z, --zero-stats      zero statistics counters

OPTIONS:
        --package-toolchain      package toolchain for distributed compilation
        --stats-format 
            set output format of statistics [default: text]  [possible values: text, json]


ARGS:
    ...

Enabled features:
    S3:        true
    Redis:     true
    Memcached: true
    GCS:       true
    Azure:     true

Rust の Cargo から sccache を利用するには RUSTC_WRAPPER 環境変数を設定する😉

$ echo 'export RUSTC_WRAPPER=$(which sccache)' >> .bashrc
$ . .bashrc
$ echo $RUSTC_WRAPPER

/home/tomoyan/.cargo/bin/sccache

または、

$ echo 'export RUSTC_WRAPPER=$(which sccache)' >> .profile
$ . .profile
$ echo $RUSTC_WRAPPER

/home/dietpi/.cargo/bin/sccache

sccache の統計情報を表示する🤔

$ sccache -s

Compile requests                      0
Compile requests executed             0
Cache hits                            0
Cache misses                          0
Cache timeouts                        0
Cache read errors                     0
Forced recaches                       0
Cache write errors                    0
Compilation failures                  0
Cache errors                          0
Non-cacheable compilations            0
Non-cacheable calls                   0
Non-compilation calls                 0
Unsupported compiler calls            0
Average cache write               0.000 s
Average cache read miss           0.000 s
Average cache read hit            0.000 s
Failed distributed compilations       0
Cache location                  Local disk: "/home/tomoyan/.cache/sccache"

evcxr/evcxr_repl at main · google/evcxr

$ rustup component add rust-src

info: downloading component 'rust-src'
info: installing component 'rust-src'

$ TMPDIR=/var/tmp cargo install evcxr_repl

    Updating crates.io index
  Downloaded evcxr_repl v0.12.0
  Downloaded 1 crate (30.7 KB) in 0.82s
  Installing evcxr_repl v0.12.0
  Downloaded endian-type v0.1.2
  Downloaded addr2line v0.17.0
  Downloaded ena v0.14.0
  Downloaded drop_bomb v0.1.5
  Downloaded ra_ap_project_model v0.0.76
  Downloaded evcxr v0.12.0
  Downloaded dot v0.1.4
  Downloaded expect-test v1.3.0
  Downloaded rustc-hash v1.1.0
  Downloaded rustyline v9.1.2
  Downloaded rustix v0.34.8
  Downloaded ryu v1.0.10
  Downloaded notify v5.0.0-pre.13
  Downloaded ra_ap_cfg v0.0.76
  Downloaded ra_ap_base_db v0.0.76
  Downloaded pulldown-cmark-to-cmark v6.0.4
  Downloaded perf-event-open-sys v1.0.1
  Downloaded ra_ap_hir v0.0.76
  Downloaded rustc-demangle v0.1.21
  Downloaded mimalloc v0.1.29
  Downloaded jod-thread v0.1.2
  Downloaded inotify-sys v0.1.5
  Downloaded ra_ap_hir_def v0.0.76
  Downloaded ra_ap_hir_expand v0.0.76
  Downloaded ra_ap_ide_completion v0.0.76
  Downloaded ra_ap_ide_db v0.0.76
  Downloaded always-assert v0.1.2
  Downloaded anyhow v1.0.57
  Downloaded salsa v0.17.0-pre.1
  Downloaded tracing-attributes v0.1.21
  Downloaded chalk-recursive v0.71.0
  Downloaded chalk-ir v0.71.0
  Downloaded cargo_metadata v0.14.2
  Downloaded which v4.2.5
  Downloaded unicode-xid v0.2.3
  Downloaded camino v1.0.9
  Downloaded text-size v1.1.0
  Downloaded smol_str v0.1.23
  Downloaded salsa-macros v0.17.0-pre.2
  Downloaded cargo-platform v0.1.2
  Downloaded arrayvec v0.7.2
  Downloaded clap v2.34.0
  Downloaded chalk-solve v0.71.0
  Downloaded ra_ap_hir_ty v0.0.76
  Downloaded crossbeam-channel v0.5.4
  Downloaded ra_ap_ide_diagnostics v0.0.76
  Downloaded crossbeam-deque v0.8.1
  Downloaded cov-mark v2.0.0-pre.1
  Downloaded crossbeam-epoch v0.9.8
  Downloaded countme v2.0.4
  Downloaded crossbeam-utils v0.8.8
  Downloaded dashmap v4.0.2
  Downloaded dirs-sys v0.3.7
  Downloaded dirs v3.0.2
  Downloaded fastrand v1.7.0
  Downloaded evcxr_input v1.0.0
  Downloaded ra_ap_la-arena v0.0.76
  Downloaded ra_ap_ide_assists v0.0.76
  Downloaded memoffset v0.6.5
  Downloaded json v0.12.4
  Downloaded ra_ap_ide v0.0.76
  Downloaded ra_ap_limit v0.0.76
  Downloaded ra_ap_ide_ssr v0.0.76
  Downloaded ra_ap_mbe v0.0.76
  Downloaded ra_ap_paths v0.0.76
  Downloaded ra_ap_parser v0.0.76
  Downloaded ra_ap_test_utils v0.0.76
  Downloaded ra_ap_vfs v0.0.76
  Downloaded ra_ap_toolchain v0.0.76
  Downloaded filetime v0.2.16
  Downloaded lazy_static v1.4.0
  Downloaded instant v0.1.12
  Downloaded matches v0.1.9
  Downloaded form_urlencoded v1.0.1
  Downloaded fixedbitset v0.2.0
  Downloaded num_cpus v1.13.1
  Downloaded radix_trie v0.2.1
  Downloaded ra_ap_vfs-notify v0.0.76
  Downloaded scopeguard v1.1.0
  Downloaded same-file v1.0.6
  Downloaded ra_ap_stdx v0.0.76
  Downloaded percent-encoding v2.1.0
  Downloaded ra_ap_tt v0.0.76
  Downloaded adler v1.0.2
  Downloaded dirs-sys-next v0.1.2
  Downloaded strsim v0.8.0
  Downloaded cfg-if v1.0.0
  Downloaded atty v0.2.14
  Downloaded tinyvec_macros v0.1.0
  Downloaded either v1.6.1
  Downloaded dirs-next v2.0.0
  Downloaded itoa v1.0.2
  Downloaded ra_ap_text_edit v0.0.76
  Downloaded ra_ap_profile v0.0.76
  Downloaded vec_map v0.8.2
  Downloaded proc-macro-error-attr v1.0.4
  Downloaded remove_dir_all v0.5.3
  Downloaded rustc-ap-rustc_lexer v725.0.0
  Downloaded semver v1.0.10
  Downloaded serde_derive v1.0.137
  Downloaded structopt v0.3.26
  Downloaded textwrap v0.11.0
  Downloaded synstructure v0.12.6
  Downloaded structopt-derive v0.4.18
  Downloaded serde_json v1.0.81
  Downloaded unicase v2.6.0
  Downloaded serde v1.0.137
  Downloaded smallvec v1.8.0
  Downloaded tempfile v3.3.0
  Downloaded tinyvec v1.6.0
  Downloaded version_check v0.9.4
  Downloaded unicode-width v0.1.9
  Downloaded unicode-ident v1.0.0
  Downloaded url v2.2.2
  Downloaded unicode-normalization v0.1.19
  Downloaded oorandom v11.1.3
  Downloaded walkdir v2.3.2
  Downloaded unicode-segmentation v1.9.0
  Downloaded utf8parse v0.2.0
  Downloaded scoped-tls v1.0.0
  Downloaded unicode-bidi v0.3.8
  Downloaded pulldown-cmark v0.8.0
  Downloaded chalk-derive v0.71.0
  Downloaded anymap v0.12.1
  Downloaded fd-lock v3.0.5
  Downloaded libloading v0.7.3
  Downloaded tracing v0.1.35
  Downloaded log v0.4.17
  Downloaded once_cell v1.12.0
  Downloaded rayon-core v1.9.3
  Downloaded parking_lot_core v0.8.5
  Downloaded parking_lot v0.11.2
  Downloaded memchr v2.5.0
  Downloaded lock_api v0.4.7
  Downloaded dissimilar v1.0.4
  Downloaded regex v1.5.6
  Downloaded pin-project-lite v0.2.9
  Downloaded rayon v1.5.3
  Downloaded ansi_term v0.12.1
  Downloaded quote v1.0.18
  Downloaded proc-macro-error v1.0.4
  Downloaded petgraph v0.5.1
  Downloaded proc-macro2 v1.0.39
  Downloaded indexmap v1.8.2
  Downloaded io-lifetimes v0.6.1
  Downloaded bitflags v1.3.2
  Downloaded hashbrown v0.11.2
  Downloaded nibble_vec v0.1.0
  Downloaded miniz_oxide v0.5.3
  Downloaded autocfg v1.1.0
  Downloaded syn v1.0.96
  Downloaded tracing-core v0.1.27
  Downloaded sig v1.0.0
  Downloaded regex-syntax v0.6.26
  Downloaded backtrace v0.3.65
  Downloaded cc v1.0.73
  Downloaded mio v0.7.14
  Downloaded rowan v0.14.1
  Downloaded itertools v0.10.3
  Downloaded object v0.28.4
  Downloaded nix v0.23.1
  Downloaded idna v0.2.3
  Downloaded home v0.5.3
  Downloaded inotify v0.9.6
  Downloaded ra_ap_syntax v0.0.76
  Downloaded perf-event v0.4.7
  Downloaded heck v0.3.3
  Downloaded colored v2.0.0
  Downloaded libc v0.2.126
  Downloaded gimli v0.26.1
  Downloaded linux-raw-sys v0.0.46
  Downloaded libmimalloc-sys v0.1.25
  Downloaded fst v0.4.7
  Downloaded 173 crates (13.2 MB) in 3.47s (largest was `fst` at 1.6 MB)
   Compiling libc v0.2.126
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.39
   Compiling unicode-ident v1.0.0
   Compiling autocfg v1.1.0
   Compiling syn v1.0.96
   Compiling log v0.4.17
   Compiling lazy_static v1.4.0
   Compiling serde_derive v1.0.137
   Compiling serde v1.0.137
   Compiling rustc-hash v1.1.0
   Compiling once_cell v1.12.0
   Compiling hashbrown v0.11.2
   Compiling crossbeam-utils v0.8.8
   Compiling bitflags v1.3.2
   Compiling smallvec v1.8.0
   Compiling either v1.6.1
   Compiling scopeguard v1.1.0
   Compiling unicode-segmentation v1.9.0
   Compiling text-size v1.1.0
   Compiling parking_lot_core v0.8.5
   Compiling fst v0.4.7
   Compiling ra_ap_la-arena v0.0.76
   Compiling pin-project-lite v0.2.9
   Compiling dissimilar v1.0.4
   Compiling unicode-xid v0.2.3
   Compiling drop_bomb v0.1.5
   Compiling version_check v0.9.4
   Compiling ra_ap_paths v0.0.76
   Compiling cov-mark v2.0.0-pre.1
   Compiling oorandom v11.1.3
   Compiling fixedbitset v0.2.0
   Compiling ra_ap_limit v0.0.76
   Compiling rayon-core v1.9.3
   Compiling anymap v0.12.1
   Compiling arrayvec v0.7.2
   Compiling scoped-tls v1.0.0
   Compiling memchr v2.5.0
   Compiling cc v1.0.73
   Compiling tinyvec_macros v0.1.0
   Compiling matches v0.1.9
   Compiling serde_json v1.0.81
   Compiling camino v1.0.9
   Compiling semver v1.0.10
   Compiling pulldown-cmark v0.8.0
   Compiling io-lifetimes v0.6.1
   Compiling percent-encoding v2.1.0
   Compiling anyhow v1.0.57
   Compiling itoa v1.0.2
   Compiling rustix v0.34.8
   Compiling ryu v1.0.10
   Compiling unicode-width v0.1.9
   Compiling unicode-bidi v0.3.8
   Compiling same-file v1.0.6
   Compiling gimli v0.26.1
   Compiling adler v1.0.2
   Compiling linux-raw-sys v0.0.46
   Compiling home v0.5.3
   Compiling strsim v0.8.0
   Compiling jod-thread v0.1.2
   Compiling ansi_term v0.12.1
   Compiling vec_map v0.8.2
   Compiling dot v0.1.4
   Compiling endian-type v0.1.2
   Compiling rustc-demangle v0.1.21
   Compiling regex-syntax v0.6.26
   Compiling fastrand v1.7.0
   Compiling remove_dir_all v0.5.3
   Compiling json v0.12.4
   Compiling utf8parse v0.2.0
   Compiling evcxr_input v1.0.0
   Compiling instant v0.1.12
   Compiling libloading v0.7.3
   Compiling memoffset v0.6.5
   Compiling indexmap v1.8.2
   Compiling lock_api v0.4.7
   Compiling crossbeam-epoch v0.9.8
   Compiling rayon v1.5.3
   Compiling tracing-core v0.1.27
   Compiling nibble_vec v0.1.0
   Compiling itertools v0.10.3
   Compiling ra_ap_text_edit v0.0.76
   Compiling heck v0.3.3
   Compiling rustc-ap-rustc_lexer v725.0.0
   Compiling ra_ap_parser v0.0.76
   Compiling expect-test v1.3.0
   Compiling unicase v2.6.0
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-macro-error v1.0.4
   Compiling tinyvec v1.6.0
   Compiling backtrace v0.3.65
   Compiling libmimalloc-sys v0.1.25
   Compiling form_urlencoded v1.0.1
   Compiling textwrap v0.11.0
   Compiling walkdir v2.3.2
   Compiling miniz_oxide v0.5.3
   Compiling addr2line v0.17.0
   Compiling ra_ap_toolchain v0.0.76
   Compiling regex v1.5.6
   Compiling radix_trie v0.2.1
   Compiling unicode-normalization v0.1.19
   Compiling num_cpus v1.13.1
   Compiling perf-event-open-sys v1.0.1
   Compiling inotify-sys v0.1.5
   Compiling atty v0.2.14
   Compiling filetime v0.2.16
   Compiling dirs-sys-next v0.1.2
   Compiling dirs-sys v0.3.7
   Compiling sig v1.0.0
   Compiling which v4.2.5
   Compiling tempfile v3.3.0
   Compiling quote v1.0.18
   Compiling always-assert v0.1.2
   Compiling ena v0.14.0
   Compiling mio v0.7.14
   Compiling crossbeam-channel v0.5.4
   Compiling object v0.28.4
   Compiling idna v0.2.3
   Compiling dashmap v4.0.2
   Compiling perf-event v0.4.7
   Compiling inotify v0.9.6
   Compiling clap v2.34.0
   Compiling colored v2.0.0
   Compiling dirs v3.0.2
   Compiling dirs-next v2.0.0
   Compiling nix v0.23.1
   Compiling parking_lot v0.11.2
   Compiling ra_ap_stdx v0.0.76
   Compiling ra_ap_vfs v0.0.76
   Compiling petgraph v0.5.1
   Compiling fd-lock v3.0.5
   Compiling url v2.2.2
   Compiling mimalloc v0.1.29
   Compiling countme v2.0.4
   Compiling notify v5.0.0-pre.13
   Compiling synstructure v0.12.6
   Compiling tracing-attributes v0.1.21
   Compiling salsa-macros v0.17.0-pre.2
   Compiling crossbeam-deque v0.8.1
   Compiling pulldown-cmark-to-cmark v6.0.4
   Compiling rustyline v9.1.2
   Compiling ra_ap_profile v0.0.76
   Compiling rowan v0.14.1
   Compiling chalk-derive v0.71.0
   Compiling salsa v0.17.0-pre.1
   Compiling tracing v0.1.35
   Compiling structopt-derive v0.4.18
   Compiling ra_ap_test_utils v0.0.76
   Compiling chalk-ir v0.71.0
   Compiling smol_str v0.1.23
   Compiling cargo-platform v0.1.2
   Compiling ra_ap_vfs-notify v0.0.76
   Compiling structopt v0.3.26
   Compiling chalk-solve v0.71.0
   Compiling ra_ap_tt v0.0.76
   Compiling ra_ap_syntax v0.0.76
   Compiling cargo_metadata v0.14.2
   Compiling ra_ap_cfg v0.0.76
   Compiling chalk-recursive v0.71.0
   Compiling ra_ap_mbe v0.0.76
   Compiling ra_ap_base_db v0.0.76
   Compiling ra_ap_hir_expand v0.0.76
   Compiling ra_ap_project_model v0.0.76
   Compiling ra_ap_hir_def v0.0.76
   Compiling ra_ap_hir_ty v0.0.76
   Compiling ra_ap_hir v0.0.76
   Compiling ra_ap_ide_db v0.0.76
   Compiling ra_ap_ide_diagnostics v0.0.76
   Compiling ra_ap_ide_assists v0.0.76
   Compiling ra_ap_ide_completion v0.0.76
   Compiling ra_ap_ide_ssr v0.0.76
   Compiling ra_ap_ide v0.0.76
   Compiling evcxr v0.12.0
   Compiling evcxr_repl v0.12.0
    Finished release [optimized] target(s) in 7m 59s
  Installing /home/tomoyan/.cargo/bin/evcxr
   Installed package `evcxr_repl v0.12.0` (executable `evcxr`)

evcxr/evcxr_jupyter at main · google/evcxr

$ TMPDIR=/var/tmp cargo install evcxr_jupyter

    Updating crates.io index
  Installing evcxr_jupyter v0.12.0
  Downloaded getrandom v0.2.7
  Downloaded 1 crate (28.9 KB) in 0.64s
   Compiling libc v0.2.126
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling proc-macro2 v1.0.39
   Compiling unicode-ident v1.0.1
   Compiling syn v1.0.96
   Compiling log v0.4.17
   Compiling serde_derive v1.0.137
   Compiling lazy_static v1.4.0
   Compiling once_cell v1.12.0
   Compiling rustc-hash v1.1.0
   Compiling serde v1.0.137
   Compiling hashbrown v0.11.2
   Compiling crossbeam-utils v0.8.8
   Compiling either v1.6.1
   Compiling scopeguard v1.1.0
   Compiling bitflags v1.3.2
   Compiling text-size v1.1.0
   Compiling parking_lot_core v0.8.5
   Compiling pin-project-lite v0.2.9
   Compiling ra_ap_la-arena v0.0.76
   Compiling smallvec v1.8.0
   Compiling fst v0.4.7
   Compiling unicode-segmentation v1.9.0
   Compiling unicode-xid v0.2.3
   Compiling dissimilar v1.0.4
   Compiling drop_bomb v0.1.5
   Compiling ra_ap_paths v0.0.76
   Compiling cov-mark v2.0.0-pre.1
   Compiling cc v1.0.73
   Compiling version_check v0.9.4
   Compiling oorandom v11.1.3
   Compiling fixedbitset v0.2.0
   Compiling rayon-core v1.9.3
   Compiling ra_ap_limit v0.0.76
   Compiling anymap v0.12.1
   Compiling scoped-tls v1.0.0
   Compiling arrayvec v0.7.2
   Compiling memchr v2.5.0
   Compiling typenum v1.15.0
   Compiling pkg-config v0.3.25
   Compiling toml v0.2.1
   Compiling error-chain v0.10.0
   Compiling tinyvec_macros v0.1.0
   Compiling serde_json v1.0.81
   Compiling pulldown-cmark v0.8.0
   Compiling matches v0.1.9
   Compiling camino v1.0.9
   Compiling semver v1.0.10
   Compiling same-file v1.0.6
   Compiling percent-encoding v2.1.0
   Compiling ryu v1.0.10
   Compiling itoa v1.0.2
   Compiling anyhow v1.0.57
   Compiling unicode-bidi v0.3.8
   Compiling adler v1.0.2
   Compiling gimli v0.26.1
   Compiling home v0.5.3
   Compiling fastrand v1.7.0
   Compiling jod-thread v0.1.2
   Compiling regex-syntax v0.6.26
   Compiling zmq v0.9.2
   Compiling subtle v2.4.1
   Compiling rustc-demangle v0.1.21
   Compiling remove_dir_all v0.5.3
   Compiling dot v0.1.4
   Compiling cpufeatures v0.2.2
   Compiling evcxr_input v1.0.0
   Compiling opaque-debug v0.3.0
   Compiling json v0.12.4
   Compiling hex v0.4.3
   Compiling instant v0.1.12
   Compiling libloading v0.7.3
   Compiling indexmap v1.8.2
   Compiling memoffset v0.6.5
   Compiling lock_api v0.4.7
   Compiling crossbeam-epoch v0.9.8
   Compiling rayon v1.5.3
   Compiling num-traits v0.2.15
   Compiling num-integer v0.1.45
   Compiling tracing-core v0.1.27
   Compiling itertools v0.10.3
   Compiling ra_ap_text_edit v0.0.76
   Compiling rustc-ap-rustc_lexer v725.0.0
   Compiling heck v0.3.3
   Compiling ra_ap_parser v0.0.76
   Compiling expect-test v1.3.0
   Compiling cmake v0.1.48
   Compiling generic-array v0.14.5
   Compiling unicase v2.6.0
   Compiling libmimalloc-sys v0.1.25
   Compiling backtrace v0.3.65
   Compiling metadeps v1.1.2
   Compiling tinyvec v1.6.0
   Compiling walkdir v2.3.2
   Compiling form_urlencoded v1.0.1
   Compiling miniz_oxide v0.5.3
   Compiling ra_ap_toolchain v0.0.76
   Compiling addr2line v0.17.0
   Compiling regex v1.5.6
   Compiling zeromq-src v0.1.10+4.3.2
   Compiling unicode-normalization v0.1.19
   Compiling num_cpus v1.13.1
   Compiling perf-event-open-sys v1.0.1
   Compiling inotify-sys v0.1.5
   Compiling filetime v0.2.16
   Compiling dirs-sys v0.3.7
   Compiling time v0.1.44
   Compiling atty v0.2.14
   Compiling sig v1.0.0
   Compiling which v4.2.5
   Compiling tempfile v3.3.0
   Compiling getrandom v0.2.7
   Compiling quote v1.0.18
   Compiling always-assert v0.1.2
   Compiling ena v0.14.0
   Compiling mio v0.7.14
   Compiling crossbeam-channel v0.5.4
   Compiling zmq-sys v0.11.0
   Compiling object v0.28.4
   Compiling idna v0.2.3
   Compiling dashmap v4.0.2
   Compiling perf-event v0.4.7
   Compiling inotify v0.9.6
   Compiling dirs v3.0.2
   Compiling colored v2.0.0
   Compiling uuid v0.8.2
   Compiling ra_ap_vfs v0.0.76
   Compiling petgraph v0.5.1
   Compiling parking_lot v0.11.2
   Compiling ra_ap_stdx v0.0.76
   Compiling mimalloc v0.1.29
   Compiling digest v0.9.0
   Compiling crypto-mac v0.11.1
   Compiling block-buffer v0.9.0
   Compiling url v2.2.2
   Compiling countme v2.0.4
   Compiling notify v5.0.0-pre.13
   Compiling crossbeam-deque v0.8.1
   Compiling chrono v0.4.19
   Compiling synstructure v0.12.6
   Compiling tracing-attributes v0.1.21
   Compiling salsa-macros v0.17.0-pre.2
   Compiling pulldown-cmark-to-cmark v6.0.4
   Compiling hmac v0.11.0
   Compiling sha2 v0.9.9
   Compiling ra_ap_profile v0.0.76
   Compiling rowan v0.14.1
   Compiling chalk-derive v0.71.0
   Compiling tracing v0.1.35
   Compiling salsa v0.17.0-pre.1
   Compiling ra_ap_test_utils v0.0.76
   Compiling ra_ap_vfs-notify v0.0.76
   Compiling chalk-ir v0.71.0
   Compiling smol_str v0.1.23
   Compiling cargo-platform v0.1.2
   Compiling chalk-solve v0.71.0
   Compiling ra_ap_tt v0.0.76
   Compiling ra_ap_syntax v0.0.76
   Compiling cargo_metadata v0.14.2
   Compiling ra_ap_cfg v0.0.76
   Compiling chalk-recursive v0.71.0
   Compiling ra_ap_mbe v0.0.76
   Compiling ra_ap_base_db v0.0.76
   Compiling ra_ap_hir_expand v0.0.76
   Compiling ra_ap_project_model v0.0.76
   Compiling ra_ap_hir_def v0.0.76
   Compiling ra_ap_hir_ty v0.0.76
   Compiling ra_ap_hir v0.0.76
   Compiling ra_ap_ide_db v0.0.76
   Compiling ra_ap_ide_completion v0.0.76
   Compiling ra_ap_ide_ssr v0.0.76
   Compiling ra_ap_ide_diagnostics v0.0.76
   Compiling ra_ap_ide_assists v0.0.76
   Compiling ra_ap_ide v0.0.76
   Compiling evcxr v0.12.0
   Compiling evcxr_jupyter v0.12.0
    Finished release [optimized] target(s) in 8m 03s
   Installing /home/tomoyan/.cargo/bin/evcxr_jupyter
    Installed package `evcxr_jupyter v0.12.0` with `evcxr_jupyter v0.12.0` (executable `evcxr_jupyter`)

$ evcxr_jupyter --install
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/kernel.json
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/logo-32x32.png
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/logo-64x64.png
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/logo-LICENSE.md
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/kernel.js
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/lint.js
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/lint.css
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/lint-LICENSE
Writing /home/tomoyan/.local/share/jupyter/kernels/rust/version.txt
Installation complete
$ cargo install sccache

    Updating crates.io index
  Downloaded sccache v0.3.0
  Downloaded 1 crate (272.5 KB) in 2.44s
  Installing sccache v0.3.0
  Downloaded async-trait v0.1.56
  ...
   Compiling local-encoding v0.2.0
   Compiling tokio v1.19.2
error: failed to write /tmp/cargo-installcx83Fu/release/deps/rmetaqzpZIF/lib.rmeta: No space left on device (os error 28)

error: could not compile `tokio` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `sccache v0.3.0`, intermediate artifacts can be found at `/tmp/cargo-installcx83Fu`

/tmp が溢れている😱

$ df -BM

Filesystem     1M-blocks   Used Available Use% Mounted on
/dev/root        118989M 13156M   101048M  12% /
devtmpfs            183M     0M      183M   0% /dev
tmpfs               215M     0M      215M   0% /dev/shm
tmpfs                86M     9M       78M  10% /run
tmpfs                 5M     1M        5M   1% /run/lock
tmpfs               428M   426M        3M 100% /tmp
tmpfs                50M     1M       50M   1% /var/log
/dev/mmcblk0p1      127M    51M       76M  41% /boot
tmpfs                43M     1M       43M   1% /run/user/0
tmpfs                43M     1M       43M   1% /run/user/106
tmpfs                43M     1M       43M   1% /run/user/1000

tmp を掃除する😊

$ rm -rf /tmp/cargo-*
$ rm -rf /var/tmp/cargo-*

一時作業ディレクトリを /var/tmp にしてビルドを再実行する😊

$ TMPDIR=/var/tmp cargo install sccache

   Updating crates.io index
 Installing sccache v0.3.0
   Compiling libc v0.2.126
  ...

インストーラスクリプトの内容

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | cat
#!/bin/sh
# shellcheck shell=dash
 
# This is just a little script that can be downloaded from the internet to
# install rustup. It just does platform detection, downloads the installer
# and runs it.
 
# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local`
# extension. Note: Most shells limit `local` to 1 var per line, contra bash.
 
if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then
    # The version of ksh93 that ships with many illumos systems does not
    # support the "local" extension.  Print a message rather than fail in
    # subtle ways later on:
    echo 'rustup does not work with this ksh93 version; please try bash!' >&2
    exit 1
fi
 
 
set -u
 
# If RUSTUP_UPDATE_ROOT is unset or empty, default it.
RUSTUP_UPDATE_ROOT="${RUSTUP_UPDATE_ROOT:-https://static.rust-lang.org/rustup}"
 
#XXX: If you change anything here, please make the same changes in setup_mode.rs
usage() {
    cat 1>&2 <<EOF
rustup-init 1.24.3 (c1c769109 2021-05-31)
The installer for rustup
 
USAGE:
    rustup-init [FLAGS] [OPTIONS]
 
FLAGS:
    -v, --verbose           Enable verbose output
    -q, --quiet             Disable progress output
    -y                      Disable confirmation prompt.
        --no-modify-path    Don't configure the PATH environment variable
    -h, --help              Prints help information
    -V, --version           Prints version information
 
OPTIONS:
        --default-host <default-host>              Choose a default host triple
        --default-toolchain <default-toolchain>    Choose a default toolchain to install
        --default-toolchain none                   Do not install any toolchains
        --profile [minimal|default|complete]       Choose a profile
    -c, --component <components>...                Component name to also install
    -t, --target <targets>...                      Target name to also install
EOF
}
 
main() {
    downloader --check
    need_cmd uname
    need_cmd mktemp
    need_cmd chmod
    need_cmd mkdir
    need_cmd rm
    need_cmd rmdir
 
    get_architecture || return 1
    local _arch="$RETVAL"
    assert_nz "$_arch" "arch"
 
    local _ext=""
    case "$_arch" in
        *windows*)
            _ext=".exe"
            ;;
    esac
 
    local _url="${RUSTUP_UPDATE_ROOT}/dist/${_arch}/rustup-init${_ext}"
 
    local _dir
    _dir="$(ensure mktemp -d)"
    local _file="${_dir}/rustup-init${_ext}"
 
    local _ansi_escapes_are_valid=false
    if [ -t 2 ]; then
        if [ "${TERM+set}" = 'set' ]; then
            case "$TERM" in
                xterm*|rxvt*|urxvt*|linux*|vt*)
                    _ansi_escapes_are_valid=true
                ;;
            esac
        fi
    fi
 
    # check if we have to use /dev/tty to prompt the user
    local need_tty=yes
    for arg in "$@"; do
        case "$arg" in
            -h|--help)
                usage
                exit 0
                ;;
            -y)
                # user wants to skip the prompt -- we don't need /dev/tty
                need_tty=no
                ;;
            *)
                ;;
        esac
    done
 
    if $_ansi_escapes_are_valid; then
        printf "\33[1minfo:\33[0m downloading installer\n" 1>&2
    else
        printf '%s\n' 'info: downloading installer' 1>&2
    fi
 
    ensure mkdir -p "$_dir"
    ensure downloader "$_url" "$_file" "$_arch"
    ensure chmod u+x "$_file"
    if [ ! -x "$_file" ]; then
        printf '%s\n' "Cannot execute $_file (likely because of mounting /tmp as noexec)." 1>&2
        printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./rustup-init${_ext}." 1>&2
        exit 1
    fi
 
    if [ "$need_tty" = "yes" ]; then
        # The installer is going to want to ask for confirmation by
        # reading stdin.  This script was piped into `sh` though and
        # doesn't have stdin to pass to its children. Instead we're going
        # to explicitly connect /dev/tty to the installer's stdin.
        if [ ! -t 1 ]; then
            err "Unable to run interactively. Run with -y to accept defaults, --help for additional options"
        fi
 
        ignore "$_file" "$@" < /dev/tty
    else
        ignore "$_file" "$@"
    fi
 
    local _retval=$?
 
    ignore rm "$_file"
    ignore rmdir "$_dir"
 
    return "$_retval"
}
 
check_proc() {
    # Check for /proc by looking for the /proc/self/exe link
    # This is only run on Linux
    if ! test -L /proc/self/exe ; then
        err "fatal: Unable to find /proc/self/exe.  Is /proc mounted?  Installation cannot proceed without /proc."
    fi
}
 
get_bitness() {
    need_cmd head
    # Architecture detection without dependencies beyond coreutils.
    # ELF files start out "\x7fELF", and the following byte is
    #   0x01 for 32-bit and
    #   0x02 for 64-bit.
    # The printf builtin on some shells like dash only supports octal
    # escape sequences, so we use those.
    local _current_exe_head
    _current_exe_head=$(head -c 5 /proc/self/exe )
    if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then
        echo 32
    elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then
        echo 64
    else
        err "unknown platform bitness"
    fi
}
 
is_host_amd64_elf() {
    need_cmd head
    need_cmd tail
    # ELF e_machine detection without dependencies beyond coreutils.
    # Two-byte field at offset 0x12 indicates the CPU,
    # but we're interested in it being 0x3E to indicate amd64, or not that.
    local _current_exe_machine
    _current_exe_machine=$(head -c 19 /proc/self/exe | tail -c 1)
    [ "$_current_exe_machine" = "$(printf '\076')" ]
}
 
get_endianness() {
    local cputype=$1
    local suffix_eb=$2
    local suffix_el=$3
 
    # detect endianness without od/hexdump, like get_bitness() does.
    need_cmd head
    need_cmd tail
 
    local _current_exe_endianness
    _current_exe_endianness="$(head -c 6 /proc/self/exe | tail -c 1)"
    if [ "$_current_exe_endianness" = "$(printf '\001')" ]; then
        echo "${cputype}${suffix_el}"
    elif [ "$_current_exe_endianness" = "$(printf '\002')" ]; then
        echo "${cputype}${suffix_eb}"
    else
        err "unknown platform endianness"
    fi
}
 
get_architecture() {
    local _ostype _cputype _bitness _arch _clibtype
    _ostype="$(uname -s)"
    _cputype="$(uname -m)"
    _clibtype="gnu"
 
    if [ "$_ostype" = Linux ]; then
        if [ "$(uname -o)" = Android ]; then
            _ostype=Android
        fi
        if ldd --version 2>&1 | grep -q 'musl'; then
            _clibtype="musl"
        fi
    fi
 
    if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then
        # Darwin `uname -m` lies
        if sysctl hw.optional.x86_64 | grep -q ': 1'; then
            _cputype=x86_64
        fi
    fi
 
    if [ "$_ostype" = SunOS ]; then
        # Both Solaris and illumos presently announce as "SunOS" in "uname -s"
        # so use "uname -o" to disambiguate.  We use the full path to the
        # system uname in case the user has coreutils uname first in PATH,
        # which has historically sometimes printed the wrong value here.
        if [ "$(/usr/bin/uname -o)" = illumos ]; then
            _ostype=illumos
        fi
 
        # illumos systems have multi-arch userlands, and "uname -m" reports the
        # machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86
        # systems.  Check for the native (widest) instruction set on the
        # running kernel:
        if [ "$_cputype" = i86pc ]; then
            _cputype="$(isainfo -n)"
        fi
    fi
 
    case "$_ostype" in
 
        Android)
            _ostype=linux-android
            ;;
 
        Linux)
            check_proc
            _ostype=unknown-linux-$_clibtype
            _bitness=$(get_bitness)
            ;;
 
        FreeBSD)
            _ostype=unknown-freebsd
            ;;
 
        NetBSD)
            _ostype=unknown-netbsd
            ;;
 
        DragonFly)
            _ostype=unknown-dragonfly
            ;;
 
        Darwin)
            _ostype=apple-darwin
            ;;
 
        illumos)
            _ostype=unknown-illumos
            ;;
 
        MINGW* | MSYS* | CYGWIN*)
            _ostype=pc-windows-gnu
            ;;
 
        *)
            err "unrecognized OS type: $_ostype"
            ;;
 
    esac
 
    case "$_cputype" in
 
        i386 | i486 | i686 | i786 | x86)
            _cputype=i686
            ;;
 
        xscale | arm)
            _cputype=arm
            if [ "$_ostype" = "linux-android" ]; then
                _ostype=linux-androideabi
            fi
            ;;
 
        armv6l)
            _cputype=arm
            if [ "$_ostype" = "linux-android" ]; then
                _ostype=linux-androideabi
            else
                _ostype="${_ostype}eabihf"
            fi
            ;;
 
        armv7l | armv8l)
            _cputype=armv7
            if [ "$_ostype" = "linux-android" ]; then
                _ostype=linux-androideabi
            else
                _ostype="${_ostype}eabihf"
            fi
            ;;
 
        aarch64 | arm64)
            _cputype=aarch64
            ;;
 
        x86_64 | x86-64 | x64 | amd64)
            _cputype=x86_64
            ;;
 
        mips)
            _cputype=$(get_endianness mips '' el)
            ;;
 
        mips64)
            if [ "$_bitness" -eq 64 ]; then
                # only n64 ABI is supported for now
                _ostype="${_ostype}abi64"
                _cputype=$(get_endianness mips64 '' el)
            fi
            ;;
 
        ppc)
            _cputype=powerpc
            ;;
 
        ppc64)
            _cputype=powerpc64
            ;;
 
        ppc64le)
            _cputype=powerpc64le
            ;;
 
        s390x)
            _cputype=s390x
            ;;
        riscv64)
            _cputype=riscv64gc
            ;;
        *)
            err "unknown CPU type: $_cputype"
 
    esac
 
    # Detect 64-bit linux with 32-bit userland
    if [ "${_ostype}" = unknown-linux-gnu ] && [ "${_bitness}" -eq 32 ]; then
        case $_cputype in
            x86_64)
                if [ -n "${RUSTUP_CPUTYPE:-}" ]; then
                    _cputype="$RUSTUP_CPUTYPE"
                else {
                    # 32-bit executable for amd64 = x32
                    if is_host_amd64_elf; then {
                         echo "This host is running an x32 userland; as it stands, x32 support is poor," 1>&2
                         echo "and there isn't a native toolchain -- you will have to install" 1>&2
                         echo "multiarch compatibility with i686 and/or amd64, then select one" 1>&2
                         echo "by re-running this script with the RUSTUP_CPUTYPE environment variable" 1>&2
                         echo "set to i686 or x86_64, respectively." 1>&2
                         echo 1>&2
                         echo "You will be able to add an x32 target after installation by running" 1>&2
                         echo "  rustup target add x86_64-unknown-linux-gnux32" 1>&2
                         exit 1
                    }; else
                        _cputype=i686
                    fi
                }; fi
                ;;
            mips64)
                _cputype=$(get_endianness mips '' el)
                ;;
            powerpc64)
                _cputype=powerpc
                ;;
            aarch64)
                _cputype=armv7
                if [ "$_ostype" = "linux-android" ]; then
                    _ostype=linux-androideabi
                else
                    _ostype="${_ostype}eabihf"
                fi
                ;;
            riscv64gc)
                err "riscv64 with 32-bit userland unsupported"
                ;;
        esac
    fi
 
    # Detect armv7 but without the CPU features Rust needs in that build,
    # and fall back to arm.
    # See https://github.com/rust-lang/rustup.rs/issues/587.
    if [ "$_ostype" = "unknown-linux-gnueabihf" ] && [ "$_cputype" = armv7 ]; then
        if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then
            # At least one processor does not have NEON.
            _cputype=arm
        fi
    fi
 
    _arch="${_cputype}-${_ostype}"
 
    RETVAL="$_arch"
}
 
say() {
    printf 'rustup: %s\n' "$1"
}
 
err() {
    say "$1" >&2
    exit 1
}
 
need_cmd() {
    if ! check_cmd "$1"; then
        err "need '$1' (command not found)"
    fi
}
 
check_cmd() {
    command -v "$1" > /dev/null 2>&1
}
 
assert_nz() {
    if [ -z "$1" ]; then err "assert_nz $2"; fi
}
 
# Run a command that should never fail. If the command fails execution
# will immediately terminate with an error showing the failing
# command.
ensure() {
    if ! "$@"; then err "command failed: $*"; fi
}
 
# This is just for indicating that commands' results are being
# intentionally ignored. Usually, because it's being executed
# as part of error handling.
ignore() {
    "$@"
}
 
# This wraps curl or wget. Try curl first, if not installed,
# use wget instead.
downloader() {
    local _dld
    local _ciphersuites
    local _err
    local _status
    if check_cmd curl; then
        _dld=curl
    elif check_cmd wget; then
        _dld=wget
    else
        _dld='curl or wget' # to be used in error message of need_cmd
    fi
 
    if [ "$1" = --check ]; then
        need_cmd "$_dld"
    elif [ "$_dld" = curl ]; then
        get_ciphersuites_for_curl
        _ciphersuites="$RETVAL"
        if [ -n "$_ciphersuites" ]; then
            _err=$(curl --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$1" --output "$2" 2>&1)
            _status=$?
        else
            echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
            if ! check_help_for "$3" curl --proto --tlsv1.2; then
                echo "Warning: Not enforcing TLS v1.2, this is potentially less secure"
                _err=$(curl --silent --show-error --fail --location "$1" --output "$2" 2>&1)
                _status=$?
            else
                _err=$(curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2" 2>&1)
                _status=$?
            fi
        fi
        if [ -n "$_err" ]; then
            echo "$_err" >&2
            if echo "$_err" | grep -q 404$; then
                err "installer for platform '$3' not found, this may be unsupported"
            fi
        fi
        return $_status
    elif [ "$_dld" = wget ]; then
        get_ciphersuites_for_wget
        _ciphersuites="$RETVAL"
        if [ -n "$_ciphersuites" ]; then
            _err=$(wget --https-only --secure-protocol=TLSv1_2 --ciphers "$_ciphersuites" "$1" -O "$2" 2>&1)
            _status=$?
        else
            echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
            if ! check_help_for "$3" wget --https-only --secure-protocol; then
                echo "Warning: Not enforcing TLS v1.2, this is potentially less secure"
                _err=$(wget "$1" -O "$2" 2>&1)
                _status=$?
            else
                _err=$(wget --https-only --secure-protocol=TLSv1_2 "$1" -O "$2" 2>&1)
                _status=$?
            fi
        fi
        if [ -n "$_err" ]; then
            echo "$_err" >&2
            if echo "$_err" | grep -q ' 404 Not Found$'; then
                err "installer for platform '$3' not found, this may be unsupported"
            fi
        fi
        return $_status
    else
        err "Unknown downloader"   # should not reach here
    fi
}
 
check_help_for() {
    local _arch
    local _cmd
    local _arg
    _arch="$1"
    shift
    _cmd="$1"
    shift
 
    local _category
    if "$_cmd" --help | grep -q 'For all options use the manual or "--help all".'; then
      _category="all"
    else
      _category=""
    fi
 
    case "$_arch" in
 
        *darwin*)
        if check_cmd sw_vers; then
            case $(sw_vers -productVersion) in
                10.*)
                    # If we're running on macOS, older than 10.13, then we always
                    # fail to find these options to force fallback
                    if [ "$(sw_vers -productVersion | cut -d. -f2)" -lt 13 ]; then
                        # Older than 10.13
                        echo "Warning: Detected macOS platform older than 10.13"
                        return 1
                    fi
                    ;;
                11.*)
                    # We assume Big Sur will be OK for now
                    ;;
                *)
                    # Unknown product version, warn and continue
                    echo "Warning: Detected unknown macOS major version: $(sw_vers -productVersion)"
                    echo "Warning TLS capabilities detection may fail"
                    ;;
            esac
        fi
        ;;
 
    esac
 
    for _arg in "$@"; do
        if ! "$_cmd" --help $_category | grep -q -- "$_arg"; then
            return 1
        fi
    done
 
    true # not strictly needed
}
 
# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites
# if support by local tools is detected. Detection currently supports these curl backends:
# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.
get_ciphersuites_for_curl() {
    if [ -n "${RUSTUP_TLS_CIPHERSUITES-}" ]; then
        # user specified custom cipher suites, assume they know what they're doing
        RETVAL="$RUSTUP_TLS_CIPHERSUITES"
        return
    fi
 
    local _openssl_syntax="no"
    local _gnutls_syntax="no"
    local _backend_supported="yes"
    if curl -V | grep -q ' OpenSSL/'; then
        _openssl_syntax="yes"
    elif curl -V | grep -iq ' LibreSSL/'; then
        _openssl_syntax="yes"
    elif curl -V | grep -iq ' BoringSSL/'; then
        _openssl_syntax="yes"
    elif curl -V | grep -iq ' GnuTLS/'; then
        _gnutls_syntax="yes"
    else
        _backend_supported="no"
    fi
 
    local _args_supported="no"
    if [ "$_backend_supported" = "yes" ]; then
        # "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc.
        if check_help_for "notspecified" "curl" "--tlsv1.2" "--ciphers" "--proto"; then
            _args_supported="yes"
        fi
    fi
 
    local _cs=""
    if [ "$_args_supported" = "yes" ]; then
        if [ "$_openssl_syntax" = "yes" ]; then
            _cs=$(get_strong_ciphersuites_for "openssl")
        elif [ "$_gnutls_syntax" = "yes" ]; then
            _cs=$(get_strong_ciphersuites_for "gnutls")
        fi
    fi
 
    RETVAL="$_cs"
}
 
# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites
# if support by local tools is detected. Detection currently supports these wget backends:
# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.
get_ciphersuites_for_wget() {
    if [ -n "${RUSTUP_TLS_CIPHERSUITES-}" ]; then
        # user specified custom cipher suites, assume they know what they're doing
        RETVAL="$RUSTUP_TLS_CIPHERSUITES"
        return
    fi
 
    local _cs=""
    if wget -V | grep -q '\-DHAVE_LIBSSL'; then
        # "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc.
        if check_help_for "notspecified" "wget" "TLSv1_2" "--ciphers" "--https-only" "--secure-protocol"; then
            _cs=$(get_strong_ciphersuites_for "openssl")
        fi
    elif wget -V | grep -q '\-DHAVE_LIBGNUTLS'; then
        # "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc.
        if check_help_for "notspecified" "wget" "TLSv1_2" "--ciphers" "--https-only" "--secure-protocol"; then
            _cs=$(get_strong_ciphersuites_for "gnutls")
        fi
    fi
 
    RETVAL="$_cs"
}
 
# Return strong TLS 1.2-1.3 cipher suites in OpenSSL or GnuTLS syntax. TLS 1.2
# excludes non-ECDHE and non-AEAD cipher suites. DHE is excluded due to bad
# DH params often found on servers (see RFC 7919). Sequence matches or is
# similar to Firefox 68 ESR with weak cipher suites disabled via about:config.
# $1 must be openssl or gnutls.
get_strong_ciphersuites_for() {
    if [ "$1" = "openssl" ]; then
        # OpenSSL is forgiving of unknown values, no problems with TLS 1.3 values on versions that don't support it yet.
        echo "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384"
    elif [ "$1" = "gnutls" ]; then
        # GnuTLS isn't forgiving of unknown values, so this may require a GnuTLS version that supports TLS 1.3 even if wget doesn't.
        # Begin with SECURE128 (and higher) then remove/add to build cipher suites. Produces same 9 cipher suites as OpenSSL but in slightly different order.
        echo "SECURE128:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1:-VERS-DTLS-ALL:-CIPHER-ALL:-MAC-ALL:-KX-ALL:+AEAD:+ECDHE-ECDSA:+ECDHE-RSA:+AES-128-GCM:+CHACHA20-POLY1305:+AES-256-GCM"
    fi
}
 
main "$@" || exit 1
  • rust.1655493644.txt.gz
  • 最終更新: 2022/06/18 04:20
  • by ともやん