virtual packages regression broke cross compiling gcc (makedepends_host uninstall makedepends_build)
The logic for virtual packages in apk was changed a few times recently, and now the way we cross compile gcc in postmarketOS is broken. I can reproduce it as follows with a clean Alpine chroot and Alpine's gcc aport without modifications (full log):
$ cd aports/main/gcc
$ C_TARGET_ARCH=armhf CTARGET=armv6-alpine-linux-musleabihf BOOTSTRAP=nobuildbase CBUILDROOT=/ abuild -r
...
>>> gcc-armhf: Analyzing dependencies...
>>> gcc-armhf: Installing for build: binutils-armhf isl gcc g++ paxmark bison flex texinfo gawk zip gmp-dev mpfr-dev mpc1-dev zlib-dev gcc-gnat linux-headers isl-dev !gettext-dev
...
(1/24) Installing binutils-armhf (2.31.1-r2)
(2/24) Installing paxmark (0.11-r1)
(3/24) Installing m4 (1.4.18-r1)
(4/24) Installing bison (3.3.2-r0)
(5/24) Installing flex (2.6.4-r2)
...
(24/24) Upgrading .makedepends-gcc-armhf (20190714.104650 -> 20190714.104731)
Executing busybox-1.30.1-r2.trigger
OK: 362 MiB in 78 packages
>>> gcc-armhf: Installing for host:
(1/24) Upgrading .makedepends-gcc-armhf (20190714.104731 -> 20190714.104741)
(2/24) Purging binutils-armhf (2.31.1-r2)
(3/24) Purging paxmark (0.11-r1)
(4/24) Purging bison (3.3.2-r0)
(5/24) Purging flex (2.6.4-r2)
...
OK: 171 MiB in 55 packages
...
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
So abuild installs $makedepends_build (gmp-dev, mpfr-dev, mpc1-dev, ...) first, then $makedepends_host (empty). Both use the same virtual package, but now the empty $makedepends_host list is seen as upgrade from the $makedepends_build, and therefore all packages get purged before building.
Is this a regression in apk, a bug in abuild, or is the way we are trying to build the package (with CBUILDROOT=/) not supported?
CC: @fabled
EDIT: using Alpine edge, latest apk-tools 2.10.4-r2 and latest abuild 3.4.0-r0. Cross compiling the same way used to work two weeks ago or so, so this is likely introduced by the latest patch (though I did not bisect).