external_deps: add a tool to build cross-compilers
Add a tool to build cross-compilers.
This is currently a proof of concept and it is not used yet. The toolchains are built with crosstool-NG.
It is rebased on:
- https://github.com/DaemonEngine/Daemon/pull/874
The build.sh script can optionally use the built toolchain with --with-toolchain.
The idea is that someone can do:
./build-toolchain.sh linux-arm64
./build.sh --with-toolchain linux-arm64-default jpeg
As I was testing the ability to do it, the script currently builds the compiler with the oldest glibc and oldest kernel the crosstool-NG because I wanted to verify the ability to build new compilers with old glibc. We may not want to build the oldest glibc possible if there is some advantage to not use a too-old glibc. I haven't seen any way to force any old libc++, so I don't know how the builds behave on that side of things.
This is something I get on Debian Buster:
$ ./build.sh linux-arm64-default jpeg
-- The C compiler identification is GNU 8.3.0
…
-- Performing Test HAVE_VLD1_S16_X3
-- Performing Test HAVE_VLD1_S16_X3 - Failed
-- Performing Test HAVE_VLD1_U16_X2
-- Performing Test HAVE_VLD1_U16_X2 - Success
-- Performing Test HAVE_VLD1Q_U8_X4
-- Performing Test HAVE_VLD1Q_U8_X4 - Failed
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/aarch64-linux-gnu-gcc
-- Use partial Neon SIMD intrinsics implementation (NEON_INTRINSICS = OFF)
-- CMAKE_ASM_FLAGS = -fPIC -march=armv8-a -O3 -DNDEBUG
$ ./build.sh --toolchain linux-arm64-default jpeg
-- The C compiler identification is GNU 11.2.0
…
-- Performing Test HAVE_VLD1_S16_X3
-- Performing Test HAVE_VLD1_S16_X3 - Success
-- Performing Test HAVE_VLD1_U16_X2
-- Performing Test HAVE_VLD1_U16_X2 - Success
-- Performing Test HAVE_VLD1Q_U8_X4
-- Performing Test HAVE_VLD1Q_U8_X4 - Success
-- The ASM compiler identification is GNU
-- Found assembler: Unvanquished/daemon/external_deps/toolchains_1/linux-arm64/bin/aarch64-unknown-linux-gnu-gcc
-- Use partial Neon SIMD intrinsics implementation (NEON_INTRINSICS = OFF)
-- CMAKE_ASM_FLAGS = -fPIC -march=armv8-a -O3 -DNDEBUG
Unfortunately this is not using NEON yet, but we can see the compiler being upgraded and some tests succeeding.
Edit: that's because libjpeg-turbo needs GCC 12 for Neon, but ct-ng 1.25.0 (latest) still provides no more than GCC 11. The ct-ng tool from repository can build GCC 12 and GCC 13.
What's the main purpose of this? Is it mainly the old libc thing or is it actually needed for cross-compiling?
I'm trying to get a way to build the deps and the game with a new compiler but with an old libc.
With that script I managed to build a GCC11 with an old libc on Debian Buster and build a deps. I have not tested more but that starts to look good.