Multi-arch SliTaz 5.1

SliTaz 5.1 is built for two architectures: i486, the 32-bit one, for old PCs, and x86_64. Both come from the same wok: one receipt per package, and the build host cooks each receipt once for each architecture. This page shows how a receipt says where it builds, how it handles what differs between the two, and how to cook both. The receipt itself is explained in Receipt.

What changes from one arch to the other

The architecture is ARCH in /etc/slitaz/cook.conf: i486 or x86_64. cook sets from it:

Libraries go to /usr/lib on both: SliTaz x86_64 has no separate lib64. cook sets it for ./configure; with CMake, pass -DCMAKE_INSTALL_LIBDIR=lib, as many receipts of the wok do.

HOST_ARCH: where a receipt builds

HOST_ARCH lists the architectures a receipt is cooked for:

HOST_ARCH="i486 x86_64"

On an architecture left out, cook does not fail: it prints package "foo" doesn't cook or is not included in x86_64 and stops. When you leave an architecture out, say why in a comment, so the next person knows what to fix:

HOST_ARCH="i486"	# no bdep libwebkit in x86_64

When a 32-bit program fails on x86_64, cook gives a hint at the end of the log: a -march forced in a Makefile ("CPU you selected does not support x86-64"), or 32-bit registers and inline assembly. Remove the forced flag, or set HOST_ARCH="i486".

case "$ARCH": one receipt, two ways

When something differs, test $ARCH with a case in the receipt. Outside the functions, it can change the source, here a prebuilt binary (restic):

case "$ARCH" in
	i?86)	TARBALL="${PACKAGE}_${VERSION}_linux_386.bz2" ;;
	*)	TARBALL="${PACKAGE}_${VERSION}_linux_amd64.bz2" ;;
esac

or even the version, when the two architectures follow different releases (the Firefox language packs):

case "$ARCH" in
	x86_64)	VERSION="153.0esr"; MOZ_ARCH="linux-x86_64" ;;
	*)	VERSION="140.13.0esr"; MOZ_ARCH="linux-i686" ;;
esac

Inside compile_rules, it fixes the build for one architecture only, here a Makefile that forces 32-bit code (chntpw):

case "$ARCH" in
	x86_64) sed -i 's/ -m32//g' Makefile ;;
esac

Two habits:

Cooking for both

On an x86_64 SliTaz you can cook for both: the 64-bit kernel runs 32-bit programs, so an i486 chroot works. cook runs its i486 builds with a 32-bit personality, so build scripts that ask the system see i686, not x86_64. An i486 system cannot cook for x86_64.

Make an i486 chroot with tazdev, as root (package slitaz-dev-tools):

# tazdev gen-chroot --arch=i486 \
	--mirror=https://mirror.slitaz.org/i486/cooking/packages/
# tazdev chroot --arch=i486

See Building in a chroot in the Handbook. The chroot shares /home/slitaz/src with your system, so a source is downloaded once, but not your wok: copy the package directory into the chroot's /home/slitaz/wok, then cook it there as usual. Its packages land in /home/slitaz/cooking/i486/packages on your system.

Cook in a chroot even for your own architecture before you share a receipt: the build host starts from a clean system and installs only what BUILD_DEPENDS lists.

One wok, both arches

The wok is one Mercurial repository for both architectures: commit a fix once, and the build host cooks it on i486 and x86_64. If you keep two clones, one per chroot, commit in one and hg pull -u in the other: the same change committed in both makes two heads to merge. See Mercurial.

After a push, check the result of both architectures on cook.slitaz.org: a receipt can build on one and break on the other.