Debian's filesystem layout has a nice advantage over Fedora which is that it can install non-native RPMs in the main root filesystem. It is thus possible to prepare an x86_64 filesystem containing -dev packages for a foreign architecture, along with a GCC cross compiler. QEMU has used this technique to facilitate developer build testing of non-x86 architectures, since few people have access to physical hardware for most of these architectures. For the same reason it would be helpful to libvirt developers. This docker file allows creation of containers buildenv-cross-$ARCH for arm64, armel, armhf, mips, mipsel, mips64el, ppc64el, s390x, based off Debian 9, in which libvirt can be cross-compiled. Debian can support further architectures, but only by using the unstable 'sid' repos. This does not enable use of 'sid' but it could be added fairly easily at a later date if desired. Most of the other architectures are fairly old & obscure, the main interesting exception being riscv64. If qemu-user emulators are registered with the kernel binfmt, then it is theoretically possible to run "make check" tool, though this has not been tested. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- .gitignore | 1 + cross-build/arch-config.csv | 8 +++ cross-build/buildenv-cross.docker.in | 96 ++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 cross-build/arch-config.csv create mode 100644 cross-build/buildenv-cross.docker.in diff --git a/.gitignore b/.gitignore index b25c15b..4884352 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *~ +cross-build/*docker diff --git a/cross-build/arch-config.csv b/cross-build/arch-config.csv new file mode 100644 index 0000000..36fcb5f --- /dev/null +++ b/cross-build/arch-config.csv @@ -0,0 +1,8 @@ +arm64,crossbuild-essential-arm64,aarch64-linux-gnu +armel,crossbuild-essential-armel,arm-linux-gnueabi +armhf,crossbuild-essential-armhf,arm-linux-gnueabihf +mips64el,gcc-mips64el-linux-gnuabi64,mips64el-linux-gnuabi64 +mips,gcc-mips-linux-gnu,mips-linux-gnu +mipsel,gcc-mipsel-linux-gnu,mipsel-linux-gnu +ppc64el,crossbuild-essential-ppc64el,powerpc64le-linux-gnu +s390x,gcc-multilib-s390x-linux-gnu,s390x-linux-gnu diff --git a/cross-build/buildenv-cross.docker.in b/cross-build/buildenv-cross.docker.in new file mode 100644 index 0000000..97a9e69 --- /dev/null +++ b/cross-build/buildenv-cross.docker.in @@ -0,0 +1,96 @@ +# +# ::ARCH:: cross-compiler target +# +FROM debian:stretch-slim + +# Grab the updated list of packages +RUN apt update && apt dist-upgrade -yy + +# First some common native binaries. Any program that the +# build will execute needs to have a native binary package +# installed. We don't want to rely on qemu-user emulation +# for executing non-native binaries as that is slow & flaky +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get install -y --no-install-recommends \ + git \ + build-essential \ + ca-certificates \ + libtool\ + autoconf \ + automake \ + python3 \ + xsltproc \ + parted \ + radvd \ + qemu-system-common \ + dwarves \ + libxml2-utils \ + dnsmasq-base \ + openssh-client \ + netcat-openbsd \ + ebtables \ + iptables \ + sheepdog \ + qemu-utils \ + qemu-system-x86 \ + pkg-config + + +# Add the ::ARCH:: architecture +RUN dpkg --add-architecture ::ARCH:: + + +# Grab the freshly updated list of packages +RUN apt update + + +# Pull in the native package for the cross-compiler +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get install -y --no-install-recommends \ + ::COMPILER:: + +# Finally pull in the foreign architecture library +# packages that we're going to link against. Everything +# here should be a -dev package. Binaries belong earlier +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get install -y --no-install-recommends \ + libxml2-dev:::ARCH:: \ + libncurses5-dev:::ARCH:: \ + libreadline-dev:::ARCH:: \ + zlib1g-dev:::ARCH:: \ + libgcrypt20-dev:::ARCH:: \ + libgnutls28-dev:::ARCH:: \ + libavahi-client-dev:::ARCH:: \ + libsasl2-dev:::ARCH:: \ + libparted-dev:::ARCH:: \ + libdevmapper-dev:::ARCH:: \ + uuid-dev:::ARCH:: \ + libudev-dev:::ARCH:: \ + libpciaccess-dev:::ARCH:: \ + libpolkit-gobject-1-dev:::ARCH:: \ + libcap-ng-dev:::ARCH:: \ + libnl-3-dev:::ARCH:: \ + libnl-route-3-dev:::ARCH:: \ + libyajl-dev:::ARCH:: \ + libpcap0.8-dev:::ARCH:: \ + libsanlock-dev:::ARCH:: \ + libaudit-dev:::ARCH:: \ + libselinux1-dev:::ARCH:: \ + libapparmor-dev:::ARCH:: \ + libdbus-1-dev:::ARCH:: \ + librbd-dev:::ARCH:: \ + librados-dev:::ARCH:: \ + libfuse-dev:::ARCH:: \ + libssh2-1-dev:::ARCH:: \ + libcurl4-gnutls-dev:::ARCH:: \ + libacl1-dev:::ARCH:: \ + libiscsi-dev:::ARCH:: \ + xfslibs-dev:::ARCH:: \ + libssh-dev:::ARCH:: \ + libgnutls28-dev:::ARCH:: + +# Tell libvirt which architecture we want to target +ENV LIBVIRT_CONFIGURE_OPTS "--host=::ABI:: --build=x86_64-linux-gnu --target=::ABI::" + +# Tell pkg-config where to find the non-native .pc files +ENV PKG_CONFIG_LIBDIR=/usr/lib/::ABI::/pkgconfig -- 2.20.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list