Mail archive
alpine-aports

[alpine-aports] [PATCH 1/4] testing/ghc-llvm new aport

From: Mitch Tishmack <mitch.tishmack_at_gmail.com>
Date: Sun, 15 May 2016 22:30:15 -0500

---
 testing/ghc-llvm/APKBUILD                    | 169 +++++++++++++++++++++++++++
 testing/ghc-llvm/llvm-0002-musl-triple.patch |  90 ++++++++++++++
 testing/ghc-llvm/llvm-0003-musl-hacks.patch  | 114 ++++++++++++++++++
 3 files changed, 373 insertions(+)
 create mode 100755 testing/ghc-llvm/APKBUILD
 create mode 100644 testing/ghc-llvm/llvm-0002-musl-triple.patch
 create mode 100644 testing/ghc-llvm/llvm-0003-musl-hacks.patch
diff --git a/testing/ghc-llvm/APKBUILD b/testing/ghc-llvm/APKBUILD
new file mode 100755
index 0000000..aeb3726
--- /dev/null
+++ b/testing/ghc-llvm/APKBUILD
_at_@ -0,0 +1,169 @@
+# 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.7
+llvm_version=${llvm_major}.1
+suffix="-${llvm_major}"
+opt=opt${suffix}
+llc=llc${suffix}
+pkgname=ghc-${_pkgname}
+# Allow for multiple installs, intentionally not default.
+if [ ! -z $MULTI ]; then
+	replaces=${pkgname}
+	pkgname=${pkgname}-${llvm_major}
+fi
+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"
+source="
+	llvm-0002-musl-triple.patch
+        llvm-0003-musl-hacks.patch
+	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 \
+        -DCMAKE_INSTALL_PREFIX=/usr \
+        -DLLVM_TARGETS_TO_BUILD='all' \
+        -DLLVM_BUILD_EXTERNAL_COMPILER_RT=NO \
+        -DBUILD_SHARED_LIBS=NO \
+        -DLLVM_BUILD_DOCS=NO \
+        -DLLVM_BUILD_TESTS=NO \
+        -DLLVM_ENABLE_CXX1Y=NO \
+        -DLLVM_ENABLE_FFI=YES \
+        -DLLVM_ENABLE_SPHINX=NO \
+        -DLLVM_ENABLE_TERMINFO=YES \
+        -DWITH_POLLY=YES \
+        -DLLVM_INCLUDE_EXAMPLES=NO \
+        -DLLVM_INCLUDE_TESTS=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() {
+        tmp="$srcdir/tmp"
+        install -d ${tmp} || 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"
+                mkdir -p "${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 llc opt|| 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
+}
+md5sums="7fc6f417edec0cd7792df58386396b7d  llvm-0002-musl-triple.patch
+f57e1e394bb9b1bdb809dc5b2a8bf04e  llvm-0003-musl-hacks.patch
+bf8b3a2c79e61212c5409041dfdbd319  llvm-3.7.1.src.tar.xz
+3a2a7367002740881637f4d47bca4dc3  polly-3.7.1.src.tar.xz"
+sha256sums="4aa20d16e6afb41a2e6fd916dab9aec28acbf4f7f732524a755973c57daecde1  llvm-0002-musl-triple.patch
+028916482184cc29ca2bca4fd59a1cae2c61ee591e3d40fd4e3e9e472629da89  llvm-0003-musl-hacks.patch
+be7794ed0cec42d6c682ca8e3517535b54555a3defabec83554dbc74db545ad5  llvm-3.7.1.src.tar.xz
+ce9273ad315e1904fd35dc64ac4375fd592f3c296252ab1d163b9ff593ec3542  polly-3.7.1.src.tar.xz"
+sha512sums="e136731a82d52b70267c8fc8fdc35340406be577cd26188b0d8273fa3059d5606c4a3f618b02a99820b601dcf86bc3cb1ff9420be463521d978b5dda7764e6e8  llvm-0002-musl-triple.patch
+fdd08d4b380d1310282f4d1ee2c5c7b91246346bb275928233fd8a90d2b4c1599556af1f7d7c278fdf13faeee11ac7800ab2912a6e88dba0c9e8f6d906691e0f  llvm-0003-musl-hacks.patch
+ac521debc02f6deba96ef975d6a546b0c5c77299c1dbf5e1b87a7974ff5e7fd715bd7e384b92d9adf572ce47130bdbf6d3c648eb0d7f72f16f976292e4909e90  llvm-3.7.1.src.tar.xz
+f03a794ab85d587511653e0799c3f2ba95145762552741959decc42cde7f7f5bd80caf79c0169440b7e5d16d3bf895501387d5094f531386d74b6c3e4fe6b1e0  polly-3.7.1.src.tar.xz"
diff --git a/testing/ghc-llvm/llvm-0002-musl-triple.patch b/testing/ghc-llvm/llvm-0002-musl-triple.patch
new file mode 100644
index 0000000..2f6fd59
--- /dev/null
+++ b/testing/ghc-llvm/llvm-0002-musl-triple.patch
_at_@ -0,0 +1,90 @@
+From 58be6f7fb164dbf42fdd28ce6474dbe4bc5ca401 Mon Sep 17 00:00:00 2001
+From: Andrea Brancaleoni <miwaxe_at_gmail.com>
+Date: Tue, 8 Sep 2015 21:53:42 +0200
+Subject: [PATCH 2/3] musl triple
+
+---
+ include/llvm/ADT/Triple.h           | 4 ++++
+ lib/Support/Triple.cpp              | 6 ++++++
+ lib/Target/ARM/ARMSubtarget.h       | 3 +++
+ lib/Target/ARM/ARMTargetMachine.cpp | 2 ++
+ 4 files changed, 15 insertions(+)
+
+diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
+index 947812d..d2a6bbe 100644
+--- a/include/llvm/ADT/Triple.h
++++ b/include/llvm/ADT/Triple.h
+_at_@ -167,6 +167,10 @@ public:
+     EABIHF,
+     Android,
+ 
++    Musl,
++    MuslEABI,
++    MuslEABIHF,
++
+     MSVC,
+     Itanium,
+     Cygnus,
+diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
+index c6646fb..8d47ad9 100644
+--- a/lib/Support/Triple.cpp
++++ b/lib/Support/Triple.cpp
+_at_@ -192,6 +192,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 "musleabihf";
++  case MuslEABI: return "musleabi";
+   case Android: return "android";
+   case MSVC: return "msvc";
+   case Itanium: return "itanium";
+_at_@ -427,6 +430,9 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
+     .StartsWith("code16", Triple::CODE16)
+     .StartsWith("gnu", Triple::GNU)
+     .StartsWith("android", Triple::Android)
++    .StartsWith("musleabihf", Triple::MuslEABIHF)
++    .StartsWith("musleabi", Triple::MuslEABI)
++    .StartsWith("musl", Triple::Musl)
+     .StartsWith("msvc", Triple::MSVC)
+     .StartsWith("itanium", Triple::Itanium)
+     .StartsWith("cygnus", Triple::Cygnus)
+diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h
+index dd101df..c5bdcca 100644
+--- a/lib/Target/ARM/ARMSubtarget.h
++++ b/lib/Target/ARM/ARMSubtarget.h
+_at_@ -381,8 +381,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_@ -391,6 +393,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 {
+diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp
+index 93495d6..56e6b7f 100644
+--- a/lib/Target/ARM/ARMTargetMachine.cpp
++++ b/lib/Target/ARM/ARMTargetMachine.cpp
+_at_@ -97,6 +97,8 @@ computeTargetABI(const Triple &TT, StringRef CPU,
+     case llvm::Triple::GNUEABIHF:
+     case llvm::Triple::EABIHF:
+     case llvm::Triple::EABI:
++    case llvm::Triple::MuslEABI:
++    case llvm::Triple::MuslEABIHF:
+       TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS;
+       break;
+     case llvm::Triple::GNU:
+-- 
+2.5.1
+
diff --git a/testing/ghc-llvm/llvm-0003-musl-hacks.patch b/testing/ghc-llvm/llvm-0003-musl-hacks.patch
new file mode 100644
index 0000000..d88b5fc
--- /dev/null
+++ b/testing/ghc-llvm/llvm-0003-musl-hacks.patch
_at_@ -0,0 +1,114 @@
+From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001
+From: Andrea Brancaleoni <miwaxe_at_gmail.com>
+Date: Tue, 8 Sep 2015 22:03:02 +0200
+Subject: [PATCH 3/3] musl
+
+---
+ include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
+ lib/Analysis/TargetLibraryInfo.cpp        | 5 +++--
+ lib/Support/DynamicLibrary.cpp            | 2 +-
+ lib/Support/Unix/Signals.inc              | 6 +++---
+ utils/unittest/googletest/src/gtest.cc    | 1 +
+ 5 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
+index e0a1ee3..465b65a 100644
+--- a/include/llvm/Analysis/TargetLibraryInfo.h
++++ b/include/llvm/Analysis/TargetLibraryInfo.h
+_at_@ -18,6 +18,15 @@
+ #include "llvm/IR/Module.h"
+ #include "llvm/Pass.h"
+ 
++#undef fopen64
++#undef fseeko64
++#undef fstat64
++#undef fstatvfs64
++#undef ftello64
++#undef lstat64
++#undef stat64
++#undef tmpfile64
++
+ namespace llvm {
+ /// VecDesc - Describes a possible vectorization of a function.
+ /// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
+diff --git a/lib/Analysis/TargetLibraryInfo.cpp b/lib/Analysis/TargetLibraryInfo.cpp
+index 635c50c..863f4a0 100644
+--- a/lib/Analysis/TargetLibraryInfo.cpp
++++ b/lib/Analysis/TargetLibraryInfo.cpp
+_at_@ -336,14 +336,15 @@ static void initialize(TargetLibraryInfoImpl &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/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp
+index 9a7aeb5..e21750d 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 bfe2a3a..e8372d9 100644
+--- a/lib/Support/Unix/Signals.inc
++++ b/lib/Support/Unix/Signals.inc
+_at_@ -117,7 +117,7 @@ static void RegisterHandlers() {
+   // during handling an actual signal because you can't safely call new in a
+   // signal handler.
+   *SignalsMutex;
+-  
++
+   // If the handlers are already registered, we're done.
+   if (NumRegisteredSignals != 0) return;
+ 
+_at_@ -164,7 +164,7 @@ static void RemoveFilesToRemove() {
+     // super-user permissions.
+     if (!S_ISREG(buf.st_mode))
+       continue;
+-  
++
+     // Otherwise, remove the file. We ignore any errors here as there is nothing
+     // else we can do.
+     unlink(path);
+_at_@ -430,7 +430,7 @@ static bool printSymbolizedStackTrace(void **StackTrace, int Depth,
+ // On glibc systems we have the 'backtrace' function, which works nicely, but
+ // doesn't demangle symbols.
+ void llvm::sys::PrintStackTrace(raw_ostream &OS) {
+-#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/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc
+index 5780764..1d548c1 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.5.1
+
-- 
2.8.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Sun May 15 2016 - 22:30:15 GMT