tests/docker: Add debian-microblaze-cross image
[qemu.git] / tests / docker / dockerfiles / debian-microblaze-cross.d / build-toolchain.sh
blob23ec0aa9a724cb171b4be64ea01e232148e864be
1 #!/bin/bash
3 set -e
5 TARGET=microblaze-linux-musl
6 LINUX_ARCH=microblaze
8 J=$(expr $(nproc) / 2)
9 TOOLCHAIN_INSTALL=/usr/local
10 TOOLCHAIN_BIN=${TOOLCHAIN_INSTALL}/bin
11 CROSS_SYSROOT=${TOOLCHAIN_INSTALL}/$TARGET/sys-root
13 export PATH=${TOOLCHAIN_BIN}:$PATH
16 # Grab all of the source for the toolchain bootstrap.
19 wget https://ftp.gnu.org/gnu/binutils/binutils-2.37.tar.xz
20 wget https://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz
21 wget https://www.musl-libc.org/releases/musl-1.2.2.tar.gz
22 wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.70.tar.xz
24 tar axf binutils-2.37.tar.xz
25 tar axf gcc-11.2.0.tar.xz
26 tar axf musl-1.2.2.tar.gz
27 tar axf linux-5.10.70.tar.xz
29 mv binutils-2.37 src-binu
30 mv gcc-11.2.0 src-gcc
31 mv musl-1.2.2 src-musl
32 mv linux-5.10.70 src-linux
34 mkdir -p bld-hdr bld-binu bld-gcc bld-musl
35 mkdir -p ${CROSS_SYSROOT}/usr/include
38 # Install kernel headers
41 cd src-linux
42 make headers_install ARCH=${LINUX_ARCH} INSTALL_HDR_PATH=${CROSS_SYSROOT}/usr
43 cd ..
46 # Build binutils
49 cd bld-binu
50 ../src-binu/configure --disable-werror \
51 --prefix=${TOOLCHAIN_INSTALL} --with-sysroot --target=${TARGET}
52 make -j${J}
53 make install
54 cd ..
57 # Build gcc, just the compiler so far.
60 cd bld-gcc
61 ../src-gcc/configure --disable-werror --disable-shared \
62 --prefix=${TOOLCHAIN_INSTALL} --with-sysroot --target=${TARGET} \
63 --enable-languages=c --disable-libssp --disable-libsanitizer \
64 --disable-libatomic --disable-libgomp --disable-libquadmath
65 make -j${J} all-gcc
66 make install-gcc
67 cd ..
70 # Build musl.
71 # We won't go through the extra step of building shared libraries
72 # because we don't actually use them in QEMU docker testing.
75 cd bld-musl
76 ../src-musl/configure --prefix=/usr --host=${TARGET} --disable-shared
77 make -j${j}
78 make install DESTDIR=${CROSS_SYSROOT}
79 cd ..
82 # Go back and build the compiler runtime
85 cd bld-gcc
86 make -j${j}
87 make install
88 cd ..