[Mesa-dev] [PATCH] configure.ac: handle llvm built with cmake in one shared library
Laurent Carlier
lordheavym at gmail.com
Tue Sep 29 08:34:05 PDT 2015
llvm can be built with cmake in a libray with the name libLLVM.so.$version
Tested with both llvm-3.7.0 and llvm-3.8.0svn
v2: check and use llvm build-system feature, update comments
Signed-off-by: Laurent Carlier <lordheavym at gmail.com>
---
configure.ac | 60 +++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 23 deletions(-)
diff --git a/configure.ac b/configure.ac
index 217281f..6101836 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2188,39 +2188,53 @@ dnl by calling llvm-config --libs ${DRIVER_LLVM_COMPONENTS}, but
dnl this was causing the same libraries to be appear multiple times
dnl in LLVM_LIBS.
+llvm_cmake_check_libs() {
+ dnl If LLVM was built with CMake, there will be one shared object per
+ dnl component or one shared object.
+ LLVM_SO_NAME=LLVM.$IMP_LIB_EXT.`$LLVM_CONFIG --version`
+ AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME"], [llvm_have_one_so=yes])
+
+ if test "x$llvm_have_one_so" = xyes; then
+ dnl LLVM was built with cmake with only one shared versioned object.
+ LLVM_LIBS="-l:lib$LLVM_SO_NAME"
+ else
+ AS_IF([test ! -f "$LLVM_LIBDIR/libLLVMTarget.$IMP_LIB_EXT"],
+ [AC_MSG_ERROR([Could not find llvm shared libraries:
+ 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 by default.
+ If you do not want to build with llvm shared libraries and instead want to
+ use llvm static libraries then add --disable-llvm-shared-libs to your configure
+ invocation and rebuild.])])
+ fi
+}
+
if test "x$MESA_LLVM" != x0; then
LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
+ dnl with llvm 3.8 we can try to determine libray name from the buildsystem
+ AS_IF([test "$LLVM_VERSION_INT" -ge "308"], [llvm_build_system="`$LLVM_CONFIG --build-system`"])
dnl llvm-config may not give the right answer when llvm is a built as a
dnl single shared library, so we must work the library name out for
dnl ourselves.
dnl (See https://llvm.org/bugs/show_bug.cgi?id=6823)
if test "x$enable_llvm_shared_libs" = xyes; then
- dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
- LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
- AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.$IMP_LIB_EXT"], [llvm_have_one_so=yes])
-
- if test "x$llvm_have_one_so" = xyes; then
- dnl LLVM was built using auto*, so there is only one shared object.
- LLVM_LIBS="-l$LLVM_SO_NAME"
+ if test "x$llvm_build_system" = xcmake; then
+ llvm_cmake_check_libs
else
- dnl If LLVM was built with CMake, there will be one shared object per
- dnl component.
- AS_IF([test ! -f "$LLVM_LIBDIR/libLLVMTarget.$IMP_LIB_EXT"],
- [AC_MSG_ERROR([Could not find llvm shared libraries:
- 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 by default.
- If you do not want to build with llvm shared libraries and instead want to
- use llvm static libraries then add --disable-llvm-shared-libs to your configure
- invocation and rebuild.])])
-
- dnl We don't need to update LLVM_LIBS in this case because the LLVM
- dnl install uses a shared object for each component and we have
- dnl already added all of these objects to LLVM_LIBS.
+ dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
+ LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
+ AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.$IMP_LIB_EXT"], [llvm_have_one_so=yes])
+
+ if test "x$llvm_have_one_so" = xyes; then
+ dnl LLVM was built using auto*, so there is only one shared object.
+ LLVM_LIBS="-l$LLVM_SO_NAME"
+ else
+ llvm_cmake_check_libs
+ fi
fi
else
AC_MSG_WARN([Building mesa with statically linked LLVM may cause compilation issues])
--
2.6.0
More information about the mesa-dev
mailing list