[Mesa-dev] [PATCH 2/3] configure.ac: Force use of LLVM shared libs with --enable-opencl

Tom Stellard tom at stellard.net
Fri Jan 18 08:58:27 PST 2013


From: Tom Stellard <thomas.stellard at amd.com>

If we build clover with LLVM static libraries, then clover and also each
pipe_*.so driver that is built will contain their own static copy of
LLVM.  The recent automake changes have uncovered a problem where
the pipe_*.so drivers try to use clover's LLVM symbols.  This causes
LLVM's static registry objects to be initialized each time
a pipe_*.so driver is loaded by clover.  Initializing these objects
multiple times is not allowed and leads to assertion failures in the
LLVM code.

We can avoid all these problems by having clover and all the pipe_*.so
drivers link against the same LLVM shared library.

https://bugs.freedesktop.org/show_bug.cgi?id=59334
https://bugs.freedesktop.org/show_bug.cgi?id=59534
---
 configure.ac | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index c85c836..4b93f22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -609,8 +609,10 @@ AC_ARG_ENABLE([vdpau],
    [enable_vdpau=auto])
 AC_ARG_ENABLE([opencl],
    [AS_HELP_STRING([--enable-opencl],
-         [enable OpenCL library @<:@default=no@:>@])],
-   [enable_opencl="$enableval"],
+         [enable OpenCL library NOTE: Enabling this option will also enable
+          --with-llvm-shared-libs
+          @<:@default=no@:>@])],
+   [enable_opencl="$enableval" with_llvm_shared_libs="$enableval"],
    [enable_opencl=no])
 AC_ARG_ENABLE([xlib_glx],
     [AS_HELP_STRING([--enable-xlib-glx],
@@ -1903,7 +1905,22 @@ dnl in LLVM_LIBS.
 
 if test "x$with_llvm_shared_libs" = xyes; then
     dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
-    LLVM_LIBS="-lLLVM-`$LLVM_CONFIG --version`"
+    LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
+    AC_CHECK_FILE("$LLVM_LIBDIR/lib$LLVM_SO_NAME.so",,
+                AC_MSG_ERROR([Could not find llvm shared library: lib$LLVM_SO_NAME.so :
+	Please make sure you have built llvm with the --enable-shared option
+	and that your llvm libraries are installed in $LLVM_LIBDIR
+	If you have installed your llvm libraries to a different directory you
+	can use the --with-llvm-prefix= configure flag to specify this directory.
+	NOTE: Mesa is attempting to use llvm shared libraries because you have
+	passed one of the following options to configure:
+		--with-llvm-shared-libs
+		--enable-opencl
+	If you do not want to build with llvm shared libraries and instead want to
+	use llvm static libraries then remove these options from your configure
+	invocation and reconfigure.]))
+
+    LLVM_LIBS="-l$LLVM_SO_NAME"
 else
     LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
 fi
-- 
1.7.11.4



More information about the mesa-dev mailing list