This repository was archived by the owner on Nov 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Add DragonFly toolchain #105
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
ARCH=x86_64 | ||
BINUTILS=2.25.1 | ||
GCC=5.3.0 | ||
URL_DFLY_ISO=http://mirror-master.dragonflybsd.org/iso-images/dfly-x86_64-4.4.3_REL.iso.bz2 | ||
|
||
mkdir binutils | ||
cd binutils | ||
|
||
# First up, build binutils | ||
curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 | tar xjf - | ||
mkdir binutils-build | ||
cd binutils-build | ||
../binutils-$BINUTILS/configure \ | ||
--target=$ARCH-unknown-dragonfly | ||
make -j10 | ||
make install | ||
cd ../.. | ||
rm -rf binutils | ||
|
||
# Next, download the DragonFly libc and relevant header files | ||
mkdir dragonfly | ||
curl $URL_DFLY_ISO | bzcat | bsdtar xf - -C dragonfly ./usr/include ./usr/lib ./lib | ||
|
||
dst=/usr/local/$ARCH-unknown-dragonfly | ||
|
||
cp -r dragonfly/usr/include $dst/ | ||
cp dragonfly/usr/lib/crt1.o $dst/lib | ||
cp dragonfly/usr/lib/Scrt1.o $dst/lib | ||
cp dragonfly/usr/lib/crti.o $dst/lib | ||
cp dragonfly/usr/lib/crtn.o $dst/lib | ||
cp dragonfly/usr/lib/libc.a $dst/lib | ||
cp dragonfly/usr/lib/libutil.a $dst/lib | ||
#cp dragonfly/usr/lib/libutil_p.a $dst/lib | ||
cp dragonfly/usr/lib/libm.a $dst/lib | ||
cp dragonfly/usr/lib/librt.so.0 $dst/lib | ||
cp dragonfly/usr/lib/libexecinfo.so.1 $dst/lib | ||
cp dragonfly/lib/libc.so.8 $dst/lib | ||
cp dragonfly/lib/libm.so.4 $dst/lib | ||
cp dragonfly/lib/libutil.so.4 $dst/lib | ||
#cp dragonfly/lib/libthr.so.3 $dst/lib/libpthread.so | ||
cp dragonfly/usr/lib/libpthread.so $dst/lib/libpthread.so | ||
cp dragonfly/usr/lib/thread/libthread_xu.so.2 $dst/lib/libpthread.so.0 | ||
|
||
ln -s libc.so.8 $dst/lib/libc.so | ||
ln -s libm.so.4 $dst/lib/libm.so | ||
ln -s librt.so.0 $dst/lib/librt.so | ||
ln -s libutil.so.4 $dst/lib/libutil.so | ||
ln -s libexecinfo.so.1 $dst/lib/libexecinfo.so | ||
rm -rf dragonfly | ||
|
||
# Finally, download and build gcc to target FreeBSD | ||
mkdir gcc | ||
cd gcc | ||
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.bz2 | tar xjf - | ||
cd gcc-$GCC | ||
|
||
# The following three patches are taken from DragonFly's dports collection: | ||
# https://github.com/DragonFlyBSD/DPorts/tree/master/lang/gcc5 | ||
# The dports specification for gcc5 contains a few more patches, but they are | ||
# not relevant in this situation, as they are for a language we don't need | ||
# (e.g. java), or a platform which is not supported by DragonFly (e.g. i386, | ||
# powerpc64, ia64, arm). | ||
# | ||
# These patches probably only need to be updated in case the gcc version is | ||
# updated. | ||
|
||
patch -p0 <<'EOF' | ||
--- libatomic/configure.tgt.orig 2015-07-09 16:08:55 UTC | ||
+++ libatomic/configure.tgt | ||
@@ -110,7 +110,7 @@ case "${target}" in | ||
;; | ||
|
||
*-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \ | ||
- | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* \ | ||
+ | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \ | ||
| *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \ | ||
| *-*-darwin* | *-*-aix* | *-*-cygwin*) | ||
# POSIX system. The OS is supported. | ||
EOF | ||
|
||
patch -p0 <<'EOF' | ||
--- libstdc++-v3/config/os/bsd/dragonfly/os_defines.h.orig 2015-07-09 16:08:54 UTC | ||
+++ libstdc++-v3/config/os/bsd/dragonfly/os_defines.h | ||
@@ -29,4 +29,9 @@ | ||
// System-specific #define, typedefs, corrections, etc, go here. This | ||
// file will come before all others. | ||
|
||
+#define _GLIBCXX_USE_C99_CHECK 1 | ||
+#define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999)) | ||
+#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1 | ||
+#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED) | ||
+ | ||
#endif | ||
EOF | ||
|
||
patch -p0 <<'EOF' | ||
--- libstdc++-v3/configure.orig 2016-05-26 18:34:47.163132921 +0200 | ||
+++ libstdc++-v3/configure 2016-05-26 18:35:29.594590648 +0200 | ||
@@ -52013,7 +52013,7 @@ | ||
|
||
;; | ||
|
||
- *-freebsd*) | ||
+ *-freebsd* | *-dragonfly*) | ||
SECTION_FLAGS='-ffunction-sections -fdata-sections' | ||
|
||
|
||
EOF | ||
|
||
./contrib/download_prerequisites | ||
|
||
mkdir ../gcc-build | ||
cd ../gcc-build | ||
../gcc-$GCC/configure \ | ||
--enable-languages=c,c++ \ | ||
--target=$ARCH-unknown-dragonfly \ | ||
--disable-multilib \ | ||
--disable-nls \ | ||
--disable-libgomp \ | ||
--disable-libquadmath \ | ||
--disable-libssp \ | ||
--disable-libvtv \ | ||
--disable-libcilkrts \ | ||
--disable-libada \ | ||
--disable-libsanitizer \ | ||
--disable-libquadmath-support \ | ||
--disable-lto | ||
make -j10 | ||
make install | ||
cd ../.. | ||
rm -rf gcc |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have links for where these patches come from? Just so if we need to update this we know where to look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are from DragonFly's dports collection (dports =~ FreeBSD ports): https://github.com/DragonFlyBSD/DeltaPorts/tree/master/ports/lang/gcc5/dragonfly or https://github.com/DragonFlyBSD/DPorts/tree/master/lang/gcc5. DeltaPorts is our layer above FreeBSD's ports collection. DPorts is then created by applying the patches from DeltaPorts against FreeBSD's ports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you only need to update the patches in case you change the gcc version. Newer versions of gcc might already ship with those patches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info! Could you add that as a comment here? We may need to update gcc one day and it'd just be good to know where the patches came from so we could perhaps pick up others if they're necessary.