Rustup add component for custom toolchain

Hi,

I need to build a repo using a custom toolchain. However, that repo requires

rust-src rustc-dev llvm-tools-preview

However, it seems rustup can't install components for custom toolchains(correct me if I'm wrong).

Do you know how can I install them or build them by myself?

Thanks

1 Like

You can use ./x.py build --stage 2 and then link the stage2 toolchain to get rustc-dev. For llvm-tools-preview I though that was the default and rust-src, not sure how to add it. Another option would be to use ./x.py dist to create tarballs with all components and then extract them into the same directory.

1 Like

You can also use ./x.py install [component], which runs dist and then the install script, using paths from the [install] section in your config.toml.

1 Like

Thanks, the ./x.py dist actually works.
The workflow is:

  1. build & install your custom toolchain to a folder.
  2. run ./x.py dist, then you can get many compressed components in the build/dist folder
  3. Select the component you want and decompress it, there is an install.sh script, you can use that script to install the component to your custom toolchain. One example of mine is ./install.sh --prefix=~/rust_custom --components=rustc-dev, suppose I installed my toolchain in ~/rust_custom folder.

hello, I'm compiling my own rust compiler, too. And I met the same problem.

 = note: Could not find tool: lld
          at: /home/hky/rust/rust-source-code/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld
          Consider `rustup component add llvm-tools-preview`
error: could not compile `hello_world` due to previous error

Could you explain more specifically, which component includes the llvm-tools-preview, where can I find it?
thanks a lot!

Did you set lld = true in config.toml?