LoginSignup
11
3

More than 1 year has passed since last update.

Rust のビルドを rust-lld で速くしてみる

Posted at

下記 κeen さんの記事で mold を教えてもらいました。

しかし、Windows 環境では使えないようです。

そこで rust-lld.exe を使ってビルドを高速化してみたいと思います。

インストロール

下記コマンドで rust-lld.exe がインストロールされます。

rustup component add llvm-tools-preview

設定

各 crate 毎に設定するなら Cargo.toml があるフォルダに .cargo フォルダと、その下に config.toml ファイルを作ります。

.
├── .cargo          // New!
│   └── config.toml // New!
├── Cargo.toml
└── src
    └── main.rs

config.toml に以下の内容を書きます。

config.toml
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"

C:\Users\xxxxx\.cargo\config.toml に書くとすべてのビルドに設定が適用されます。

結果

actix-web のサンプルプログラムを私の環境でビルドしてみた結果です。

msvc rust-lld
4.9 sec 4.4 sec

たいして変わんねー:sob:

WSL

WSL Ubuntu 20.04 環境でも同じく actix-web のサンプルプログラムをビルドして比較してみました。

gcc llvm-lld mold
11.5 sec 5.3 sec 4.9 sec

gcc のリンカが遅すぎる?:thinking:

11
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
3