This guide explains how to build Fuchsia with a custom Rust compiler. This is useful if you need to build Fuchsia with a patched compiler, or a compiler built with custom options.
Use another version of Rust
If all you need to do is use a different version than the one currently being used, most of this doc is not necessary. Fuchsia builders build Rust after every change to Rust's main branch.
- Find the commit hash you want to use.
Run the following commands from your Fuchsia directory:
# Replace COMMIT with the full Rust commit hash. # This command updates the manifests in the integration repo, which you can # then commit or revert as necessary. fx roll-compiler --package rust git_revision:COMMIT
# Fetch the package versions you specified and install them in `prebuilt/`. jiri fetch-packages -local-manifest
Run the following command to build Fuchsia:
The Fuchsia build now uses the updated compiler.
Prior to building Fuchsia with a custom Rust toolchain, you need to do the following:
Build a custom Rust toolchain for Fuchsia.
Complete the following guide to download the Fuchsia source: Get Fuchsia source code. To confirm that jiri is in your PATH run
Build Fuchsia with your custom Rust toolchain
Change into your Fuchsia directory.
Run the following command to use the newly built toolchain:
fx set core.x64 \ --args=rustc_prefix="\"$DEV_ROOT/rust/install/fuchsia-rust\"" \ --args=rustc_version_string='"1"' # plus other settings such as: # --with //bundles/kitchen_sink # --variant=coverage-rust # to enable coverage profiling of fuchsia binaries # --variant=host_coverage-rust # to enable coverage profiling of host binaries
Run the following command to rebuild Fuchsia: