Mail archive
alpine-aports

[alpine-aports] [PATCH 1/3] testing/ghc-llvm35 new aport

From: Mitch Tishmack <mitch.tishmack_at_gmail.com>
Date: Tue, 1 Mar 2016 19:28:54 -0600

From: Mitch Tishmack <mitch.tishmack_at_gmail.com>

---
 testing/ghc-llvm35/APKBUILD                        | 175 +++++++++++++++++++++
 .../ghc-llvm35/llvm-0001-fix-shared-build.patch    |  48 ++++++
 testing/ghc-llvm35/llvm-0002-musl-triple.patch     |  74 +++++++++
 testing/ghc-llvm35/llvm-0003-musl-hacks.patch      |  82 ++++++++++
 4 files changed, 379 insertions(+)
 create mode 100755 testing/ghc-llvm35/APKBUILD
 create mode 100644 testing/ghc-llvm35/llvm-0001-fix-shared-build.patch
 create mode 100644 testing/ghc-llvm35/llvm-0002-musl-triple.patch
 create mode 100644 testing/ghc-llvm35/llvm-0003-musl-hacks.patch
diff --git a/testing/ghc-llvm35/APKBUILD b/testing/ghc-llvm35/APKBUILD
new file mode 100755
index 0000000..e85b324
--- /dev/null
+++ b/testing/ghc-llvm35/APKBUILD
_at_@ -0,0 +1,175 @@
+# Contributor: Mitch Tishmack <mitch.tishmack_at_gmail.com>
+# Maintainer: Mitch Tishmack <mitch.tishmack_at_gmail.com>
+#
+# Note, this ONLY compiles llvm for opt/llc and moves the
+# suffixed binaries to /usr/lib/ghc
+#
+# This allows the ghc/ghc-bootstrap portx to use the correct llvm.
+_pkgname=llvm
+llvm_major=3.5
+llvm_version=${llvm_major}.2
+suffix="-${llvm_major}"
+opt=opt${suffix}
+llc=llc${suffix}
+pkgname=ghc-${_pkgname}-${llvm_major}
+pkgver=$llvm_version
+pkgrel=0
+pkgdesc="ghc required llvm binaries"
+url="n/a"
+arch="x86_64 armhf"
+license="UIO-NCSA"
+depends=""
+install=""
+subpackages=""
+# llvm build dependencies
+makedepends="
+	$depends
+	$makedepends
+	perl
+	cmake
+	make
+	flex
+	bison
+	groff
+	musl-dev
+	binutils-dev
+	libffi-dev
+	zlib-dev
+	ncurses-dev
+	python
+	python-dev
+	gmp-dev
+	git
+	libtool
+	autoconf
+	automake
+"
+_builddir="$srcdir/$pkgname-$pkgver"
+
+# musl patches for 3.5.2
+source="
+	llvm-0001-fix-shared-build.patch
+	llvm-0002-musl-triple.patch
+	llvm-0003-musl-hacks.patch
+"
+
+# llvm/polly
+source="
+	$source
+	http://llvm.org/releases/$pkgver/llvm-$pkgver.src.tar.xz
+	http://llvm.org/releases/$pkgver/polly-$pkgver.src.tar.xz
+"
+_builddir="$srcdir"/build
+llvm_srcdir="$srcdir/llvm-$llvm_version.src"
+llvm_builddir="$srcdir/build"
+srcdir_polly="$srcdir"/polly-$llvm_version.src
+
+_cmake_flags="\
+	-DCMAKE_BUILD_TYPE=Release \
+	-DCMAKE_VERBOSE_MAKEFILE=NO \
+	-DLLVM_DEFAULT_TARGET_TRIPLE=$CBUILD \
+	-DLLVM_HOST_TRIPLE=$CHOST \
+	-DLLVM_BINUTILS_INCDIR=/usr/include \
+	-DLLVM_ENABLE_ASSERTIONS=NO \
+	-DLLVM_ENABLE_LIBCXX=NO \
+	-DLLVM_ENABLE_PIC=YES \
+	-DLLVM_ENABLE_ZLIB=YES \
+	-DLLVM_ENABLE_RTTI=YES \
+	-DLLVM_BUILD_EXAMPLES=NO \
+	-DLLVM_INCLUDE_EXAMPLES=NO \
+	-DLIBXML2_INCLUDE_DIR=/usr/include/libxml2 \
+	-DCMAKE_INSTALL_PREFIX=/usr \
+	-DLLVM_TARGETS_TO_BUILD='all' \
+	-DLLVM_BUILD_EXTERNAL_COMPILER_RT=NO \
+	-DBUILD_SHARED_LIBS=NO \
+	-DWITH_POLLY=YES \
+	-DLLVM_BUILD_DOCS=NO \
+	-DLLVM_BUILD_TESTS=NO \
+	-DLLVM_ENABLE_CXX1Y=NO \
+	-DLLVM_ENABLE_FFI=YES \
+	-DLLVM_ENABLE_SPHINX=NO \
+	-DLLVM_INCLUDE_EXAMPLES=NO \
+	-DLLVM_INCLUDE_TESTS=NO \
+	-DLLVM_ENABLE_CURSES=NO \
+	-DLLVM_ENABLE_TERMINFO=NO \
+"
+
+prepare() {
+	msg "Patching LLVM core..."
+	cd "$llvm_srcdir" || return 1
+	for i in $source; do
+		case $i in
+			llvm-*.patch)
+				msg "Applying $i..."
+				patch -s -p1 -N -i "$srcdir"/$i || return 1
+			;;
+		esac
+	done
+}
+
+build() {
+	msg "building isl"
+	# Note, isl is now too new for 3.5.2 in alpine linux.
+	# compile the right version into $srcdir so we can use polly
+	tmp="$srcdir/tmp"
+	install -d ${tmp} || return 1
+	isl_srcdir="$tmp/isl"
+	cloog_srcdir="$tmp/cloog"
+	cd "$srcdir_polly/utils"
+	./checkout_cloog.sh ${tmp} || return 1
+	cd "$isl_srcdir"
+	./configure --build=$CBUILD \
+		--host=$CHOST \
+		--prefix=$tmp || return 1
+	make || return 1
+	make -j1 INSTALL="install -D"		 install || return 1
+	mv "$srcdir"/polly-$llvm_version.src ""$llvm_srcdir"/tools/polly" || return 1
+	(
+		OCFLAGS="${CFLAGS}"
+		OCXXFLAGS="${CXXFLAGS}"
+		unset CFLAGS
+		unset CXXFLAGS
+
+		test -z "${OCFLAGS}" && OCFLAGS="-O3"
+		test -z "${OCXXFLAGS}" && OCXXFLAGS="-O3"
+
+		cflags="${OCFLAGS} -DNDEBUG -I$srcdir/tmp/include"
+		cxxflags="${OCXXFLAGS} -DNDEBUG -fno-devirtualize"
+
+		export CBUILD
+
+		ffi_include_dir="$(pkg-config --cflags-only-I libffi | sed 's|^-I||g')"
+
+		cflags="${OCFLAGS} -DNDEBUG"
+		cxxflags="${OCXXFLAGS} -DNDEBUG"
+		CC="gcc"
+		CXX="g++"
+
+		msg "Compiling llvm"
+		install -d "${llvm_builddir}"
+		cd "${llvm_builddir}"
+		cmake -G "Unix Makefiles" -Wno-dev ${_cmake_flags} \
+			-DCMAKE_C_COMPILER="${CC}" \
+			-DCMAKE_CXX_COMPILER="${CXX}" \
+			-DCMAKE_C_FLAGS_RELEASE="${cflags}" \
+			-DCMAKE_CXX_FLAGS_RELEASE="${cxxflags}" \
+			-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS} -L$srcdir/tmp/lib -static" \
+			-DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
+			-DFFI_INCLUDE_DIR="$ffi_include_dir" \
+			-DCMAKE_PREFIX_PATH="$srcdir/tmp" \
+			"${llvm_srcdir}" || return 1
+
+		(
+			export LD_LIBRARY_PATH="$srcdir/tmp/lib:$LD_LIBRARY_PATH"
+			make llvm-tblgen opt llc || return 1
+		) || return 1
+	) || return 1
+}
+
+package() {
+	cd "$_builddir"
+	install -d "$pkgdir/usr/lib/ghc"
+	for x in opt llc; do
+		install -Dm755 "$srcdir/build/bin/${x}" "$pkgdir/usr/lib/ghc/${x}${suffix}" || return 1
+	done
+}
diff --git a/testing/ghc-llvm35/llvm-0001-fix-shared-build.patch b/testing/ghc-llvm35/llvm-0001-fix-shared-build.patch
new file mode 100644
index 0000000..492c439
--- /dev/null
+++ b/testing/ghc-llvm35/llvm-0001-fix-shared-build.patch
_at_@ -0,0 +1,48 @@
+From 0d03d2ea17b66d8cb0f6ca5f2181237228535845 Mon Sep 17 00:00:00 2001
+From: Sanjoy Das <sanjoy at azulsystems.com>
+Date:   Thu Jun 19 15:38:02 2014 -0700
+Subject: Fix the --enable-shared build.
+
+Currently a build configured with ./configure --enable-shared breaks
+with an undefined "llvm::cl::parser<llvm::PassInfo
+const*>::getOption(unsigned int) const" symbol when linking opt.  This
+body for this symbol gets emitted into Pass.o (along with the destructor
+for PassNameParser), but gets linked into libLLVM-3.5svn.so with local
+visibility, causing the link error.
+
+This fix uses the existing EXTERN_TEMPLATE machinery to force a globally
+visible definition for the functions in parser<const PassInfo *> into
+Pass.o.
+---
+ include/llvm/IR/LegacyPassNameParser.h | 2 ++
+ lib/IR/Pass.cpp                        | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/include/llvm/IR/LegacyPassNameParser.h b/include/llvm/IR/LegacyPassNameParser.h
+index e2e4912..a07e3fd 100644
+--- a/include/llvm/IR/LegacyPassNameParser.h
++++ b/include/llvm/IR/LegacyPassNameParser.h
+_at_@ -95,6 +95,8 @@ private:
+   }
+ };
+
++EXTERN_TEMPLATE_INSTANTIATION(class cl::parser<const PassInfo *>);
++
+ ///===----------------------------------------------------------------------===//
+ /// FilteredPassNameParser class - Make use of the pass registration
+ /// mechanism to automatically add a command line argument to opt for
+diff --git a/lib/IR/Pass.cpp b/lib/IR/Pass.cpp
+index 91d86ae..00ce223 100644
+--- a/lib/IR/Pass.cpp
++++ b/lib/IR/Pass.cpp
+_at_@ -234,6 +234,8 @@ PassNameParser::~PassNameParser() {
+   // attempting to remove the registration listener is an error.
+ }
+
++TEMPLATE_INSTANTIATION(class cl::parser<const PassInfo *>);
++
+ //===----------------------------------------------------------------------===//
+ //   AnalysisUsage Class Implementation
+ //
+--
+2.1.4
diff --git a/testing/ghc-llvm35/llvm-0002-musl-triple.patch b/testing/ghc-llvm35/llvm-0002-musl-triple.patch
new file mode 100644
index 0000000..7ef97be
--- /dev/null
+++ b/testing/ghc-llvm35/llvm-0002-musl-triple.patch
_at_@ -0,0 +1,74 @@
+diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
+index 8a68599..072623c 100644
+--- a/include/llvm/ADT/Triple.h
++++ b/include/llvm/ADT/Triple.h
+_at_@ -154,6 +154,10 @@ public:
+     EABIHF,
+     Android,
+
++    Musl,
++    MuslEABI,
++    MuslEABIHF,
++
+     MSVC,
+     Itanium,
+     Cygnus,
+diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
+index 0838e90..4be78e5 100644
+--- a/lib/Support/Triple.cpp
++++ b/lib/Support/Triple.cpp
+_at_@ -175,6 +175,9 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
+   case CODE16: return "code16";
+   case EABI: return "eabi";
+   case EABIHF: return "eabihf";
++  case Musl: return "musl";
++  case MuslEABIHF: return "muslgnueabihf";
++  case MuslEABI: return "muslgnueabi";
+   case Android: return "android";
+   case MSVC: return "msvc";
+   case Itanium: return "itanium";
+_at_@ -375,6 +378,9 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
+     .StartsWith("code16", Triple::CODE16)
+     .StartsWith("gnu", Triple::GNU)
+     .StartsWith("android", Triple::Android)
++    .StartsWith("muslgnueabihf", Triple::MuslEABIHF)
++    .StartsWith("muslgnueabi", Triple::MuslEABI)
++    .StartsWith("musl", Triple::Musl)
+     .StartsWith("msvc", Triple::MSVC)
+     .StartsWith("itanium", Triple::Itanium)
+     .StartsWith("cygnus", Triple::Cygnus)
+--- llvm-3.6.1.src.orig/lib/Support/Triple.cpp
++++ llvm-3.6.1.src/lib/Support/Triple.cpp
+_at_@ -1094,6 +1094,7 @@
+     switch (getEnvironment()) {
+     case llvm::Triple::EABIHF:
+     case llvm::Triple::GNUEABIHF:
++    case llvm::Triple::MuslEABIHF:
+       return "arm1176jzf-s";
+     default:
+       return "arm7tdmi";
+diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h
+index dbacd4d..b330be5 100644
+--- a/lib/Target/ARM/ARMSubtarget.h
++++ b/lib/Target/ARM/ARMSubtarget.h
+_at_@ -369,8 +369,10 @@ public:
+   bool isTargetEHABICompatible() const {
+     return (TargetTriple.getEnvironment() == Triple::EABI ||
+             TargetTriple.getEnvironment() == Triple::GNUEABI ||
++            TargetTriple.getEnvironment() == Triple::MuslEABI ||
+             TargetTriple.getEnvironment() == Triple::EABIHF ||
+             TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
++            TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
+             TargetTriple.getEnvironment() == Triple::Android) &&
+            !isTargetDarwin() && !isTargetWindows();
+   }
+_at_@ -379,6 +381,7 @@ public:
+     // FIXME: this is invalid for WindowsCE
+     return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
+            TargetTriple.getEnvironment() == Triple::EABIHF ||
++           TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
+            isTargetWindows();
+   }
+   bool isTargetAndroid() const {
+--
+2.1.4
diff --git a/testing/ghc-llvm35/llvm-0003-musl-hacks.patch b/testing/ghc-llvm35/llvm-0003-musl-hacks.patch
new file mode 100644
index 0000000..7d3e0a6
--- /dev/null
+++ b/testing/ghc-llvm35/llvm-0003-musl-hacks.patch
_at_@ -0,0 +1,82 @@
+diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h
+index 46f87b9..41ac5fd 100644
+--- a/include/llvm/Target/TargetLibraryInfo.h
++++ b/include/llvm/Target/TargetLibraryInfo.h
+_at_@ -13,6 +13,15 @@
+ #include "llvm/ADT/DenseMap.h"
+ #include "llvm/Pass.h"
+
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+   class Triple;
+
+diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp
+index d2b551e..4634a13 100644
+--- a/lib/Support/DynamicLibrary.cpp
++++ b/lib/Support/DynamicLibrary.cpp
+_at_@ -138,7 +138,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
+
+ // This macro returns the address of a well-known, explicit symbol
+ #define EXPLICIT_SYMBOL(SYM) \
+-   if (!strcmp(symbolName, #SYM)) return &SYM
++   if (!strcmp(symbolName, #SYM)) return (void *) &SYM
+
+ // On linux we have a weird situation. The stderr/out/in symbols are both
+ // macros and global variables because of standards requirements. So, we
+diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc
+index e8f4643..8a320ef 100644
+--- a/lib/Support/Unix/Signals.inc
++++ b/lib/Support/Unix/Signals.inc
+_at_@ -416,7 +416,7 @@ static bool printSymbolizedStackTrace(void **StackTrace, int Depth, FILE *FD) {
+ // On glibc systems we have the 'backtrace' function, which works nicely, but
+ // doesn't demangle symbols.
+ void llvm::sys::PrintStackTrace(FILE *FD) {
+-#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
++#if defined(__GLIBC__) && defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
+   static void* StackTrace[256];
+   // Use backtrace() to output a backtrace on Linux systems with glibc.
+   int depth = backtrace(StackTrace,
+diff --git a/lib/Target/TargetLibraryInfo.cpp b/lib/Target/TargetLibraryInfo.cpp
+index c0abdbd..ed908f8 100644
+--- a/lib/Target/TargetLibraryInfo.cpp
++++ b/lib/Target/TargetLibraryInfo.cpp
+_at_@ -664,14 +664,15 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T,
+   }
+
+   // The following functions are available on at least Linux:
+-  if (!T.isOSLinux()) {
++  if (!T.isOSLinux())
++    TLI.setUnavailable(LibFunc::memalign);
++  if (1 /*!T.isGlibc()*/) {
+     TLI.setUnavailable(LibFunc::dunder_strdup);
+     TLI.setUnavailable(LibFunc::dunder_strtok_r);
+     TLI.setUnavailable(LibFunc::dunder_isoc99_scanf);
+     TLI.setUnavailable(LibFunc::dunder_isoc99_sscanf);
+     TLI.setUnavailable(LibFunc::under_IO_getc);
+     TLI.setUnavailable(LibFunc::under_IO_putc);
+-    TLI.setUnavailable(LibFunc::memalign);
+     TLI.setUnavailable(LibFunc::fopen64);
+     TLI.setUnavailable(LibFunc::fseeko64);
+     TLI.setUnavailable(LibFunc::fstat64);
+diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc
+index bf850c6..9e9088c 100644
+--- a/utils/unittest/googletest/src/gtest.cc
++++ b/utils/unittest/googletest/src/gtest.cc
+_at_@ -120,6 +120,7 @@
+
+ #if GTEST_CAN_STREAM_RESULTS_
+ # include <arpa/inet.h>  // NOLINT
++# include <sys/socket.h>  // NOLINT
+ # include <netdb.h>  // NOLINT
+ #endif
+
+--
+2.1.4
-- 
2.7.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Tue Mar 01 2016 - 19:28:54 GMT