Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Commit 25e1ae0

Browse files
authored
Merge pull request #105 from mneumann/dragonfly
Add DragonFly toolchain
2 parents ac6560d + 98cd61e commit 25e1ae0

File tree

2 files changed

+142
-1
lines changed

2 files changed

+142
-1
lines changed

slaves/linux-cross/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get install -y --force-yes --no-install-recommends \
99
g++-4.8-powerpc-linux-gnu libc6-dev-powerpc-cross \
1010
g++-4.8-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \
1111
lib64gcc-4.8-dev-powerpc-cross libc6-dev-ppc64-powerpc-cross \
12-
software-properties-common
12+
software-properties-common bsdtar
1313
RUN add-apt-repository ppa:angelsl/mips-cross && apt-get update
1414
RUN apt-get install -y --force-yes --no-install-recommends \
1515
g++-5-mips-linux-gnu libc6-dev-mips-cross \
@@ -121,6 +121,9 @@ RUN bash /tmp/build_freebsd_toolchain.sh i686
121121
RUN bash /tmp/build_freebsd_toolchain.sh x86_64
122122
COPY linux-cross/build_netbsd_toolchain.sh /tmp/
123123
RUN bash /tmp/build_netbsd_toolchain.sh
124+
COPY linux-cross/build_dragonfly_toolchain.sh /tmp/
125+
RUN bash /tmp/build_dragonfly_toolchain.sh
126+
124127

125128
# Instruct rustbuild to use the armv7-linux-gnueabihf toolchain instead of the
126129
# default arm-linux-gnueabihf one
@@ -136,6 +139,9 @@ ENV AR_armv7_unknown_linux_gnueabihf=armv7-linux-gnueabihf-ar \
136139
AR_x86_64_unknown_netbsd=x86_64-unknown-netbsd-ar \
137140
CC_x86_64_unknown_netbsd=x86_64-unknown-netbsd-gcc \
138141
CXX_x86_64_unknown_netbsd=x86_64-unknown-netbsd-g++ \
142+
AR_x86_64_unknown_dragonfly=x86_64-unknown-dragonfly-ar \
143+
CC_x86_64_unknown_dragonfly=x86_64-unknown-dragonfly-gcc \
144+
CXX_x86_64_unknown_dragonfly=x86_64-unknown-dragonfly-g++ \
139145
AR_mips_unknown_linux_musl=mips-linux-musl-ar \
140146
CC_mips_unknown_linux_musl=mips-linux-musl-gcc \
141147
CXX_mips_unknown_linux_musl=mips-linux-musl-g++ \
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
ARCH=x86_64
6+
BINUTILS=2.25.1
7+
GCC=5.3.0
8+
URL_DFLY_ISO=http://mirror-master.dragonflybsd.org/iso-images/dfly-x86_64-4.4.3_REL.iso.bz2
9+
10+
mkdir binutils
11+
cd binutils
12+
13+
# First up, build binutils
14+
curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 | tar xjf -
15+
mkdir binutils-build
16+
cd binutils-build
17+
../binutils-$BINUTILS/configure \
18+
--target=$ARCH-unknown-dragonfly
19+
make -j10
20+
make install
21+
cd ../..
22+
rm -rf binutils
23+
24+
# Next, download the DragonFly libc and relevant header files
25+
mkdir dragonfly
26+
curl $URL_DFLY_ISO | bzcat | bsdtar xf - -C dragonfly ./usr/include ./usr/lib ./lib
27+
28+
dst=/usr/local/$ARCH-unknown-dragonfly
29+
30+
cp -r dragonfly/usr/include $dst/
31+
cp dragonfly/usr/lib/crt1.o $dst/lib
32+
cp dragonfly/usr/lib/Scrt1.o $dst/lib
33+
cp dragonfly/usr/lib/crti.o $dst/lib
34+
cp dragonfly/usr/lib/crtn.o $dst/lib
35+
cp dragonfly/usr/lib/libc.a $dst/lib
36+
cp dragonfly/usr/lib/libutil.a $dst/lib
37+
#cp dragonfly/usr/lib/libutil_p.a $dst/lib
38+
cp dragonfly/usr/lib/libm.a $dst/lib
39+
cp dragonfly/usr/lib/librt.so.0 $dst/lib
40+
cp dragonfly/usr/lib/libexecinfo.so.1 $dst/lib
41+
cp dragonfly/lib/libc.so.8 $dst/lib
42+
cp dragonfly/lib/libm.so.4 $dst/lib
43+
cp dragonfly/lib/libutil.so.4 $dst/lib
44+
#cp dragonfly/lib/libthr.so.3 $dst/lib/libpthread.so
45+
cp dragonfly/usr/lib/libpthread.so $dst/lib/libpthread.so
46+
cp dragonfly/usr/lib/thread/libthread_xu.so.2 $dst/lib/libpthread.so.0
47+
48+
ln -s libc.so.8 $dst/lib/libc.so
49+
ln -s libm.so.4 $dst/lib/libm.so
50+
ln -s librt.so.0 $dst/lib/librt.so
51+
ln -s libutil.so.4 $dst/lib/libutil.so
52+
ln -s libexecinfo.so.1 $dst/lib/libexecinfo.so
53+
rm -rf dragonfly
54+
55+
# Finally, download and build gcc to target FreeBSD
56+
mkdir gcc
57+
cd gcc
58+
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.bz2 | tar xjf -
59+
cd gcc-$GCC
60+
61+
# The following three patches are taken from DragonFly's dports collection:
62+
# https://github.com/DragonFlyBSD/DPorts/tree/master/lang/gcc5
63+
# The dports specification for gcc5 contains a few more patches, but they are
64+
# not relevant in this situation, as they are for a language we don't need
65+
# (e.g. java), or a platform which is not supported by DragonFly (e.g. i386,
66+
# powerpc64, ia64, arm).
67+
#
68+
# These patches probably only need to be updated in case the gcc version is
69+
# updated.
70+
71+
patch -p0 <<'EOF'
72+
--- libatomic/configure.tgt.orig 2015-07-09 16:08:55 UTC
73+
+++ libatomic/configure.tgt
74+
@@ -110,7 +110,7 @@ case "${target}" in
75+
;;
76+
77+
*-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
78+
- | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* \
79+
+ | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \
80+
| *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
81+
| *-*-darwin* | *-*-aix* | *-*-cygwin*)
82+
# POSIX system. The OS is supported.
83+
EOF
84+
85+
patch -p0 <<'EOF'
86+
--- libstdc++-v3/config/os/bsd/dragonfly/os_defines.h.orig 2015-07-09 16:08:54 UTC
87+
+++ libstdc++-v3/config/os/bsd/dragonfly/os_defines.h
88+
@@ -29,4 +29,9 @@
89+
// System-specific #define, typedefs, corrections, etc, go here. This
90+
// file will come before all others.
91+
92+
+#define _GLIBCXX_USE_C99_CHECK 1
93+
+#define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
94+
+#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1
95+
+#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED)
96+
+
97+
#endif
98+
EOF
99+
100+
patch -p0 <<'EOF'
101+
--- libstdc++-v3/configure.orig 2016-05-26 18:34:47.163132921 +0200
102+
+++ libstdc++-v3/configure 2016-05-26 18:35:29.594590648 +0200
103+
@@ -52013,7 +52013,7 @@
104+
105+
;;
106+
107+
- *-freebsd*)
108+
+ *-freebsd* | *-dragonfly*)
109+
SECTION_FLAGS='-ffunction-sections -fdata-sections'
110+
111+
112+
EOF
113+
114+
./contrib/download_prerequisites
115+
116+
mkdir ../gcc-build
117+
cd ../gcc-build
118+
../gcc-$GCC/configure \
119+
--enable-languages=c,c++ \
120+
--target=$ARCH-unknown-dragonfly \
121+
--disable-multilib \
122+
--disable-nls \
123+
--disable-libgomp \
124+
--disable-libquadmath \
125+
--disable-libssp \
126+
--disable-libvtv \
127+
--disable-libcilkrts \
128+
--disable-libada \
129+
--disable-libsanitizer \
130+
--disable-libquadmath-support \
131+
--disable-lto
132+
make -j10
133+
make install
134+
cd ../..
135+
rm -rf gcc

0 commit comments

Comments
 (0)