diff options
author | Bert Belder <bertbelder@gmail.com> | 2018-08-26 06:17:02 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2018-08-26 19:22:37 +0200 |
commit | 224cfc8c74133a6b4fe6c9e96a90925ebaf066aa (patch) | |
tree | 6a02023ba3a2a1205a84858f3f1aa8bf903450a5 /build_extra/rust/rust.gni | |
parent | dfcde3e1eecc03a97d9e395ee9e61b7e03f1354d (diff) |
build: fix rust temp file conflicts during parallel build
Diffstat (limited to 'build_extra/rust/rust.gni')
-rw-r--r-- | build_extra/rust/rust.gni | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/build_extra/rust/rust.gni b/build_extra/rust/rust.gni index ece21d6c0..586953917 100644 --- a/build_extra/rust/rust.gni +++ b/build_extra/rust/rust.gni @@ -118,9 +118,30 @@ template("run_rustc") { ] if (defined(crate_version)) { + # Compute the sha256sum of the version number. See comments below. + # Note that we do this only if there are multiple versions of this crate. + hash = + exec_script("get_version_hash.py", [ crate_version ], "trim string") + args += [ + # In our build setup, all crates are built in the same directory. The + # actual build outputs have unique names (e.g. 'foo-1.2.3.rlib'), but + # rustc also creates many temp files (e.g. 'foo.crate.metadata.rcgu.bc', + # 'foo.foo0.rcgu.o'), and with those files, name collisions do occur. + # This causes random failures during parallel builds and on CI. + # + # These name conflicts can be avoided by setting `-C extra-filename=` to + # some unique value. Unfortunately the version number as such can't be + # used: everything after the first dot (.) is thrown away, so winapi-0.2 + # vs. winapi-0.3 would still have conflicts -- so we use a hash instead. + "-C", + "extra-filename=$hash", + + # Rustc blows up if a target (directly or indirectly) depends on two+ + # crates that have the same name *and* the same metadata. So we use the + # hash to give 'metadata' a unique value too (any unique value will do). "-C", - "metadata=$crate_version", + "metadata=$hash", ] } |