本指南說明如何使用自訂 Rust 編譯器建構 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 版本現在使用更新版編譯器。
必要條件
使用自訂 Rust 工具鍊建構 Fuchsia 之前,您需要先完成下列事項:
為 Fuchsia 建構自訂 Rust 工具鍊。
請完成下列指南,下載 Fuchsia 來源:取得 Fuchsia 原始碼。如要確認 Jiri 是否位於路徑中,請執行
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