master
sh 96 lines 2.1 KB
Raw
1 #!/bin/bash
2
3 set -e
4
5 TARGET=microblaze-linux-musl
6 LINUX_ARCH=microblaze
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 GCC_PATCH0_URL=https://raw.githubusercontent.com/Xilinx/meta-xilinx/refs/tags/xlnx-rel-v2024.1/meta-microblaze/recipes-devtools/gcc/gcc-12/0009-Patch-microblaze-Fix-atomic-boolean-return-value.patch
14
15 export PATH=${TOOLCHAIN_BIN}:$PATH
16
17 #
18 # Grab all of the source for the toolchain bootstrap.
19 #
20
21 wget https://ftp.gnu.org/gnu/binutils/binutils-2.37.tar.xz
22 wget https://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz
23 wget https://www.musl-libc.org/releases/musl-1.2.2.tar.gz
24 wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.70.tar.xz
25
26 tar axf binutils-2.37.tar.xz
27 tar axf gcc-11.2.0.tar.xz
28 tar axf musl-1.2.2.tar.gz
29 tar axf linux-5.10.70.tar.xz
30
31 mv binutils-2.37 src-binu
32 mv gcc-11.2.0 src-gcc
33 mv musl-1.2.2 src-musl
34 mv linux-5.10.70 src-linux
35
36 #
37 # Patch gcc
38 #
39
40 wget -O - ${GCC_PATCH0_URL} | patch -d src-gcc -p1
41
42 mkdir -p bld-hdr bld-binu bld-gcc bld-musl
43 mkdir -p ${CROSS_SYSROOT}/usr/include
44
45 #
46 # Install kernel headers
47 #
48
49 cd src-linux
50 make headers_install ARCH=${LINUX_ARCH} INSTALL_HDR_PATH=${CROSS_SYSROOT}/usr
51 cd ..
52
53 #
54 # Build binutils
55 #
56
57 cd bld-binu
58 ../src-binu/configure --disable-werror \
59 --prefix=${TOOLCHAIN_INSTALL} --with-sysroot --target=${TARGET}
60 make -j${J}
61 make install
62 cd ..
63
64 #
65 # Build gcc, just the compiler so far.
66 #
67
68 cd bld-gcc
69 ../src-gcc/configure --disable-werror --disable-shared \
70 --prefix=${TOOLCHAIN_INSTALL} --with-sysroot --target=${TARGET} \
71 --enable-languages=c --disable-libssp --disable-libsanitizer \
72 --disable-libatomic --disable-libgomp --disable-libquadmath
73 make -j${J} all-gcc
74 make install-gcc
75 cd ..
76
77 #
78 # Build musl.
79 # We won't go through the extra step of building shared libraries
80 # because we don't actually use them in QEMU docker testing.
81 #
82
83 cd bld-musl
84 ../src-musl/configure --prefix=/usr --host=${TARGET} --disable-shared
85 make -j${j}
86 make install DESTDIR=${CROSS_SYSROOT}
87 cd ..
88
89 #
90 # Go back and build the compiler runtime
91 #
92
93 cd bld-gcc
94 make -j${j}
95 make install
96 cd ..