Skip to content

Commit 713372c

Browse files
danakjcopybara-github
authored andcommitted
Add some mention of build script extra inputs for gnrt
Build scripts are a potential separate build target for each crate, so they have a separate set up sources/inputs, and thus a separate config option for the same. Remove some obsolete stuff around cargo vendor. [email protected] Change-Id: I27516beb831359044deb77afd728af99fad8812b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5871322 Commit-Queue: danakj <[email protected]> Reviewed-by: Hans Wennborg <[email protected]> Cr-Commit-Position: refs/heads/main@{#1357147} NOKEYCHECK=True GitOrigin-RevId: 324f546558b0a6b8cfdc818a85ed55ce3487824a
1 parent a7d3d8a commit 713372c

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,6 @@ gen` does different things for creating gn rules for the standard library
124124
versus for various non-standard-library packages, such as producing a single
125125
BUILD.gn file.
126126

127-
### Possible failure: Missing dependencies
128-
129-
`build_rust.py` will vendor all dependencies before starting the build. To do
130-
this it first initializes git submodules. Then it runs `cargo vendor`. However
131-
some parts of the compiler build are excluded from the top level Cargo.toml
132-
workspace. Thus it passes `--sync dir` for a number of subdirectories, based
133-
on [dist.rs, the nightly tarball packager](
134-
https://github.com/rust-lang/rust/blob/master/src/bootstrap/dist.rs#L986-L995).
135-
136-
If another Cargo.toml is required in the future, and not part of the workspace
137-
it would produce missing dependencies, and the set of directories in
138-
`build_rust.py` would need to be updated.
139-
140127
### Possible failure: Missing sources or inputs
141128

142129
A build error when building the stdlib in Chromium may look like:
@@ -185,22 +172,41 @@ To fix the error:
185172
* Find the failing build target crate's rules in
186173
`//build/rust/std/gnrt_config.toml`. The failing crate in the above example
187174
is `libstd.rlib`, so we want the `[crate.std]` section of the config file.
175+
* Determine if the target being built is a library or a build script. Build
176+
script targets end with the suffix `_build_script`. For example:
177+
```
178+
[13627/84339] RUST(BIN) clang_x64_for_rust_host_build_tools/compiler_builtins_compiler_builtins_vunknown_build_script
179+
python3 ../../build/rust/rustc_wrapper.py --rustc=../../third_party/rust-toolchain/bin/rustc --depfi...(too long)
180+
ERROR: file not in GN sources: ../../third_party/rust-toolchain/lib/rustlib/src/rust/library/vendor/compiler_builtins-0.1.123/configure.rs
181+
```
188182
* Determine if the missing file should go in `sources` or `inputs`.
189183
* For `sources`, add the path to a `extra_src_roots` list in the crate's
190184
rules. For the above example, we could add
191185
`extra_src_roots = ['../../portable-simd/crates/std_float/src']`.
186+
* Or if it was a build script target, then
187+
`extra_build_script_src_roots = ['../../portable-simd/crates/std_float/src']`.
192188
* For `inputs`, add the path to a `extra_input_roots` list in the crate's
193189
rules. For the above example, we could add
194190
`extra_input_roots = ['../../stdarch/crates/core_arch/src']`.
191+
* Or if it was a build script target, then
192+
`extra_build_script_input_roots = ['../../stdarch/crates/core_arch/src']`.
195193
* With the roll CL checked out, run `gclient sync`.
194+
196195
*** note
197196
NOTE: `gclient sync` will download the version of the rust toolchain from the
198197
roll CL. In order for this to work, the upload_rust bots should've completed and
199198
`copy_staging_to_prod_and_goma.sh should've been run.
200199
***
200+
201201
* Run `tools/rust/gnrt_stdlib.py` to use gnrt to rebuild the stdlib GN rules
202202
using the updated config.
203203

204+
*** note
205+
NOTE: All gnrt_config options are found in
206+
[//tools/crates/gnrt/lib/config.rs](https://source.chromium.org/chromium/chromium/src/+/main:tools/crates/gnrt/lib/config.rs).
207+
The `CrateConfig` type has the various per-crate config options.
208+
***
209+
204210
### Generating `BUILD.gn` files for stdlib crates
205211

206212
If the build structure changes in any way during a roll, the GN files need

0 commit comments

Comments
 (0)