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 patch extends the 'dockerfile' command to 'lcitool' so that it
accepts a '-x $ARCH' argument.
$ lcitool -a dockerfile -h libvirt-debian-9 -p libvirt -x s390x
This is only valid when using a 'deb' based distro.
With the Debian 9 distro, this supports arm64, armel, armhf, mips,
mipsel, mips64el, ppc64el, s390x, which are all the official archs
that Debian maintainers currently build libvirt for. With Debian Sid,
this is extended to include i386. Debian also builds libvirt on hppa,
powerpcspe, sparc64 and x32 which are unofficial ports. Unfortunately
it is not possible to reliably add foreign arch packages from the
unofficial ports in parallel with those from the native arch, without
hitting dependency problems from apt.
When an architecture is given, any package name ending in '-dev' will
be installed using that architecture variant, while all remaining
packages will have their native variant installed. For various reasons
(commented inline) a few blacklists are required on a per-arch basis.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
guests/host_vars/libvirt-debian-9/docker.yml | 57 +++++++++++++++
.../host_vars/libvirt-debian-sid/docker.yml | 62 +++++++++++++++++
guests/lcitool | 69 ++++++++++++++++---
3 files changed, 179 insertions(+), 9 deletions(-)
diff --git a/guests/host_vars/libvirt-debian-9/docker.yml b/guests/host_vars/libvirt-debian-9/docker.yml
index 0b4ccee..0e613da 100644
--- a/guests/host_vars/libvirt-debian-9/docker.yml
+++ b/guests/host_vars/libvirt-debian-9/docker.yml
@@ -1,2 +1,59 @@
---
docker_base: debian:9
+cross_build:
+ blacklist:
+ # Doesn't properly resolve from foreign arch package
+ # to the native package of augeas-lenses
+ - libnetcf-dev
+ # Fails to resolve deps from foreign arch
+ - wireshark-dev
+ # dtrace tool doesn't know how to cross-compile
+ - systemtap-sdt-dev
+ arches:
+ arm64:
+ gcc-pkg-prefix: crossbuild-essential-arm64
+ target-prefix: aarch64-linux-gnu
+ armel:
+ gcc-pkg-prefix: crossbuild-essential-armel
+ target-prefix: arm-linux-gnueabi
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ # Arch does not support NUMA concept
+ - libnuma-dev
+ armhf:
+ gcc-pkg-prefix: crossbuild-essential-armhf
+ target-prefix: arm-linux-gnueabihf
+ blacklist:
+ # Arch does not support NUMA concept
+ - libnuma-dev
+ mips64el:
+ gcc-pkg-prefix: gcc-mips64el-linux-gnuabi64
+ target-prefix: mips64el-linux-gnuabi64
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ mips:
+ gcc-pkg-prefix: gcc-mips-linux-gnu
+ target-prefix: mips-linux-gnu
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ mipsel:
+ gcc-pkg-prefix: gcc-mipsel-linux-gnu
+ target-prefix: mipsel-linux-gnu
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ ppc64el:
+ gcc-pkg-prefix: crossbuild-essential-ppc64el
+ target-prefix: powerpc64le-linux-gnu
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ s390x:
+ gcc-pkg-prefix: gcc-multilib-s390x-linux-gnu
+ target-prefix: s390x-linux-gnu
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
diff --git a/guests/host_vars/libvirt-debian-sid/docker.yml b/guests/host_vars/libvirt-debian-sid/docker.yml
index e20a37e..61ecc1f 100644
--- a/guests/host_vars/libvirt-debian-sid/docker.yml
+++ b/guests/host_vars/libvirt-debian-sid/docker.yml
@@ -1,2 +1,64 @@
---
docker_base: debian:sid
+cross_build:
+ blacklist:
+ # Doesn't properly resolve from foreign arch package
+ # to the native package of augeas-lenses
+ - libnetcf-dev
+ # Fails to resolve deps from foreign arch
+ - wireshark-dev
+ # dtrace tool doesn't know how to cross-compile
+ - systemtap-sdt-dev
+ # appears to be dropped from the 'sid' tree
+ - sheepdog
+ arches:
+ arm64:
+ gcc-pkg-prefix: crossbuild-essential-arm64
+ target-prefix: aarch64-linux-gnu
+ armel:
+ gcc-pkg-prefix: crossbuild-essential-armel
+ target-prefix: arm-linux-gnueabi
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ # Arch does not support NUMA concept
+ - libnuma-dev
+ armhf:
+ gcc-pkg-prefix: crossbuild-essential-armhf
+ target-prefix: arm-linux-gnueabihf
+ blacklist:
+ # Arch does not support NUMA concept
+ - libnuma-dev
+ mips64el:
+ gcc-pkg-prefix: gcc-mips64el-linux-gnuabi64
+ target-prefix: mips64el-linux-gnuabi64
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ mips:
+ gcc-pkg-prefix: gcc-mips-linux-gnu
+ target-prefix: mips-linux-gnu
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ mipsel:
+ gcc-pkg-prefix: gcc-mipsel-linux-gnu
+ target-prefix: mipsel-linux-gnu
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ ppc64el:
+ gcc-pkg-prefix: crossbuild-essential-ppc64el
+ target-prefix: powerpc64le-linux-gnu
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ s390x:
+ gcc-pkg-prefix: gcc-multilib-s390x-linux-gnu
+ target-prefix: s390x-linux-gnu
+ blacklist:
+ # Not built on this arch
+ - libxen-dev
+ i386:
+ gcc-pkg-prefix: gcc-multilib-i686-linux-gnu
+ target-prefix: i686-linux-gnu
diff --git a/guests/lcitool b/guests/lcitool
index cd757eb..dc5741e 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -343,6 +343,11 @@ class Application:
metavar="GIT_REVISION",
help="git revision to build (remote/branch)",
)
+ self._parser.add_argument(
+ "-x",
+ metavar="CROSS-ARCH",
+ help="cross compiler architecture (dockerfile action only)",
+ )
def _execute_playbook(self, playbook, hosts, projects, git_revision):
base = Util.get_base()
@@ -402,15 +407,15 @@ class Application:
except Exception:
raise Error("Failed to run {} on '{}'".format(playbook, hosts))
- def _action_hosts(self, _hosts, _projects, _revision):
+ def _action_hosts(self, _hosts, _projects, _revision, _cross_arch):
for host in self._inventory.expand_pattern("all"):
print(host)
- def _action_projects(self, _hosts, _projects, _revision):
+ def _action_projects(self, _hosts, _projects, _revision, _cross_arch):
for project in self._projects.expand_pattern("all"):
print(project)
- def _action_install(self, hosts, _projects, _revision):
+ def _action_install(self, hosts, _projects, _revision, _cross_arch):
base = Util.get_base()
flavor = self._config.get_flavor()
@@ -482,13 +487,13 @@ class Application:
except Exception:
raise Error("Failed to install '{}'".format(host))
- def _action_update(self, hosts, projects, git_revision):
+ def _action_update(self, hosts, projects, git_revision, _cross_arch):
self._execute_playbook("update", hosts, projects, git_revision)
- def _action_build(self, hosts, projects, git_revision):
+ def _action_build(self, hosts, projects, git_revision, _cross_arch):
self._execute_playbook("build", hosts, projects, git_revision)
- def _action_dockerfile(self, hosts, projects, _revision):
+ def _action_dockerfile(self, hosts, projects, _revision, cross_arch):
mappings = self._projects.get_mappings()
hosts = self._inventory.expand_pattern(hosts)
@@ -501,10 +506,24 @@ class Application:
os_name = facts["os_name"]
os_version = facts["os_version"]
os_full = os_name + os_version
+ blacklist = []
+ cross_build_facts = None
if package_format not in ["deb", "rpm"]:
raise Error("Host {} doesn't support Dockerfiles".format(host))
+ if cross_arch is not None:
+ if package_format != "deb":
+ raise Error("cross compilers only supported for debian packages")
+ if "cross_build" not in facts:
+ raise Error("cross compilers not supported for this host")
+ if cross_arch not in facts["cross_build"]["arches"]:
+ raise Error("unsupported cross compiler architecture, use one of {}".format(
+ ", ".join(facts["cross_build"]["arches"].keys())))
+ cross_build_facts = facts["cross_build"]["arches"][cross_arch]
+ blacklist.extend(facts["cross_build"].get("blacklist", []))
+ blacklist.extend(cross_build_facts.get("blacklist", []))
+
projects = self._projects.expand_pattern(projects)
for project in projects:
if project not in facts["projects"]:
@@ -531,18 +550,31 @@ class Application:
temp[package] = mappings[package][os_full]
pkgs = []
+ cross_pkgs = []
for item in temp:
pkgname = temp[item]
if pkgname is None:
continue
- if pkgname not in pkgs:
- pkgs.append(pkgname)
+ if pkgname in blacklist:
+ continue
+ if cross_arch and pkgname[-4:] == "-dev":
+ if pkgname not in cross_pkgs:
+ cross_pkgs.append(pkgname + ":" + cross_arch)
+ else:
+ if pkgname not in pkgs:
+ pkgs.append(pkgname)
print("FROM {}".format(facts["docker_base"]))
varmap = {}
varmap["pkgs"] = "".join([" \\\n " + pkgname
for pkgname in sorted(pkgs)])
+ if cross_arch:
+ varmap["cross_arch"] = cross_arch
+ varmap["cross_pkgs"] = "".join([" \\\n " + pkgname
+ for pkgname in sorted(cross_pkgs)])
+ varmap["cross_gcc"] = cross_build_facts["gcc-pkg-prefix"]
+ varmap["cross_prefix"] = cross_build_facts["target-prefix"]
if package_format == "deb":
sys.stdout.write(textwrap.dedent("""
RUN DEBIAN_FRONTEND=noninteractive && \\
@@ -554,6 +586,24 @@ class Application:
apt-get autoclean -y \\
)
""") % varmap )
+ if cross_arch:
+ # Intentionally a separate RUN command from the above
+ # so that the common packages of all cross-built images
+ # share a docker image layer
+ sys.stdout.write(textwrap.dedent("""
+ RUN DEBIAN_FRONTEND=noninteractive && \\
+ ( \\
+ dpkg --add-architecture %(cross_arch)s && \\
+ apt-get update && \\
+ apt-get dist-upgrade -y && \\
+ apt-get install --no-install-recommends -y %(cross_gcc)s %(cross_pkgs)s && \\
+ apt-get autoremove -y && \\
+ apt-get autoclean -y \\
+ )
+ ENV TARGET "%(cross_prefix)s"
+ ENV CONFIGURE_OPTS "--host=%(cross_prefix)s --target=%(cross_prefix)s"
+ ENV PKG_CONFIG_LIBDIR "/usr/lib/%(cross_prefix)s/pkgconfig"
+ """) % varmap )
elif package_format == "rpm":
if os_name == "Fedora" and os_version == "Rawhide":
sys.stdout.write(textwrap.dedent("""
@@ -577,11 +627,12 @@ class Application:
hosts = cmdline.h
projects = cmdline.p
git_revision = cmdline.g
+ cross_arch = cmdline.x
method = "_action_{}".format(action.replace("-", "_"))
if hasattr(self, method):
- getattr(self, method).__call__(hosts, projects, git_revision)
+ getattr(self, method).__call__(hosts, projects, git_revision, cross_arch)
else:
raise Error("Invalid action '{}'".format(action))
--
2.20.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Tue, 2019-02-05 at 17:53 +0000, Daniel P. Berrangé wrote:
[...]
> With the Debian 9 distro, this supports arm64, armel, armhf, mips,
> mipsel, mips64el, ppc64el, s390x, which are all the official archs
> that Debian maintainers currently build libvirt for. With Debian Sid,
> this is extended to include i386.
Is i386 really not supported as a cross compilation target on Debian
9? It seems like it would be such a low hanging fruit...
[...]
> +++ b/guests/host_vars/libvirt-debian-9/docker.yml
> @@ -1,2 +1,59 @@
> ---
> docker_base: debian:9
> +cross_build:
I don't think this belongs in docker.yml, since there's nothing
specific to Docker here: we could just as well use this information
to build a virtual machine in which to perform cross builds.
I would create a new fact file, eg. cross-build.yml, for this.
To be completely honest I'm not 100% sold on the structure and
placement of the data, but I can't quite put my fingers on why
that's the case - which of course makes it very difficult to come
up with an alternative suggestion ;) So let's use this structure
for now, we can always change it later if needed.
> + blacklist:
> + # Doesn't properly resolve from foreign arch package
> + # to the native package of augeas-lenses
I cannot really understand what you're trying to say with this
comment, can you try to reword it please?
> + - libnetcf-dev
> + # Fails to resolve deps from foreign arch
> + - wireshark-dev
> + # dtrace tool doesn't know how to cross-compile
> + - systemtap-sdt-dev
For these and all other blacklisted packages, you should list the
name of the mapping (eg. netcf) rather than the concrete Debian
package name (eg. libnetcf-dev). Then of course you'll have to act
on the blacklist earlier, before mapping is performed.
> + arches:
> + arm64:
> + gcc-pkg-prefix: crossbuild-essential-arm64
This is not a prefix, and the package is not GCC :)
I would use 'cross_gcc', which incidentally is also the name of the
variable you use in the Python script to store this value. (More on
this later, though.)
> + target-prefix: aarch64-linux-gnu
Same here, you later use 'cross_prefix' in the script but also store
it as 'TARGET' in the environment... I'd suggest 'cross_target'.
[...]
> + mipsel:
> + gcc-pkg-prefix: gcc-mipsel-linux-gnu
crossbuild-essential-mipsel is available in Debian 9, so you should
use that instead.
[...]
> +++ b/guests/host_vars/libvirt-debian-sid/docker.yml
> @@ -1,2 +1,64 @@
> ---
> docker_base: debian:sid
> +cross_build:
> + blacklist:
> + # Doesn't properly resolve from foreign arch package
> + # to the native package of augeas-lenses
> + - libnetcf-dev
> + # Fails to resolve deps from foreign arch
> + - wireshark-dev
> + # dtrace tool doesn't know how to cross-compile
> + - systemtap-sdt-dev
> + # appears to be dropped from the 'sid' tree
> + - sheepdog
So it has! And it's apparently not going to be in the next Ubuntu
release, either.
This has nothing to do with cross compilation, though: you should
just update the regular mappings file, in a separate commit, based
on this information.
[...]
> + mips64el:
> + gcc-pkg-prefix: gcc-mips64el-linux-gnuabi64
Debian Sid has crossbuild-essential-* packages available for all
cross compilation targets, so please use those everywhere.
Another idea would be to drop these from the facts entirely and
have a bunch of mappings like
cross-gcc-mipsel:
Debian9: gcc-mipsel-linux-gnu
DebianSid: crossbuild-essential-mipsel
instead; then you could programmatically add cross-gcc-$arch to
the package list in the script before mapping is performed. That
sounds to me like it would be much nicer.
[...]
> +++ b/guests/lcitool
> @@ -343,6 +343,11 @@ class Application:
> metavar="GIT_REVISION",
> help="git revision to build (remote/branch)",
> )
> + self._parser.add_argument(
> + "-x",
> + metavar="CROSS-ARCH",
> + help="cross compiler architecture (dockerfile action only)",
> + )
s/CROSS-ARCH/CROSS_ARCH/
[...]
> @@ -501,10 +506,24 @@ class Application:
> os_name = facts["os_name"]
> os_version = facts["os_version"]
> os_full = os_name + os_version
> + blacklist = []
> + cross_build_facts = None
>
> if package_format not in ["deb", "rpm"]:
> raise Error("Host {} doesn't support Dockerfiles".format(host))
>
> + if cross_arch is not None:
> + if package_format != "deb":
> + raise Error("cross compilers only supported for debian packages")
This first check is kinda pointless, since the one right after it
would be triggered when trying to generate a Dockerfile for cross
compilation and the required information has not been provided by
maintainers.
> + if "cross_build" not in facts:
> + raise Error("cross compilers not supported for this host")
raise Error("Host {} doesn't support cross compilation".format(host))
[...]
> + if cross_arch and pkgname[-4:] == "-dev":
> + if pkgname not in cross_pkgs:
> + cross_pkgs.append(pkgname + ":" + cross_arch)
I can see how sticking with the Debian-style architecture names
makes this bit trivial, but I'm still entirely convinced we should
use the same architecture names as libvirt does.
Especially once we'll have integrated this into libvirt's own build
system, the difference in names would introduce needless friction,
as the target audience (libvirt developers) is certainly more
familiar with the architecture names used in that project than
Debian's.
We can avoid that easily enough, by performing the necessary
conversion in the script with a small dedicated utility function.
[...]
> + if cross_arch:
> + # Intentionally a separate RUN command from the above
> + # so that the common packages of all cross-built images
> + # share a docker image layer
Oh, clever! :)
> + sys.stdout.write(textwrap.dedent("""
> + RUN DEBIAN_FRONTEND=noninteractive && \\
> + ( \\
> + dpkg --add-architecture %(cross_arch)s && \\
> + apt-get update && \\
> + apt-get dist-upgrade -y && \\
> + apt-get install --no-install-recommends -y %(cross_gcc)s %(cross_pkgs)s && \\
> + apt-get autoremove -y && \\
> + apt-get autoclean -y \\
> + )
The same considerations about formatting the list of packages as in
patch 7/9 also apply here.
> + ENV TARGET "%(cross_prefix)s"
> + ENV CONFIGURE_OPTS "--host=%(cross_prefix)s --target=%(cross_prefix)s"
> + ENV PKG_CONFIG_LIBDIR "/usr/lib/%(cross_prefix)s/pkgconfig"
As you mention in a previous commit message, each ENV statement
will create and additional layer, and it's considered best practice
to have as few of those as possible.
Another reason why I don't like this is that it's different from
what we already do for the "cross compilation" target we already
support, MinGW: in that case, we have a single image with pristine
environment, and we inject the additional variables only when
actually running the build. In my opinion, that's a saner way to
tweak the build, since the interaction is very explicit and doesn't
require any knowledge of other components that might even be
hosted, as is the case here, in a separate git repository!
Additionally, and I only thought about this now :) did we consider
the possibility of providing a single Debian image with all cross
compilation packages installed, rather than one image per target
architecture? Assuming that's feasible, it would also fit very
nicely with how we have a single Fedora image that we use for both
MinGW variants...
I apologize for the length of this message. If it's any consolation,
it clearly shows that your patches were good food for thought :)
--
Andrea Bolognani / Red Hat / Virtualization
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Thu, Feb 07, 2019 at 04:21:34PM +0100, Andrea Bolognani wrote: > On Tue, 2019-02-05 at 17:53 +0000, Daniel P. Berrangé wrote: > [...] > > With the Debian 9 distro, this supports arm64, armel, armhf, mips, > > mipsel, mips64el, ppc64el, s390x, which are all the official archs > > that Debian maintainers currently build libvirt for. With Debian Sid, > > this is extended to include i386. > > Is i386 really not supported as a cross compilation target on Debian > 9? It seems like it would be such a low hanging fruit... Yes, the i386 gcc simply doesn't exist in 9. No idea why > [...] > > +++ b/guests/host_vars/libvirt-debian-9/docker.yml > > @@ -1,2 +1,59 @@ > > --- > > docker_base: debian:9 > > +cross_build: > > I don't think this belongs in docker.yml, since there's nothing > specific to Docker here: we could just as well use this information > to build a virtual machine in which to perform cross builds. > > I would create a new fact file, eg. cross-build.yml, for this. Ok. In practice this split doesn't seem to actually do anything since we load all files & take the union of their contents. > > + blacklist: > > + # Doesn't properly resolve from foreign arch package > > + # to the native package of augeas-lenses > > I cannot really understand what you're trying to say with this > comment, can you try to reword it please? dpkg fails to resolve the deps. It wants augeas-lenses:s390x when it should be satisfied with augeas-lenses:$NATIVE. You can't install both augeas-lenses as they conflict on files. > > + - libnetcf-dev > > + # Fails to resolve deps from foreign arch > > + - wireshark-dev > > + # dtrace tool doesn't know how to cross-compile > > + - systemtap-sdt-dev > > For these and all other blacklisted packages, you should list the > name of the mapping (eg. netcf) rather than the concrete Debian > package name (eg. libnetcf-dev). Then of course you'll have to act > on the blacklist earlier, before mapping is performed. I don't find that desirable. This is a debian specific config file, and it is clearer to list the actual debian packages we have trouble with, as that's what apt-get is complaining about when it fails. Using the generic mapping obscures what is going on. > > + arches: > > + arm64: > > + gcc-pkg-prefix: crossbuild-essential-arm64 > > This is not a prefix, and the package is not GCC :) > > I would use 'cross_gcc', which incidentally is also the name of the > variable you use in the Python script to store this value. (More on > this later, though.) Actually this entire variable can be eliminated, as we can derive it from the target name. > > > + target-prefix: aarch64-linux-gnu > > Same here, you later use 'cross_prefix' in the script but also store > it as 'TARGET' in the environment... I'd suggest 'cross_target'. Using "cross_" is redundant as this already inside a parent "cross-build" block. > [...] > > + mipsel: > > + gcc-pkg-prefix: gcc-mipsel-linux-gnu > > crossbuild-essential-mipsel is available in Debian 9, so you should > use that instead. Actually, I've eliminated all usage of the crossbuild-essential-* packages. These needlessly pull in the C++ compiler too. > > docker_base: debian:sid > > +cross_build: > > + blacklist: > > + # Doesn't properly resolve from foreign arch package > > + # to the native package of augeas-lenses > > + - libnetcf-dev > > + # Fails to resolve deps from foreign arch > > + - wireshark-dev > > + # dtrace tool doesn't know how to cross-compile > > + - systemtap-sdt-dev > > + # appears to be dropped from the 'sid' tree > > + - sheepdog > > So it has! And it's apparently not going to be in the next Ubuntu > release, either. What's missing that we've not seen this problem already ? Is it just because we don't regularlyl rebuild the CI hosts / images ? > > + if cross_arch and pkgname[-4:] == "-dev": > > + if pkgname not in cross_pkgs: > > + cross_pkgs.append(pkgname + ":" + cross_arch) > > I can see how sticking with the Debian-style architecture names > makes this bit trivial, but I'm still entirely convinced we should > use the same architecture names as libvirt does. > Especially once we'll have integrated this into libvirt's own build > system, the difference in names would introduce needless friction, > as the target audience (libvirt developers) is certainly more > familiar with the architecture names used in that project than > Debian's. Using the libvirt arch names adds no value. There's no friction as there is no context in which we're using the libvirt arch names & need a mapping to the cross build names. These image configs are distro specific and using the distro's native arch is directly relevant to the build results. > > + ENV TARGET "%(cross_prefix)s" > > + ENV CONFIGURE_OPTS "--host=%(cross_prefix)s --target=%(cross_prefix)s" > > + ENV PKG_CONFIG_LIBDIR "/usr/lib/%(cross_prefix)s/pkgconfig" > > As you mention in a previous commit message, each ENV statement > will create and additional layer, and it's considered best practice > to have as few of those as possible. The difference is the usage context. The ENV statement is intended to provide environment variables to runtime users of the image. The previous ENV usage was merely used internally to the docker build and was polluting the runtime env where it was not required. These ENV statements are intended for direct usage in the docker images at runtime, so you can launch the image with docker and simply type "$TARGET-gcc" or "./configure $CONFIGURE_OPTS" and have it do the right thing. > Another reason why I don't like this is that it's different from > what we already do for the "cross compilation" target we already > support, MinGW: in that case, we have a single image with pristine > environment, and we inject the additional variables only when > actually running the build. In my opinion, that's a saner way to > tweak the build, since the interaction is very explicit and doesn't > require any knowledge of other components that might even be > hosted, as is the case here, in a separate git repository! The mingw images are slightly different in that the Fedora mingw RPMs have invented a "mingw32-configure" program that sets all these env variables already. If that program didn't exist, then it would be desirable to have the same env vars set for the mingw images too. > Additionally, and I only thought about this now :) did we consider > the possibility of providing a single Debian image with all cross > compilation packages installed, rather than one image per target > architecture? Assuming that's feasible, it would also fit very > nicely with how we have a single Fedora image that we use for both > MinGW variants... Creating a single image would mean a significantly larger download image size when you only care about testing a single architecture. Because of the way image layer sharing works, having lots of separate images ensures you can have a minimal download size for a single image, while not giving duplication if you need to download all images. We ought to have a separate Fedora image for each MinGW target for this same reason in fact. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Wed, 2019-02-13 at 18:52 +0000, Daniel P. Berrangé wrote:
> On Thu, Feb 07, 2019 at 04:21:34PM +0100, Andrea Bolognani wrote:
> > On Tue, 2019-02-05 at 17:53 +0000, Daniel P. Berrangé wrote:
> > [...]
> > > With the Debian 9 distro, this supports arm64, armel, armhf, mips,
> > > mipsel, mips64el, ppc64el, s390x, which are all the official archs
> > > that Debian maintainers currently build libvirt for. With Debian Sid,
> > > this is extended to include i386.
> >
> > Is i386 really not supported as a cross compilation target on Debian
> > 9? It seems like it would be such a low hanging fruit...
>
> Yes, the i386 gcc simply doesn't exist in 9. No idea why
Pretty weird indeed.
But that kinda leads into the question: why having Debian 9 support
at all? We're only going to have a single set of buildenv-cross-*
images, one per architecture, and those are going to be based on
Debian Sid, no? Just like we use Fedora Rawhide for MinGW builds.
So adding Debian 9 into the mix seems unnecessary.
> > [...]
> > > +++ b/guests/host_vars/libvirt-debian-9/docker.yml
> > > @@ -1,2 +1,59 @@
> > > ---
> > > docker_base: debian:9
> > > +cross_build:
> >
> > I don't think this belongs in docker.yml, since there's nothing
> > specific to Docker here: we could just as well use this information
> > to build a virtual machine in which to perform cross builds.
> >
> > I would create a new fact file, eg. cross-build.yml, for this.
>
> Ok. In practice this split doesn't seem to actually do anything
> since we load all files & take the union of their contents.
It's just to keep things organized :)
> > > + blacklist:
> > > + # Doesn't properly resolve from foreign arch package
> > > + # to the native package of augeas-lenses
> >
> > I cannot really understand what you're trying to say with this
> > comment, can you try to reword it please?
>
> dpkg fails to resolve the deps. It wants augeas-lenses:s390x
> when it should be satisfied with augeas-lenses:$NATIVE. You
> can't install both augeas-lenses as they conflict on files.
Got it.
> > > + - libnetcf-dev
> > > + # Fails to resolve deps from foreign arch
> > > + - wireshark-dev
> > > + # dtrace tool doesn't know how to cross-compile
> > > + - systemtap-sdt-dev
> >
> > For these and all other blacklisted packages, you should list the
> > name of the mapping (eg. netcf) rather than the concrete Debian
> > package name (eg. libnetcf-dev). Then of course you'll have to act
> > on the blacklist earlier, before mapping is performed.
>
> I don't find that desirable. This is a debian specific config
> file, and it is clearer to list the actual debian packages we
> have trouble with, as that's what apt-get is complaining about
> when it fails. Using the generic mapping obscures what is
> going on.
That's true every time package names are involved, and everywhere
else we use the abstract names rather than the concrete ones. We
should use them here as well, not only to be consistent but also
so that we only ever have to update a single file when the concrete
package names change.
> > > + arches:
> > > + arm64:
> > > + gcc-pkg-prefix: crossbuild-essential-arm64
> >
> > This is not a prefix, and the package is not GCC :)
> >
> > I would use 'cross_gcc', which incidentally is also the name of the
> > variable you use in the Python script to store this value. (More on
> > this later, though.)
>
> Actually this entire variable can be eliminated, as we can derive
> it from the target name.
Alright, I had suggested doing that with the arch name and
crossbuild-essential-*, but using the target and gcc-* works just
as nicely :)
> > > + target-prefix: aarch64-linux-gnu
> >
> > Same here, you later use 'cross_prefix' in the script but also store
> > it as 'TARGET' in the environment... I'd suggest 'cross_target'.
>
> Using "cross_" is redundant as this already inside a parent "cross-build"
> block.
Alright.
> > [...]
> > > + mipsel:
> > > + gcc-pkg-prefix: gcc-mipsel-linux-gnu
> >
> > crossbuild-essential-mipsel is available in Debian 9, so you should
> > use that instead.
>
> Actually, I've eliminated all usage of the crossbuild-essential-*
> packages. These needlessly pull in the C++ compiler too.
Okay.
> > > docker_base: debian:sid
> > > +cross_build:
> > > + blacklist:
> > > + # Doesn't properly resolve from foreign arch package
> > > + # to the native package of augeas-lenses
> > > + - libnetcf-dev
> > > + # Fails to resolve deps from foreign arch
> > > + - wireshark-dev
> > > + # dtrace tool doesn't know how to cross-compile
> > > + - systemtap-sdt-dev
> > > + # appears to be dropped from the 'sid' tree
> > > + - sheepdog
> >
> > So it has! And it's apparently not going to be in the next Ubuntu
> > release, either.
>
> What's missing that we've not seen this problem already ? Is it
> just because we don't regularlyl rebuild the CI hosts / images ?
Yeah, we hadn't triggered a build for Docker images in a while,
and as for the virtual machine running builds on ci.centos.org we
don't rebuild those unless there's some issue, so it's happily
hanging on to the local copy of sheepdog it installed back when it
was still part of Debian Sid.
> > > + if cross_arch and pkgname[-4:] == "-dev":
> > > + if pkgname not in cross_pkgs:
> > > + cross_pkgs.append(pkgname + ":" + cross_arch)
> >
> > I can see how sticking with the Debian-style architecture names
> > makes this bit trivial, but I'm still entirely convinced we should
> > use the same architecture names as libvirt does.
> > Especially once we'll have integrated this into libvirt's own build
> > system, the difference in names would introduce needless friction,
> > as the target audience (libvirt developers) is certainly more
> > familiar with the architecture names used in that project than
> > Debian's.
>
> Using the libvirt arch names adds no value. There's no friction as
> there is no context in which we're using the libvirt arch names &
> need a mapping to the cross build names. These image configs are
> distro specific and using the distro's native arch is directly
> relevant to the build results.
The context is libvirt developers running a cross build through the
build system integration, eg. using your proposed implementation
you'd need to use
$ make cibuild-cross-arm64
instead of the much more natural (to libvirt developers)
$ make cibuild-cross-aarch64
Now, having to mentally map 'aarch64' to 'arm64' might not be a lot
of friction, but it's still some friction, and it's completely
unnecessary too because we can perform the architecture mapping very
easily in lcitool and make it completely transparent to all other
tools and users.
> > > + ENV TARGET "%(cross_prefix)s"
> > > + ENV CONFIGURE_OPTS "--host=%(cross_prefix)s --target=%(cross_prefix)s"
> > > + ENV PKG_CONFIG_LIBDIR "/usr/lib/%(cross_prefix)s/pkgconfig"
> >
> > As you mention in a previous commit message, each ENV statement
> > will create and additional layer, and it's considered best practice
> > to have as few of those as possible.
>
> The difference is the usage context. The ENV statement is intended
> to provide environment variables to runtime users of the image. The
> previous ENV usage was merely used internally to the docker build
> and was polluting the runtime env where it was not required.
Okay, point taken.
> These ENV statements are intended for direct usage in the docker
> images at runtime, so you can launch the image with docker and
> simply type "$TARGET-gcc" or "./configure $CONFIGURE_OPTS" and
> have it do the right thing.
I guess what I don't like is using something that's Docker-specific
to inject this kind of information into the guest OS, because in
my mind you should end up with a mostly identical environment
whether you're building in a virtual machines created using lcitool
or inside a Docker container.
The way we get this kind of information into virtual machines is
through a combination of static, job-agnostic variables set in the
user's .bashrc and job-specific variables passed by whatever
process is running the build.
Looking at the variables above, TARGET belongs to the former group
and CONFIGURE_OPTS to the latter, with PKG_CONFIG_LIBDIR sitting
uncomfortably somewhere in between.
Now, we're not adding a custom .bashrc at all when using Docker,
so I guess using ENV directives instead is fine. But poisoning the
user environment by setting PKG_CONFIG_LIBDIR globally might not be,
and having a magic CONFIGURE_OPTS that build commands are somehow
just supposed to know exists is very much not cool.
What I'd like to see instead is something like
docker \
-e PKG_CONFIG_LIBDIR='/usr/lib/$TARGET/pkgconfig' \
-e autogen_args='--host=$TARGET --target=$TARGET' \
...
/bin/sh -xc './autogen.sh $autogen_args'
but I just realized that such a thing wouldn't really work because
the variables won't be expanded inside the container, and so you'd
just get the literal string '$TARGET' which is of course no good :(
Alright, ENV directives it is I guess :(
> > Another reason why I don't like this is that it's different from
> > what we already do for the "cross compilation" target we already
> > support, MinGW: in that case, we have a single image with pristine
> > environment, and we inject the additional variables only when
> > actually running the build. In my opinion, that's a saner way to
> > tweak the build, since the interaction is very explicit and doesn't
> > require any knowledge of other components that might even be
> > hosted, as is the case here, in a separate git repository!
>
> The mingw images are slightly different in that the Fedora mingw
> RPMs have invented a "mingw32-configure" program that sets all
> these env variables already. If that program didn't exist, then
> it would be desirable to have the same env vars set for the mingw
> images too.
Yeah, that's kind of a shortcut that we took in our travis.yml
compared to what we do on ci.centos.org or local builds through
lcitool, where we call good 'ol configure with appropriate arguments
after adding all the necessary variables into the environment.
Personally I don't much like the discrepancy, as I believe we should
perform all builds the same way regardless of the environment to
guarantee consistency, but it is way shorter and more convenient so
I guess we're keeping it :) Especially since the issue mentioned
above makes it hard to do anything else :(
> > Additionally, and I only thought about this now :) did we consider
> > the possibility of providing a single Debian image with all cross
> > compilation packages installed, rather than one image per target
> > architecture? Assuming that's feasible, it would also fit very
> > nicely with how we have a single Fedora image that we use for both
> > MinGW variants...
>
> Creating a single image would mean a significantly larger download
> image size when you only care about testing a single architecture.
> Because of the way image layer sharing works, having lots of
> separate images ensures you can have a minimal download size for
> a single image, while not giving duplication if you need to download
> all images.
Okay, this makes sense.
> We ought to have a separate Fedora image for each MinGW target for
> this same reason in fact.
First step would be to rip the MinGW stuff out of the regular
Fedora Rawhide configuration; after that we can definitely move
to separate images.
--
Andrea Bolognani / Red Hat / Virtualization
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2026 Red Hat, Inc.