-
Notifications
You must be signed in to change notification settings - Fork 0
Crosscompiling
Gentoo is designed to compile native for system the compiling process is going on. Therefore the best way to compile packages for other system is to emulate the target system and then compile in emulator. Because any emulation is slow comparing to native execution, it is possible to move some compiling tasks back to the native host with cross-compiler.
Kernel is required with CONFIG_BINFMT_MISC is set.
The qemu needs to be compiled with static-user USE-flag and the Switch-compatible target "aarch64"
echo 'app-emulation/qemu static-user' > /etc/portage/package.use/qemu
echo 'QEMU_USER_TARGETS="aarch64"' >> /etc/portage/make.conf
emerge app-emulation/qemu
/etc/init.d/qemu-binfmt start # Done in `./qemu-chroot.sh` script
The trick is to copy /usr/bin/qemu-aarch64 to an aarch64 root, then you can chroot this root like native, and work with the emulated target arch aarch64. See the ./qemu-chroot.sh script for more details.
The script collection is designed to have an nintendo switch root in ./root/ directory for cross-compiling environment. To enter the environment the ./qemu-chroot.sh should be used.
To get faster compilation times I recommend to use cross-compiler and distcc to speed up the workload. The Cross-Compiler you can get with crossdev.
emerge crossdev distcc
crossdev -S -t aarch64-unknown-linux-gnu
distcc needs to be emerged/installed on both, host and in the qemu-chroot.
Then on host the --allow 127.0.0.0/24" is enough in /etc/conf.d/distcc
In qemu-chroot the 127.0.0.1:3632 (IP with Port!) needed in /etc/distcc/hosts to send compiling tasks to host distcc cross-compiler. See ./buildscripts/update_buildhost.sh for more details.
At the first clone download and install this repo with all submodules
git clone --recurse-submodules https://github.com/bell07/bashscripts-switch_gentoo switch_gentoo
Then Way 1: (faster, if release tarball already downloaded): go into the script directory and extract the Gentoo release tarball to ./root/
mkdir ./root/
cd ./root/
tar -zvxf switch-gentoo-release-2019-08-29.tar.gz
cd ..
./buildscripts/update_buildhost.sh
Way 2: Bootstrap using release builder script
./buildscripts/build_release.sh
cp -a ./out/release ./root/
./buildscripts/update_buildhost.sh
./qemu-chroot.sh
emerge what you need
By default binary packages are rebuilt in the buildhost root trough FEATURES="-getbinpkg" See into ./buildscripts/update_buildhost.sh implementation for more info
exit
rsync -av --delete --progress packages your_binhost:/var/www/localhost/htdocs/pub/gentoo-switch-gcc9/