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 <keiichiw@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
Daniel Verkamp 2020-04-15 11:41:50 -07:00 committed by Commit Bot
parent fcf078c38a
commit 043aaea79b
3 changed files with 16 additions and 5 deletions

View file

@ -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

View file

@ -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 -- \

View file

@ -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.