diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2019-01-18 04:15:30 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-01-18 04:43:15 +0000 |
commit | d67871786829bb27df798d4207aaacbd90e893b5 (patch) | |
tree | 52a6c037c312afb29e773075d8adcb76cb750bfc | |
download | klibc-maint-d67871786829bb27df798d4207aaacbd90e893b5.tar.gz |
Add script to (cross-)build and test klibc for many architectures
This script assumes Debian conventions for cross-compilers etc.
-rwxr-xr-x | test-many-klibcs | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/test-many-klibcs b/test-many-klibcs new file mode 100755 index 0000000..d1c6b22 --- /dev/null +++ b/test-many-klibcs @@ -0,0 +1,92 @@ +#!/bin/bash -eu + +build() { + local arch kernelarch gnuarch makeflags + + arch="$1" + kernelarch="$2" + gnuarch="$3" + makeflags="${5:-}" + + echo "I: Using $("$gnuarch-gcc" --version | head -1)" + echo "I: Using $("$gnuarch-ld" --version | head -1)" + + echo "I: Generating kernel UAPI headers for ARCH=$kernelarch" + rm -rf ../linux/usr/include || return + make -C ../linux "ARCH=$kernelarch" headers_install || return + echo "I: Building with ARCH=$arch CROSS_COMPILE=$gnuarch- $makeflags" + make -C ../klibc all "ARCH=$arch" "CROSS_COMPILE=$gnuarch-" $makeflags \ + || return +} + +clean() { + local arch="$1" + + echo "I: Cleaning" + make -C ../klibc clean "ARCH=$arch" +} + +run_tests() { + local qemuarch="$4" + + echo "I: Testing statically linked shell running builtin command" + "qemu-$qemuarch-static" ../klibc/usr/dash/sh -c "exit" || return + echo "I: Testing statically linked shell running external command" + "qemu-$qemuarch-static" ../klibc/usr/dash/sh -c "../klibc/usr/utils/static/true; exit" || return + # TODO: build a chroot environment and run with shared library +} + +process() { + local arch + + arch="$1/$3" # klibc/GNU arch + + echo "I: Architecture $arch: begin" + if clean "$@" && build "$@" && run_tests "$@"; then + echo "I: Architecture $arch: pass" + else + echo "E: Architecture $arch: fail" + fi + clean "$@" || true +} + +echo "I: $0 started at $(date)" +echo "I: Using klibc $(GIT_DIR=../klibc/.git git describe)" +echo "I: Using Linux $(make -C ../linux -s kernelversion)" + +rm -rf ../klibc/linux +ln -s ../linux/usr ../klibc/linux + +process alpha alpha alpha-linux-gnu alpha +# arm OABI is no longer supported in Debian. +#process arm arm arm-linux-gnu arm +process arm arm arm-linux-gnueabi arm "CONFIG_AEABI=y" +process arm arm arm-linux-gnueabihf arm "CONFIG_AEABI=y CPU_ARCH=armv7-a CPU_TUNE=cortex-a8 CONFIG_KLIBC_THUMB=y" +process arm64 arm64 aarch64-linux-gnu aarch64 +# cris is not supported in Debian. +#process cris cris cris-linux-gnu cris +process i386 x86 i686-linux-gnu i386 +# ia64 cross-compiler is currently missing in Debian, as is QEMU support. +#process ia64 ia64 ia64-linux-gnu ??? +process m68k m68k m68k-linux-gnu m68k +process mips mips mips-linux-gnu mips +process mips mips mipsel-linux-gnu mipsel +# Big-endian mips64 is not supported in Debian. +#process mips64 mips mips64-linux-gnuabi64 mips64 +process mips64 mips mips64el-linux-gnuabi64 mips64el +process parisc parisc hppa-linux-gnu hppa +process ppc powerpc powerpc-linux-gnu ppc +process ppc powerpc powerpc-linux-gnuspe ppc +process ppc64 powerpc powerpc64-linux-gnu ppc64 +process ppc64 powerpc powerpc64le-linux-gnu ppc64le +process riscv64 riscv riscv64-linux-gnu riscv64 +# 32-bit s390 is no longer supported in Debian. +#process s390 s390 s390-linux-gnu s390 +process s390x s390 s390x-linux-gnu s390x +process sh sh sh4-linux-gnu sh4 +# 32-bit sparc is no longer supported in Debian. +#process sparc sparc sparc-linux-gnu sparc +process sparc64 sparc sparc64-linux-gnu sparc64 +process x86_64 x86 x86_64-linux-gnu x86_64 + +echo "I: $0 finished at $(date)" |