]>
Commit | Line | Data |
---|---|---|
abe05a73 | 1 | #!/usr/bin/env bash |
abe05a73 XL |
2 | |
3 | set -ex | |
4 | ||
5 | ARCH=x86_64 | |
6 | PATCH_TOOLCHAIN=$1 | |
7 | BINUTILS=2.25.1 | |
8 | GCC=6.4.0 | |
9 | ||
10 | hide_output() { | |
11 | set +x | |
12 | on_err=" | |
13 | echo ERROR: An error was encountered with the build. | |
14 | cat /tmp/build.log | |
15 | exit 1 | |
16 | " | |
17 | trap "$on_err" ERR | |
18 | bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & | |
19 | PING_LOOP_PID=$! | |
20 | $@ &> /tmp/build.log | |
21 | trap - ERR | |
22 | kill $PING_LOOP_PID | |
23 | set -x | |
24 | } | |
25 | ||
26 | mkdir binutils | |
27 | cd binutils | |
28 | ||
29 | # First up, build binutils | |
30 | curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 | tar xjf - | |
31 | mkdir binutils-build | |
32 | cd binutils-build | |
33 | hide_output ../binutils-$BINUTILS/configure \ | |
34 | --target=$ARCH-unknown-dragonfly | |
35 | hide_output make -j10 | |
36 | hide_output make install | |
37 | cd ../.. | |
38 | rm -rf binutils | |
39 | ||
40 | # Next, download the DragonFly libc and relevant header files | |
41 | ||
42 | URL=http://mirror-master.dragonflybsd.org/iso-images/dfly-x86_64-5.0.0_REL.iso.bz2 | |
43 | mkdir dragonfly | |
44 | curl $URL | bzcat | bsdtar xf - -C dragonfly ./usr/include ./usr/lib ./lib | |
45 | ||
46 | dst=/usr/local/$ARCH-unknown-dragonfly | |
47 | ||
48 | mkdir -p $dst/lib | |
49 | cp -r dragonfly/usr/include $dst/ | |
50 | cp dragonfly/usr/lib/crt1.o $dst/lib | |
51 | cp dragonfly/usr/lib/Scrt1.o $dst/lib | |
52 | cp dragonfly/usr/lib/crti.o $dst/lib | |
53 | cp dragonfly/usr/lib/crtn.o $dst/lib | |
54 | cp dragonfly/usr/lib/libc.a $dst/lib | |
55 | cp dragonfly/usr/lib/libutil.a $dst/lib | |
56 | cp dragonfly/usr/lib/libm.a $dst/lib | |
57 | cp dragonfly/usr/lib/librt.so.0 $dst/lib | |
58 | cp dragonfly/usr/lib/libexecinfo.so.1 $dst/lib | |
59 | cp dragonfly/lib/libc.so.8 $dst/lib | |
60 | cp dragonfly/lib/libm.so.4 $dst/lib | |
61 | cp dragonfly/lib/libutil.so.4 $dst/lib | |
62 | cp dragonfly/usr/lib/libpthread.so $dst/lib/libpthread.so | |
63 | cp dragonfly/usr/lib/thread/libthread_xu.so.2 $dst/lib/libpthread.so.0 | |
64 | ||
65 | ln -s libc.so.8 $dst/lib/libc.so | |
66 | ln -s libm.so.4 $dst/lib/libm.so | |
67 | ln -s librt.so.0 $dst/lib/librt.so | |
68 | ln -s libutil.so.4 $dst/lib/libutil.so | |
69 | ln -s libexecinfo.so.1 $dst/lib/libexecinfo.so | |
70 | rm -rf dragonfly | |
71 | ||
72 | # Finally, download and build gcc to target DragonFly | |
73 | mkdir gcc | |
74 | cd gcc | |
75 | curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.gz | tar xzf - | |
76 | cd gcc-$GCC | |
77 | ||
78 | # The following three patches are taken from DragonFly's dports collection: | |
79 | # https://github.com/DragonFlyBSD/DPorts/tree/master/lang/gcc5 | |
80 | # The dports specification for gcc5 contains a few more patches, but they are | |
81 | # not relevant in this situation, as they are for a language we don't need | |
82 | # (e.g. java), or a platform which is not supported by DragonFly (e.g. i386, | |
83 | # powerpc64, ia64, arm). | |
84 | # | |
85 | # These patches probably only need to be updated in case the gcc version is | |
86 | # updated. | |
87 | ||
88 | patch -p0 < $PATCH_TOOLCHAIN | |
89 | ||
90 | ./contrib/download_prerequisites | |
91 | ||
92 | mkdir ../gcc-build | |
93 | cd ../gcc-build | |
94 | hide_output ../gcc-$GCC/configure \ | |
95 | --enable-languages=c,c++ \ | |
96 | --target=$ARCH-unknown-dragonfly \ | |
97 | --disable-multilib \ | |
98 | --disable-nls \ | |
99 | --disable-libgomp \ | |
100 | --disable-libquadmath \ | |
101 | --disable-libssp \ | |
102 | --disable-libvtv \ | |
103 | --disable-libcilkrts \ | |
104 | --disable-libada \ | |
105 | --disable-libsanitizer \ | |
106 | --disable-libquadmath-support \ | |
107 | --disable-lto | |
108 | hide_output make -j10 | |
109 | hide_output make install | |
110 | cd ../.. | |
111 | rm -rf gcc |