]> git.proxmox.com Git - mirror_qemu.git/blob - tests/docker/dockerfiles/debian-nios2-cross.d/build-toolchain.sh
tests/docker: Add debian-nios2-cross image
[mirror_qemu.git] / tests / docker / dockerfiles / debian-nios2-cross.d / build-toolchain.sh
1 #!/bin/bash
2
3 set -e
4
5 TARGET=nios2-linux-gnu
6 LINUX_ARCH=nios2
7
8 J=$(expr $(nproc) / 2)
9 TOOLCHAIN_INSTALL=/usr/local
10 TOOLCHAIN_BIN=${TOOLCHAIN_INSTALL}/bin
11 CROSS_SYSROOT=${TOOLCHAIN_INSTALL}/$TARGET/sys-root
12
13 export PATH=${TOOLCHAIN_BIN}:$PATH
14
15 #
16 # Grab all of the source for the toolchain bootstrap.
17 #
18
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://ftp.gnu.org/gnu/glibc/glibc-2.34.tar.xz
22 wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.70.tar.xz
23
24 tar axf binutils-2.37.tar.xz
25 tar axf gcc-11.2.0.tar.xz
26 tar axf glibc-2.34.tar.xz
27 tar axf linux-5.10.70.tar.xz
28
29 mv binutils-2.37 src-binu
30 mv gcc-11.2.0 src-gcc
31 mv glibc-2.34 src-glibc
32 mv linux-5.10.70 src-linux
33
34 mkdir -p bld-hdr bld-binu bld-gcc bld-glibc
35 mkdir -p ${CROSS_SYSROOT}/usr/include
36
37 #
38 # Install kernel and glibc headers
39 #
40
41 cd src-linux
42 make headers_install ARCH=${LINUX_ARCH} INSTALL_HDR_PATH=${CROSS_SYSROOT}/usr
43 cd ..
44
45 cd bld-hdr
46 ../src-glibc/configure --prefix=/usr --host=${TARGET}
47 make install-headers DESTDIR=${CROSS_SYSROOT}
48 touch ${CROSS_SYSROOT}/usr/include/gnu/stubs.h
49 cd ..
50
51 #
52 # Build binutils
53 #
54
55 cd bld-binu
56 ../src-binu/configure --disable-werror \
57 --prefix=${TOOLCHAIN_INSTALL} --with-sysroot --target=${TARGET}
58 make -j${J}
59 make install
60 cd ..
61
62 #
63 # Build gcc, without shared libraries, because we do not yet
64 # have a shared libc against which to link.
65 #
66
67 cd bld-gcc
68 ../src-gcc/configure --disable-werror --disable-shared \
69 --prefix=${TOOLCHAIN_INSTALL} --with-sysroot --target=${TARGET} \
70 --enable-languages=c --disable-libssp --disable-libsanitizer \
71 --disable-libatomic --disable-libgomp --disable-libquadmath
72 make -j${J}
73 make install
74 cd ..
75
76 #
77 # Build glibc
78 # There are a few random things that use c++ but we didn't build that
79 # cross-compiler. We can get away without them. Disable CXX so that
80 # glibc doesn't try to use the host c++ compiler.
81 #
82
83 cd bld-glibc
84 CXX=false ../src-glibc/configure --prefix=/usr --host=${TARGET}
85 make -j${j}
86 make install DESTDIR=${CROSS_SYSROOT}
87 cd ..