Skip to content

Commit

Permalink
static-build: enable cross build for virtiofsd
Browse files Browse the repository at this point in the history
Based on messense/rust-musl-cross which offer cross build musl lib
environment to cross compile virtiofsd.

Fixes: kata-containers#6557
Signed-off-by: Jianyong Wu <[email protected]>
  • Loading branch information
jongwu authored and fidencio committed Aug 1, 2023
1 parent 11631c6 commit 2205fb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o errexit
set -o nounset
set -o pipefail

ARCH=$(uname -m)
ARCH=${ARCH:-$(uname -m)}
ARCH_LIBC=""
LIBC=""

Expand Down
6 changes: 4 additions & 2 deletions tools/packaging/static-build/virtiofsd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readonly virtiofsd_builder="${script_dir}/build-static-virtiofsd.sh"

source "${script_dir}/../../scripts/lib.sh"

ARCH=${ARCH:-$(uname -m)}
DESTDIR=${DESTDIR:-${PWD}}
PREFIX=${PREFIX:-/opt/kata}
kata_version="${kata_version:-}"
Expand All @@ -32,7 +33,6 @@ package_output_dir="${package_output_dir:-}"
[ -n "${virtiofsd_toolchain}" ] || die "Failed to get the rust toolchain to build virtiofsd"
[ -n "${virtiofsd_zip}" ] || die "Failed to get virtiofsd binary URL"

ARCH=$(uname -m)
case ${ARCH} in
"aarch64")
libc="musl"
Expand All @@ -49,9 +49,10 @@ case ${ARCH} in
esac

container_image="${VIRTIOFSD_CONTAINER_BUILDER:-$(get_virtiofsd_image_name)}"
[ "${CROSS_BUILD}" == "true" ] && container_image="${container_image}-cross-build"

sudo docker pull ${container_image} || \
(sudo docker build \
(sudo docker $BUILDX build $PLATFORM \
--build-arg RUST_TOOLCHAIN="${virtiofsd_toolchain}" \
-t "${container_image}" "${script_dir}/${libc}" && \
# No-op unless PUSH_TO_REGISTRY is exported as "yes"
Expand All @@ -64,5 +65,6 @@ sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \
--env virtiofsd_repo="${virtiofsd_repo}" \
--env virtiofsd_version="${virtiofsd_version}" \
--env virtiofsd_zip="${virtiofsd_zip}" \
--env ARCH="${ARCH}" \
"${container_image}" \
bash -c "${virtiofsd_builder}"

0 comments on commit 2205fb9

Please sign in to comment.