1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05:00

build: fix rust temp file conflicts during parallel build

This commit is contained in:
Bert Belder 2018-08-26 06:17:02 +02:00
parent dfcde3e1ee
commit 224cfc8c74
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
3 changed files with 36 additions and 7 deletions

View file

@ -306,12 +306,6 @@ before_build:
Set-FilesNeeded -Auto -Path $outputs -Reason "Build dependency graph" Set-FilesNeeded -Auto -Path $outputs -Reason "Build dependency graph"
build_script: build_script:
# Attempt to work around multiple rustc instances messing with the same file
# when building in parallel.
# TODO: fix this properly.
- ps: ninja -C $env:DENO_BUILD_PATH -j 1
build_extra/rust:winapi build_extra/rust:winapi-0.2
- python tools\build.py - python tools\build.py
- ps: Set-FilesNeeded -Auto -Reason "Build finished" - ps: Set-FilesNeeded -Auto -Reason "Build finished"

View file

@ -0,0 +1,14 @@
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
# This script computes the sha256sum of the first command line argument, and
# writes a few hex digits of it to stdout. It is used by rust.gni to derive a
# unique string (without dots/special characters) from a crate version number.
from hashlib import sha256
import sys
if len(sys.argv) != 2:
raise Exception('Expected exactly one argument.')
hash = sha256(sys.argv[1]).hexdigest()
sys.stdout.write(hash[0:8])

View file

@ -118,9 +118,30 @@ template("run_rustc") {
] ]
if (defined(crate_version)) { 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 += [ 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", "-C",
"metadata=$crate_version", "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=$hash",
] ]
} }