本指南介绍如何使用自定义 Rust 编译器构建 Fuchsia。如果您需要使用修补后的编译器或使用自定义选项构建的编译器构建 Fuchsia,这会非常有用。
使用其他版本的 Rust
如果您只需使用与当前使用的版本不同的版本,则本文档的大部分内容都没有必要。Fuchsia 构建器每次更改 Rust 的主分支后,都会构建 Rust。
- 找到要使用的提交哈希值。
从 Fuchsia 目录运行以下命令:
# 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
运行以下命令以构建 Fuchsia:
fx build
Fuchsia build 现在使用更新后的编译器。
前提条件
在使用自定义 Rust 工具链构建 Fuchsia 之前,您需要执行以下操作:
为 Fuchsia 构建自定义 Rust 工具链。
完成以下指南以下载 Fuchsia 源代码:获取 Fuchsia 源代码。如需确认 jiri 是否在 PATH 中,请运行
jiri -help
。
使用自定义 Rust 工具链构建 Fuchsia
切换到您的 Fuchsia 目录。
运行以下命令以使用新构建的工具链:
DEV_ROOT=DEV_ROOT
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
运行以下命令以重新构建 Fuchsia:
fx build