From 7004ced0d3a94eb07a535d5738e6403dc73ab313 Mon Sep 17 00:00:00 2001 From: Catena cyber <35799796+catenacyber@users.noreply.github.com> Date: Mon, 17 May 2021 20:55:53 +0200 Subject: [PATCH] Right copy for rust std lib for coverage (#5791) --- infra/base-images/base-builder/compile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/infra/base-images/base-builder/compile b/infra/base-images/base-builder/compile index abdbfdb63..129dec3f8 100755 --- a/infra/base-images/base-builder/compile +++ b/infra/base-images/base-builder/compile @@ -150,17 +150,18 @@ BUILD_CMD="bash -eux $SRC/build.sh" # We need to preserve source code files for generating a code coverage report. # We need exact files that were compiled, so copy both $SRC and $WORK dirs. -COPY_SOURCES_CMD="cp -rL --parents $SRC $WORK /usr/include /usr/local/include $GOPATH $OSSFUZZ_RUSTPATH $OUT" +COPY_SOURCES_CMD="cp -rL --parents $SRC $WORK /usr/include /usr/local/include $GOPATH $OSSFUZZ_RUSTPATH /rustc $OUT" + +# Copy rust std lib to its path with a hash +export rustch=`rustc --version --verbose | grep commit-hash | cut -d' ' -f2` +mkdir -p /rustc/$rustch/ +cp -r /rust/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/ /rustc/$rustch/ if [ "${BUILD_UID-0}" -ne "0" ]; then adduser -u $BUILD_UID --disabled-password --gecos '' builder chown -R builder $SRC $OUT $WORK su -c "$BUILD_CMD" builder if [ "$SANITIZER" = "coverage" ]; then - # Copy rust std lib to its path with a hash - export rustch=`rustc --version --verbose | grep commit-hash | cut -d' ' -f2` - mkdir -p /rust/rustc/$rustch/ - cp -r /rust/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/ /rust/rustc/$rustch/ # Some directories have broken symlinks (e.g. honggfuzz), ignore the errors. su -c "$COPY_SOURCES_CMD" builder 2>/dev/null || true fi