Third-party Rust Crates


OSRB approval is required for third-party crates. To get approval, you will need to follow the instructions under the “Process for 3rd Party Hosted Code” section in this document.

Third-party crates depended on by rustc_binary and rustc_library targets are stored in //third-party/rust-crates/rustc_deps/vendor. This set of crates is based on the dependencies listed in //third_party/rust-crates/rustc_deps/Cargo.toml, and is updated by running fx update-rustc-third-party, which will update the precise versions of the crates used in the Cargo.lock file and download any necessary crates into the vendor dir.

Adding a new vendored dependency

If a crate is not available in the vendor directory, it can to be added with the following steps:

  1. Reference the crates you need in rustc_deps/Cargo.toml.
  2. Run scripts/fx update-rustc-third-party. This will download all crates listed in rustc_deps/Cargo.toml as well as their dependencies and place them in the vendor directory.
  3. git add the Cargo.toml, Cargo.lock and vendor directory.
  4. Do not upload this change to gerrit yet.
  5. Get OSRB approval. Make sure to include the requested information for all new crates pulled in by your new dependency. If there are any files in the source repository that are not included when vendored, make a note of that for the OSRB reviewer. For example, font files that are only used for testing but are excluded when the crate is vendored. If you are not a Google employee, you will need to ask a Google employee to do this part for you.
  6. After getting the OSRB approval, upload the change to Gerrit. Get code-review+2, merge the change into third_party/rust-crates.
  7. Auto-rollers will update the git revision. If you need to update the revision manually, update the git revision in integration. Update the git revision of third_party/rust-crates in integration/garnet/third_party:
<project name="rust-crates"

Linking to a native library is not currently supported.

Adding a new mirror

  1. Request the addition of a mirror on;
  2. Add the mirror to the Jiri manifest for the Rust runtime;
  3. Add a patch section for the crate to the workspace;
  4. Run the update script.