-
Notifications
You must be signed in to change notification settings - Fork 12
/
build-gcc.sh
executable file
·95 lines (76 loc) · 3.72 KB
/
build-gcc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
###################################################################
#Script Name : build-gcc
#Description : build gcc for the Motorola 68000 toolchain
#Date : samedi, 4 avril 2020
#Args : Welcome to the next level!
#Author : Jacques Belosoukinski (kentosama)
#Email : [email protected]
##################################################################
VERSION="6.3.0"
ARCHIVE="gcc-${VERSION}.tar.bz2"
URL="https://gcc.gnu.org/pub/gcc/releases/gcc-${VERSION}/${ARCHIVE}"
SHA512SUM="234dd9b1bdc9a9c6e352216a7ef4ccadc6c07f156006a59759c5e0e6a69f0abcdc14630eff11e3826dd6ba5933a8faa43043f3d1d62df6bd5ab1e82862f9bf78"
DIR="gcc-${VERSION}"
# Check if user is root
if [ ${EUID} == 0 ]; then
echo "Please don't run this script as root"
exit
fi
# Create build folder
mkdir -p ${BUILD_DIR}/${DIR}
cd ${DOWNLOAD_DIR}
# Download gcc if is needed
if ! [ -f "${ARCHIVE}" ]; then
wget ${URL}
fi
# Extract gcc archive if is needed
if ! [ -d "${SRC_DIR}/${DIR}" ]; then
if [ $(sha512sum ${ARCHIVE} | awk '{print $1}') != ${SHA512SUM} ]; then
echo "SHA512SUM verification of ${ARCHIVE} failed!"
exit
else
tar jxvf ${ARCHIVE} -C ${SRC_DIR}
# Apply patch for ubsan.c at 1474:
# || xloc.file == '\0' || xloc.file[0] == '\xff' to
# || xloc.file[0] == '\0' || xloc.file[0] == '\xff'
patch -t ${SRC_DIR}/${DIR}/gcc/ubsan.c < ${ROOT_DIR}/patch/ubsan-fix-check-empty-string.patch
fi
fi
cd ${SRC_DIR}/${DIR}
echo ${PWD}
# Download prerequisites
./contrib/download_prerequisites
cd ${BUILD_DIR}/${DIR}
# Configure before build
../../source/${DIR}/configure --prefix=${INSTALL_DIR} \
--build=${BUILD_MACH} \
--host=${HOST_MACH} \
--target=${TARGET} \
--program-prefix=${PROGRAM_PREFIX} \
--enable-languages=c \
--enable-obsolete \
--enable-lto \
--disable-threads \
--disable-libmudflap \
--disable-libgomp \
--disable-nls \
--disable-werror \
--disable-libssp \
--disable-shared \
--disable-multilib \
--disable-libgcj \
--disable-libstdcxx \
--disable-gcov \
--without-headers \
--without-included-gettext \
--with-cpu=${WITH_CPU} \
${WITH_NEWLIB}
# build and install gcc
make -j${NUM_PROC} 2<&1 | tee build.log
# Install
if [ $? -eq 0 ]; then
make install
make -j${NUM_PROC} all-target-libgcc
make install-target-libgcc
fi