mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
build: Updated development utilities for AArch64
Updated Dockerfile to work with multiple architectures. Updated dev_cli.sh to: 1. Build container image before AArch64 image is ready in public. 2. Adjust default feature collection on AArch64. 3. Workaround a build problem with musl on AArch64. Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
af8292b623
commit
0090ec2dda
@ -1,5 +1,6 @@
|
||||
FROM ubuntu:18.04 as dev
|
||||
|
||||
ARG TARGETARCH="x86_64"
|
||||
ARG RUST_TOOLCHAIN="1.42.0"
|
||||
ARG CLH_SRC_DIR="/cloud-hypervisor"
|
||||
ARG CLH_BUILD_DIR="$CLH_SRC_DIR/build"
|
||||
@ -11,9 +12,9 @@ ENV RUSTUP_HOME=$CARGO_HOME
|
||||
ENV PATH="$PATH:$CARGO_HOME/bin"
|
||||
|
||||
# Install all CI dependencies
|
||||
RUN apt-get update
|
||||
RUN apt-get -yq upgrade
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq \
|
||||
RUN apt-get update \
|
||||
&& apt-get -yq upgrade \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq \
|
||||
build-essential \
|
||||
bc \
|
||||
docker.io \
|
||||
@ -37,22 +38,29 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq \
|
||||
dosfstools \
|
||||
cpio \
|
||||
bsdtar \
|
||||
gcc-multilib \
|
||||
libfdt-dev \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN if [ "$TARGETARCH" = "x86_64" ]; then \
|
||||
apt-get update \
|
||||
&& apt-get -yq upgrade \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq gcc-multilib \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*; fi
|
||||
|
||||
# Fix the libssl-dev install
|
||||
RUN cp /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/
|
||||
ENV OPENSSL_DIR=/usr/lib/x86_64-linux-gnu/
|
||||
ENV OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu/
|
||||
RUN cp /usr/include/"$TARGETARCH"-linux-gnu/openssl/opensslconf.h /usr/include/openssl/
|
||||
ENV OPENSSL_DIR=/usr/lib/"$TARGETARCH"-linux-gnu/
|
||||
ENV OPENSSL_LIB_DIR=/usr/lib/"$TARGETARCH"-linux-gnu/
|
||||
ENV OPENSSL_INCLUDE_DIR=/usr/include/
|
||||
|
||||
# Install the rust toolchain
|
||||
RUN nohup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN" \
|
||||
&& rustup target add x86_64-unknown-linux-musl --toolchain "$RUST_TOOLCHAIN" \
|
||||
&& rustup toolchain add $RUST_TOOLCHAIN-x86_64-unknown-linux-musl \
|
||||
&& rustup component add rustfmt \
|
||||
&& rustup component add clippy \
|
||||
&& rustup target add $TARGETARCH-unknown-linux-musl --toolchain "$RUST_TOOLCHAIN" \
|
||||
&& if [ "$TARGETARCH" = "x86_64" ]; then rustup toolchain add $RUST_TOOLCHAIN-x86_64-unknown-linux-musl; fi \
|
||||
&& if [ "$TARGETARCH" = "x86_64" ]; then rustup component add rustfmt; fi \
|
||||
&& if [ "$TARGETARCH" = "x86_64" ]; then rustup component add clippy; fi \
|
||||
&& cargo install cargo-audit \
|
||||
&& rm -rf "$CARGO_HOME/registry" \
|
||||
&& ln -s "$CARGO_REGISTRY_DIR" "$CARGO_HOME/registry" \
|
||||
|
@ -200,6 +200,13 @@ cmd_build() {
|
||||
cargo_args=("$@")
|
||||
[ $build = "release" ] && cargo_args+=("--release")
|
||||
cargo_args+=(--target "$target")
|
||||
[ $(uname -m) = "aarch64" ] && cargo_args+=("--no-default-features")
|
||||
[ $(uname -m) = "aarch64" ] && cargo_args+=(--features "mmio")
|
||||
|
||||
rustflags=""
|
||||
if [ $(uname -m) = "aarch64" ] && [ $libc = "musl" ] ; then
|
||||
rustflags="-C link-arg=-lgcc"
|
||||
fi
|
||||
|
||||
$DOCKER_RUNTIME run \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
@ -207,6 +214,7 @@ cmd_build() {
|
||||
--rm \
|
||||
--volume /dev:/dev \
|
||||
--volume "$CLH_ROOT_DIR:$CTR_CLH_ROOT_DIR" \
|
||||
--env RUSTFLAGS="$rustflags" \
|
||||
"$CTR_IMAGE" \
|
||||
cargo build \
|
||||
--target-dir "$CTR_CLH_CARGO_TARGET" \
|
||||
@ -336,6 +344,7 @@ cmd_build-container() {
|
||||
--target $container_type \
|
||||
-t $CTR_IMAGE \
|
||||
-f $BUILD_DIR/Dockerfile \
|
||||
--build-arg TARGETARCH="$(uname -m)" \
|
||||
$BUILD_DIR
|
||||
}
|
||||
|
||||
@ -365,6 +374,13 @@ cmd=cmd_$1
|
||||
shift
|
||||
|
||||
ensure_build_dir
|
||||
ensure_latest_ctr
|
||||
if [ $(uname -m) = "x86_64" ]; then
|
||||
ensure_latest_ctr
|
||||
fi
|
||||
|
||||
# Before a public image for AArch64 ready, we build the container if needed.
|
||||
if [ $(uname -m) = "aarch64" ]; then
|
||||
cmd_build-container
|
||||
fi
|
||||
|
||||
$cmd "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user