Skip to content

Instantly share code, notes, and snippets.

@amachang
Last active July 27, 2023 20:48
Show Gist options
  • Save amachang/8ff9e4432e29aaae0ff8f17b0ed24284 to your computer and use it in GitHub Desktop.
Save amachang/8ff9e4432e29aaae0ff8f17b0ed24284 to your computer and use it in GitHub Desktop.
[Rust] エラー: error[E0463]: can't find crate for `profiler_builtins` の意味が分かるようになるための知識

以下のエラーが出ることがある

error[E0463]: can't find crate for `profiler_builtins`

ググってもGPTっても、パッと出てくる情報は場当たり的なことが多かったので、わかったことをここにメモしておく

rustc-dev-guide/src/llvm-coverage-instrumentation.md を読むと

In the rustc source tree, library/profiler_builtins bundles the LLVM compiler-rt code into a Rust library crate. (When building rustc, the profiler_builtins library is only included when profiler = true is set in rustc's config.toml.)

と書いてあるので、 profiler_builtins がないって言われたら rustc を profiler = true でビルドしてないってこと

なのでおそらく以下のコマンドで libprofiler_builtins が見つからないはずだ。

ls "$(rustc --print target-libdir)"/libprofiler_builtins-*.rlib

まず調べるべきことは、その rustc は自分が意図してる rustc なのか。以下のようにして調べる。

whereis rustc
rustc --version

意図してない rustc を使っていたなら $PATH の変更とか、 rustup show などを試してみれば良い。自分の場合は、 brew でインストールしたパッケージが rust に依存していたため brew でインストールされた rustc が使われていた。

意図している rustc だけど profiler_builtins が入っていない場合は、自分で toolchain をコンパイルしてみて原因を探るのが良さそう。

参考: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment