Commit | Line | Data |
---|---|---|
e261a28e KS |
1 | #!/bin/bash -x |
2 | ||
3 | SRC_DIR="${SRC_DIR:-/src/gcc-releases-gcc-4.8.5}" | |
4 | PATCH_DIR="${PATCH_DIR:-/src/patches}" | |
5 | TARGET="${TARGET:-aarch64-linux-gnu}" | |
6 | HOST="${HOST:-x86_64-linux-gnu}" | |
2a8d15d6 KS |
7 | CONFIGURE_ARGS=(${CONFIGURE_ARGS:-}) |
8 | MAKE_ARGS=(${MAKE_ARGS:-}) | |
9 | MAKE_INSTALL_ARGS=(${MAKE_INSTALL_ARGS:-}) | |
10 | DEBUG="${DEBUG:-}" | |
e261a28e KS |
11 | |
12 | OWD="$(pwd)" | |
13 | cd "${SRC_DIR}" || exit 1 | |
14 | while read -r line ; do | |
15 | EXT=$(echo "$line" | rev | cut -d. -f1 | rev) | |
16 | PATCH_LEVEL=1 | |
17 | if [[ "${EXT}" =~ [0-9]+ ]] ; then | |
18 | PATCH_LEVEL="${EXT}" | |
19 | fi | |
20 | patch -p"${PATCH_LEVEL}" < "${line}" | |
21 | done < <(find "${PATCH_DIR}" -type f) | |
2a8d15d6 | 22 | cd "${OWD}" || exit 1 |
e261a28e KS |
23 | |
24 | TARGET_ARGS=() | |
2a8d15d6 KS |
25 | CFLAGS=(-std=gnu99) |
26 | CXXFLAGS=(-std=gnu++98) | |
27 | # apt-get install -y gcc-"${TARGET}" | |
e261a28e KS |
28 | case "${TARGET}" in |
29 | aarch64-linux-gnu) | |
30 | TARGET_ARGS+=( | |
31 | --enable-fix-cortex-a64-84319 | |
32 | ) | |
33 | ;; | |
34 | arm-linux-gnueabihf) | |
35 | TARGET_ARGS+=( | |
36 | --with-arch=armv7-a | |
37 | --with-float=hard | |
38 | --with-fpu=vfpv3-d16 | |
39 | --with-mode=thumb | |
40 | ) | |
41 | ;; | |
42 | i686-linux-gnu) | |
43 | TARGET_ARGS+=( | |
44 | --with-arch-i686 | |
45 | --with-tune=generic | |
46 | ) | |
47 | ;; | |
48 | powerpc64le-linux-gnu) | |
2a8d15d6 KS |
49 | # Disable multilib so that ppc64el kernel can be built, since |
50 | # legacy Makefiles compile vdso in 32bits unconditionally. | |
51 | # @see https://bugzilla.redhat.com/show_bug.cgi?id=1237363 | |
52 | # @see https://bugzilla.redhat.com/show_bug.cgi?id=1205236 | |
53 | # @see https://bugs.launchpad.net/ubuntu/trusty/+source/linux/+bug/1433809/ | |
e261a28e | 54 | TARGET_ARGS+=( |
2a8d15d6 | 55 | --disable-multilib |
e261a28e KS |
56 | --enable-targets=powerpcle-linux |
57 | --with-cpu=power8 | |
58 | --with-long-double-128 | |
59 | ) | |
60 | ;; | |
61 | powerpc-linux-gnu) | |
62 | TARGET_ARGS+=( | |
63 | --disable-softfloat | |
64 | --enable-secureplt | |
65 | --enable-targets=powerpc-linux,powerpc64-linux | |
66 | --with-cpu=default32 | |
67 | --with-long-double-128 | |
68 | ) | |
69 | ;; | |
70 | riscv64-linux-gnu) | |
71 | echo "Not supported in gcc-4.8" | |
72 | exit 0 | |
73 | ;; | |
74 | s390x-linux-gnu) | |
75 | TARGET_ARGS+=( | |
76 | --with-arch=zEC12 | |
77 | --with-long-double-128 | |
78 | ) | |
79 | ;; | |
80 | *) | |
81 | echo "Unrecognized target: ${TARGET}" | |
82 | exit 0 | |
83 | ;; | |
84 | esac | |
85 | ||
2a8d15d6 | 86 | START=$(date +%s) |
e261a28e KS |
87 | "${SRC_DIR}/configure" --build="${HOST}" --host="${HOST}" --enable-languages=c,c++ \ |
88 | --program-prefix="${TARGET}-" --target="${TARGET}" --program-suffix=-4.8 \ | |
89 | --prefix=/usr/ --with-system-zlib \ | |
90 | --libexecdir=/usr/lib/ --libdir=/usr/lib/ \ | |
91 | --disable-nls --disable-shared --enable-host-shared \ | |
92 | --disable-bootstrap --enable-threads=posix --enable-default-pie \ | |
93 | --with-sysroot=/ --includedir=/usr/"${TARGET}"/include \ | |
2a8d15d6 KS |
94 | --without-target-system-zlib --enable-multiarch \ |
95 | "${TARGET_ARGS[@]}" "${CONFIGURE_ARGS[@]}" \ | |
96 | CFLAGS="${CFLAGS[*]}" CXXFLAGS="${CXXFLAGS[*]}" | |
97 | ||
98 | NPROC="${NPROC:=$(nproc)}" | |
99 | make -j"${NPROC}" "${MAKE_ARGS[@]}" CFLAGS="${CFLAGS[*]}" CXXFLAGS="${CXXFLAGS[*]}" | |
100 | # Do not use -jN with make install, it often breaks. | |
101 | make install "${MAKE_INSTALL_ARGS[@]}" | |
102 | ||
103 | mkdir -p "/output/usr/lib/gcc-cross/${TARGET}" /output/usr/bin/ | |
e261a28e | 104 | |
2a8d15d6 KS |
105 | if [ -n "${DEBUG}" ] ; then |
106 | echo $(($(date +%s) - START)) > "/output/${TARGET}.time" | |
107 | fi | |
e261a28e | 108 | |
2a8d15d6 | 109 | cp -r /usr/lib/gcc-cross/"${TARGET}"/4* "/output/usr/lib/gcc-cross/${TARGET}/" |
e261a28e | 110 | cp /usr/bin/*-4.8 /output/usr/bin/ |