How to build Rust from source in the same way as release process

What is the exact script used to build the stable Rust toolchain binary from source?
Including the std libraries that is cross compiled.
Ideally, it should be identical to the official release.

I have read
but it is unclear for me what is the exact step.

It mentions ./release-scripts/,
in the repository,
but it needs privilege of Rust infra team

The process described in Rust Forge is for updating the release channels to a new release, and that isn't what you want to do (unless you are maintaining a fork of Rust with its own similar infrastructure). For instructions on compiling the compiler, see this page in the rustc dev guide. The page on bootstrapping may also be of interest. The main script to use for the build process is

1 Like

For exactly how final release binaries are created see rust/src/ci at master · rust-lang/rust · GitHub

You'll probably want to start from github-actions/ci.yml, lookup the dist- job for the platform you're interested in and then look up the scripts it uses.


Note that on several major platforms we compile with PGO which can give different results on different runs. We do ship the actual PGO profiles we used in the reproducible-artifacts component, but I think you will have to wire up these profiles yourself to the build process in the place of the first build step to generate the PGO profiles.

On top of that you can use the docker scripts which will take care of using the same build environment (e.g. gcc, clang and glibc version) as CI.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.