Skip to content

FreeBSD all architectures via jail and exampleΒ #125

@am11

Description

@am11

Background

At present, there is only FreeBSD amd64 image available by GCE and CirrusCI. To be able to configure CI/CD for other architectures, user has option to resort to cross-compilation scenarios.

Problem Statement

Unlike Linux, where we can set up a cross-compiler toolchain and build binaries for other architectures, I could not find a way to make GCC or Clang to produce 32-bit binaries on FreeBSD with lib32.txz and -m32 compiler switch. Although not clearly documented, but it appears like FreeBSD does not support cross-compilation and instead recommends jail(2) as a solution to such scenarios.

The creation of jail is not straightforward either. There is a native way, e.g. https://gundersen.net/32bit-jail-on-64bit-freebsd/, and then there are some wrapper tools from ports that provide the ability to create jails: iocell, iocage, ezjail, cbsd etc. In my little research, none of these tools are natural fit (do not scale well) for most common CI/CD build pipelines where the basic scenarios are: build, test and upload artifacts (to GitHub etc.). Some methods/tools require manual configurations for network, ZFS pool etc., others are yet to support cross architectures.

Proposal 1

In theory, to build xarch 32-bit binaries on CirrusCI, user can configure FreeBSD jail for ia32. Similarly, arm and Aarch64 archs could be entertained.

Since it takes a lot of effort to get a basic jail up and working even on a baremetal (unless user is area expert in FreeBSD jails and skels); it would be very useful if docs could reflect a .cirrus.yml example on how to create and cache i386/ARM jail environments, so community can effectively make use of it in common CI/CD scenarios.

Proposal 2

It would be even more efficient and less error-prone for consumers, if Cirrus Labs could instead provide a slim abstraction over 'cached' jails, to avoid downloading of base.txz and caching it in varied (suboptimal) ways. This way, the downstreamers would be able to do something like:

freebsd_instance:
  image: freebsd-11-2-release-amd64

freebsd_build_amd64_task:
...

freebsd_instance:
  image: freebsd-11-2-release-amd64
  target_architecture: i386

freebsd_build_i386_task:
...

freebsd_instance:
  image: freebsd-11-2-release-amd64
  target_architecture: arm

freebsd_build_arm_task:
...

freebsd_instance:
  image: freebsd-11-2-release-amd64
  target_architecture: aarch64

freebsd_build_aarch64_task:
...

upload_artifacts_task:
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions