Skip to content

abuild: allow three-way cross-compilation

Ghost User requested to merge (removed):master into master

Currently abuild does not work when $CBUILD != $CHOST != $CTARGET, this patch adds support for three-way cross-compilation by introducing a new environment variable, $CTARGET_BUILDROOT, and by tweaking the way host and target dependencies are handled by abuild.

$CBUILDROOT is the sysroot for $CARCH and $CTARGET_BUILDROOT is the sysroot for $CTARGET_ARCH. When performing a two-way cross-targeting build (i.e. $CBUILD == $CHOST && $CHOST != $CTARGET) we continue to set $CBUILDROOT to the sysroot for $CTARGET_ARCH in order to ensure existing aports and scripts continue to work without modifications. However once these changes are pushed to production, main/binutils, main/gcc, and scripts/bootstrap.sh should be updated to use $CTARGET_BUILDROOT instead of $CBUILDROOT in order to support both two-way and three-way cross-compilation.

In order to test these changes the following builds were performed:

1. Running bootstrap.sh for s390x
scripts/bootstrap.sh s390x
2. Building native build-base
APKBUILD="${APORTSDIR}/main/binutils/APKBUILD" \
BOOTSTRAP=nobase \
abuild -f -r
APKBUILD="${APORTSDIR}/main/gcc/APKBUILD" \
BOOTSTRAP=nobase \
abuild -f -r
APKBUILD="${APORTSDIR}/main/build-base/APKBUILD" \
BOOTSTRAP=nobase \
abuild -f -r
3. Building native build-base-s390x
APKBUILD="${APORTSDIR}/main/binutils/APKBUILD" \
BOOTSTRAP=nobase \
CTARGET=s390x \
abuild -f -r
APKBUILD="${APORTSDIR}/main/gcc/APKBUILD" \
BOOTSTRAP=nobase \
CTARGET=s390x \
EXTRADEPENDS_TARGET="musl-dev" \
LANG_ADA=false \
abuild -f -r
APKBUILD="${APORTSDIR}/main/build-base/APKBUILD" \
BOOTSTRAP=nobase \
CTARGET=s390x \
abuild -f -r
4. Building s390x build-base-s390x
APKBUILD="${APORTSDIR}/main/binutils/APKBUILD" \
CTARGET=s390x \
CHOST=s390x \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
abuild -f -r
APKBUILD="${APORTSDIR}/main/gcc/APKBUILD" \
CTARGET=s390x \
CHOST=s390x \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
LANG_ADA=false \
abuild -f -r
APKBUILD="${APORTSDIR}/main/build-base/APKBUILD" \
CTARGET=s390x \
CHOST=s390x \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
abuild -f -r
5. Building aarch64 build-base-s390x1
APKBUILD="${APORTSDIR}/main/binutils/APKBUILD" \
CTARGET=s390x \
CHOST=aarch64 \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
abuild -f -r
APKBUILD="${APORTSDIR}/main/gcc/APKBUILD" \
CTARGET=s390x \
CHOST=aarch64 \
EXTRADEPENDS_TARGET="libgcc libstdc++ musl-dev" \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
LANG_ADA=false \
abuild -f -r
APKBUILD="${APORTSDIR}/main/build-base/APKBUILD" \
CTARGET=s390x \
CHOST=aarch64 \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
abuild -f -r
6. Building s390x build-base-x86_641,2
APKBUILD="${APORTSDIR}/main/binutils/APKBUILD" \
CTARGET=x86_64 \
CHOST=s390x \
CTARGET_BUILDROOT=/ \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
abuild -f -r
APKBUILD="${APORTSDIR}/main/gcc/APKBUILD" \
CTARGET=x86_64 \
CHOST=s390x \
CTARGET_BUILDROOT=/ \
EXTRADEPENDS_TARGET="libgcc libstdc++ musl-dev" \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
LANG_ADA=false \
abuild -f -r
APKBUILD="${APORTSDIR}/main/build-base/APKBUILD" \
CTARGET=x86_64 \
CHOST=s390x \
CTARGET_BUILDROOT=/ \
EXTRADEPENDS_HOST="libgcc libstdc++ musl-dev" \
abuild -f -r

1 Requires changing $CBUILDROOT to $CTARGET_BUILDROOT in main/binutils and main/gcc.
2 Setting CTARGET_BUILDROOT=/ allows targeting the native arch without having to create a separate sysroot.

Merge request reports

Loading