1# Copyright 2021 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4# 5# Docker container that cross-compiles crosvm for aarch64. 6 7# Build-argument of the image tag of dependencies to use. Set to the same 8# version as `ci/image_tag` 9ARG TAG 10 11# Stage containing VM data to be used later. 12# (COPY --from does not allow the use of ARGs) 13FROM gcr.io/crosvm-packages/crosvm_test_vm_arm64:${TAG} as vm 14 15# Main stage 16FROM gcr.io/crosvm-packages/crosvm_base:${TAG} 17 18# Add repositories for arm64 packages 19RUN dpkg --add-architecture arm64 20 21# Install cross-compilation and VM tooling 22RUN apt-get update && apt-get install --yes --no-install-recommends \ 23 dpkg-dev \ 24 g++-aarch64-linux-gnu \ 25 gcc-aarch64-linux-gnu \ 26 ipxe-qemu \ 27 qemu-efi-aarch64 \ 28 qemu-system-aarch64 \ 29 qemu-user-static 30 31RUN apt-get install --yes --no-install-recommends -o APT::Immediate-Configure=false \ 32 libcap-dev:arm64 \ 33 libdbus-1-dev:arm64 \ 34 libdrm-dev:arm64 \ 35 libepoxy-dev:arm64 \ 36 libssl-dev:arm64 \ 37 libwayland-dev:arm64 38 39RUN apt-get install --yes -t testing --no-install-recommends \ 40 libdrm-dev:arm64 \ 41 libepoxy-dev:arm64 42 43# Setup rust for cross-compilation 44RUN rustup target add aarch64-unknown-linux-gnu 45ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ 46 CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ 47 CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \ 48 CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu \ 49 PKG_CONFIG=aarch64-linux-gnu-pkg-config \ 50 PKG_CONFIG_PATH=/workspace/scratch/lib/pkgconfig 51 52# Allow GCC/Rust to find packages and libraries stored on the scratch volume. We 53# have to link to a known search path since LIBRARY_PATH is not used by 54# cross-compile GCC. 55RUN ln -s /workspace/scratch/lib/ /usr/local/lib/aarch64-linux-gnu 56 57# Hack: For some reason the libgcc-10-dev-arm64-cross package does not install 58# this link correctly. 59RUN cd /usr/aarch64-linux-gnu/lib && ln -s libgcc_s.so.1 libgcc_s.so 60 61# Allow qemu-aarch64-static to find aarch64 libraries 62ENV QEMU_LD_PREFIX=/usr/aarch64-linux-gnu 63 64# Include test VM inside this container 65COPY --from=vm \ 66 /workspace/vm/* \ 67 /workspace/vm/ 68COPY --from=vm \ 69 /root/.ssh /root/.ssh 70 71# Setup entrypoint and interactive shell 72WORKDIR /workspace/src/platform/crosvm 73COPY bashrc /root/.bashrc 74COPY entrypoint /workspace 75ENTRYPOINT ["/workspace/entrypoint"] 76