From 2d1aeb6ac6ea27dd296d66666189adf6896cd4d1 Mon Sep 17 00:00:00 2001
From: Kevin Mihelich <kevin@archlinuxarm.org>
Date: Sat, 2 Jun 2012 14:22:07 -0400
Subject: [PATCH] extra/mesa to 8.0.3-2

---
 extra/mesa/PKGBUILD                        |  7 +++-
 extra/mesa/mesa-8.0.3-llvm-3.1-fixes.patch | 44 ++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 extra/mesa/mesa-8.0.3-llvm-3.1-fixes.patch

diff --git a/extra/mesa/PKGBUILD b/extra/mesa/PKGBUILD
index 0cb153709..097702ed7 100644
--- a/extra/mesa/PKGBUILD
+++ b/extra/mesa/PKGBUILD
@@ -27,7 +27,8 @@ makedepends=('glproto>=1.4.15' 'libdrm>=2.4.30' 'libxxf86vm>=1.1.1' 'libxdamage>
              'gcc-libs>=4.6.1' 'dri2proto>=2.6' 'python2' 'libxml2' 'imake' 'llvm' 'udev')
 url="http://mesa3d.sourceforge.net"
 license=('custom')
-source=(LICENSE)
+source=(LICENSE
+        mesa-8.0.3-llvm-3.1-fixes.patch)
 if [ "${_git}" = "true" ]; then
 	# mesa git shot from 7.11 branch - see for state: http://cgit.freedesktop.org/mesa/mesa/commit/?h=7.11&id=1ae00c5960af83bea9545a18a1754bad83d5cbd0
 	#source=(${source[@]} 'ftp://ftp.archlinux.org/other/mesa/mesa-1ae00c5960af83bea9545a18a1754bad83d5cbd0.tar.bz2')
@@ -39,10 +40,14 @@ if [ "${_git}" = "true" ]; then
 )
 fi
 md5sums=('5c65a0fe315dd347e09b1f2826a1df5a'
+         'c452ed3392468170726c004c2f4e02ca'
          'cc5ee15e306b8c15da6a478923797171')
 
 build() {
     cd ${srcdir}/?esa-*
+
+    patch -Np1 -i "${srcdir}/mesa-8.0.3-llvm-3.1-fixes.patch"
+
     [ "${CARCH}" = "armv7h" ] && CFLAGS=`echo $CFLAGS | sed -e 's/-O2/-O1/'` && CXXFLAGS="$CFLAGS"
 
 if [ "${_git}" = "true" ]; then
diff --git a/extra/mesa/mesa-8.0.3-llvm-3.1-fixes.patch b/extra/mesa/mesa-8.0.3-llvm-3.1-fixes.patch
new file mode 100644
index 000000000..922577aef
--- /dev/null
+++ b/extra/mesa/mesa-8.0.3-llvm-3.1-fixes.patch
@@ -0,0 +1,44 @@
+diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+index a50a51d..f1bb4d9 100644
+--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
++++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+@@ -235,7 +235,24 @@ lp_disassemble(const void* func)
+    int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
+ #endif
+
+-#if HAVE_LLVM >= 0x0300
++#if HAVE_LLVM >= 0x0301
++   OwningPtr<const MCRegisterInfo> MRI(T->createMCRegInfo(Triple));
++   if (!MRI) {
++      debug_printf("error: no register info for target %s\n", Triple.c_str());
++      return;
++   }
++
++   OwningPtr<const MCInstrInfo> MII(T->createMCInstrInfo());
++   if (!MII) {
++      debug_printf("error: no instruction info for target %s\n", Triple.c_str());
++      return;
++   }
++#endif
++
++#if HAVE_LLVM >= 0x0301
++   OwningPtr<MCInstPrinter> Printer(
++         T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *MII, *MRI, *STI));
++#elif HAVE_LLVM == 0x0300
+    OwningPtr<MCInstPrinter> Printer(
+          T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *STI));
+ #elif HAVE_LLVM >= 0x0208
+diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+index fe7616b..68f8808 100644
+--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
++++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+@@ -62,7 +62,11 @@
+ extern "C" void
+ lp_register_oprofile_jit_event_listener(LLVMExecutionEngineRef EE)
+ {
++#if HAVE_LLVM >= 0x0301
++   llvm::unwrap(EE)->RegisterJITEventListener(llvm::JITEventListener::createOProfileJITEventListener());
++#else
+    llvm::unwrap(EE)->RegisterJITEventListener(llvm::createOProfileJITEventListener());
++#endif
+ }