From 043aaea79be76508cc52f07e54da6b933b1987ef Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Wed, 15 Apr 2020 11:41:50 -0700 Subject: [PATCH] docker: update to rust 1.42 and rustup 1.21.1 Update to the latest rustup release, which (since 1.20.0) installs rustfmt and clippy by default: https://blog.rust-lang.org/2019/10/15/Rustup-1.20.0.html Also update the Rust toolchain version to 1.42.0 to match the version in the CrOS build environment. Additionally, add workarounds for sysroot of cargo clippy. BUG=None TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh TEST=bin/clippy on workstation Change-Id: I7ac4db92f4e5f277d77a77fa3c4ffa880f2ae116 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2150988 Tested-by: Keiichi Watanabe Tested-by: Daniel Verkamp Reviewed-by: Zach Reizner Commit-Queue: Keiichi Watanabe --- bin/clippy | 6 ++++++ bin/smoke_test | 3 ++- docker/Dockerfile | 12 ++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/clippy b/bin/clippy index 6631f26c64..03f85c8a4a 100755 --- a/bin/clippy +++ b/bin/clippy @@ -72,5 +72,11 @@ SUPPRESS=( # Needed or else clippy won't re-run on code that has already compiled. cargo clean +# Need to set pass --sysroot for cargo-clippy manually. +# cf. https://github.com/rust-lang/rust-clippy/issues/3523 +RUST_SYSROOT=$(rustc --print sysroot) +RUSTFLAGS="${RUSTFLAGS:-}" +export RUSTFLAGS="$RUSTFLAGS --sysroot=$RUST_SYSROOT" + cargo clippy --all-features --all-targets -- ${SUPPRESS[@]/#/-Aclippy::} "$@" \ -D warnings diff --git a/bin/smoke_test b/bin/smoke_test index ade2a196dc..7467c75e37 100755 --- a/bin/smoke_test +++ b/bin/smoke_test @@ -10,7 +10,8 @@ cd ../ rustup default "$(cat rust-toolchain)" rustup component add rustfmt-preview -cargo --version && rustc --version && rustfmt --version +cargo --version && rustc --version && rustfmt --version \ + && cargo clippy --version echo "Running cargo test" cargo test --no-fail-fast --features plugin,default-no-sandbox,wl-dmabuf,gpu,tpm \ --all --exclude aarch64 $TEST_FLAGS -- \ diff --git a/docker/Dockerfile b/docker/Dockerfile index 995ff9b232..ecafd0a3e3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -36,16 +36,15 @@ RUN apt-get update && apt-get install -y \ ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=1.41.0 \ + RUST_VERSION=1.42.0 \ RUSTFLAGS='--cfg hermetic' # Debian usually has an old rust version in the repository. Instead of using that, we use rustup to # pull in a toolchain versions of our choosing. -RUN curl -LO "https://static.rust-lang.org/rustup/archive/1.14.0/x86_64-unknown-linux-gnu/rustup-init" \ - && echo "0077ff9c19f722e2be202698c037413099e1188c0c233c12a2297bf18e9ff6e7 *rustup-init" | sha256sum -c - \ +RUN curl -LO "https://static.rust-lang.org/rustup/archive/1.21.1/x86_64-unknown-linux-gnu/rustup-init" \ + && echo "ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b *rustup-init" | sha256sum -c - \ && chmod +x rustup-init \ && ./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION \ - && rustup component add rustfmt-preview \ && rm rustup-init \ && chmod -R a+w $RUSTUP_HOME $CARGO_HOME \ && rustup --version \ @@ -129,6 +128,11 @@ ENV SYSROOT=/sysroot RUN mkdir -p $SYSROOT/usr/include/chromeos/dbus/trunks \ && cp $PLATFORM2_ROOT/trunks/interface.proto \ $SYSROOT/usr/include/chromeos/dbus/trunks +# Copy it under rustc's sysroot as well for cargo clippy. +RUN export RUST_SYSROOT=$(rustc --print sysroot); echo $RUST_SYSROOT +RUN mkdir -p $RUST_SYSROOT/usr/include/chromeos/dbus/trunks \ + && cp $PLATFORM2_ROOT/trunks/interface.proto \ + $RUST_SYSROOT/usr/include/chromeos/dbus/trunks # Inform pkg-config where libraries we install are placed. # Also, copy a dummy libvda.pc to compile crosvm with video features.