Bug 66029

Summary: More robust way of detecting LLVM major and minor versions
Product: Mesa Reporter: Klemens Baum <klemensbaum>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Use the new version defines if available
Use the new version defines if available

Description Klemens Baum 2013-06-21 23:02:55 UTC
Created attachment 81187 [details] [review]
Use the new version defines if available

LLVM added LLVM_VERSION_MAJOR and LLVM_VERSION_MINOR defines in r150405 (see http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/107277).

For better compatibility and to avoid breaking in the future, these should be used instead of the current sed hack that deletes the "svn.*" part from the `llvm-config --version' output.

The attached patch uses the new defines if available, and falls back to the sed hack otherwise.
Comment 1 Klemens Baum 2013-06-21 23:05:02 UTC
Comment on attachment 81187 [details] [review]
Use the new version defines if available

>diff --git a/configure.ac b/configure.ac
>index 6832b0d..3cabfe8 100644
>--- a/configure.ac
>+++ b/configure.ac
>@@ -1577,8 +1577,26 @@ if test "x$enable_gallium_llvm" = xyes; then
>     fi
>
>     if test "x$LLVM_CONFIG" != xno; then
>-	LLVM_VERSION=`$LLVM_CONFIG --version | sed 's/svn.*//g'`
>-	LLVM_VERSION_INT=`echo $LLVM_VERSION | sed -e 's/\([[0-9]]\)\.\([[0-9]]\)/\10\2/g'`
>+        LLVM_VERSION=`$LLVM_CONFIG --version | sed 's/svn.*//g'`
>+        LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
>+        LLVM_BINDIR=`$LLVM_CONFIG --bindir`
>+        LLVM_CPPFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cppflags"`
>+        LLVM_CFLAGS=$LLVM_CPPFLAGS   # CPPFLAGS seem to be sufficient
>+        LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"`
>+        LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir`
>+        LLVM_LIBDIR=`$LLVM_CONFIG --libdir`
>+
>+        AC_COMPUTE_INT([LLVM_VERSION_MAJOR], [LLVM_VERSION_MAJOR],
>+            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
>+        AC_COMPUTE_INT([LLVM_VERSION_MINOR], [LLVM_VERSION_MINOR],
>+            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
>+
>+        if test "x${LLVM_VERSION_MAJOR}" != x; then
>+            LLVM_VERSION_INT="${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}"
>+        else
>+            LLVM_VERSION_INT=`echo $LLVM_VERSION | sed -e 's/\([[0-9]]\)\.\([[0-9]]\)/\10\2/g'`
>+        fi
>+
>         LLVM_COMPONENTS="engine bitwriter"
>         if $LLVM_CONFIG --components | grep -q '\<mcjit\>'; then
>             LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit"
>@@ -1591,17 +1609,10 @@ if test "x$enable_gallium_llvm" = xyes; then
>                 LLVM_COMPONENTS="${LLVM_COMPONENTS} irreader"
>             fi
>         fi
>-	LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
>-	LLVM_BINDIR=`$LLVM_CONFIG --bindir`
>-	LLVM_CPPFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cppflags"`
>-	LLVM_CFLAGS=$LLVM_CPPFLAGS   # CPPFLAGS seem to be sufficient
>-	LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"`
>-	LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir`
>-	LLVM_LIBDIR=`$LLVM_CONFIG --libdir`
>-	DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT"
>-	MESA_LLVM=1
>-
>-	dnl Check for Clang interanl headers
>+        DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT"
>+        MESA_LLVM=1
>+
>+        dnl Check for Clang internal headers
>         if test "x$enable_opencl" = xyes; then
>             if test "x$CLANG_LIBDIR" = x; then
>                 CLANG_LIBDIR=${LLVM_LIBDIR}
>@@ -1611,8 +1622,8 @@ if test "x$enable_gallium_llvm" = xyes; then
>                 AC_MSG_ERROR([Could not find clang internal header stddef.h in $CLANG_RESOURCE_DIR Use --with-clang-libdir to specify the correct path to the clang libraries.]))
>         fi
>     else
>-	MESA_LLVM=0
>-	LLVM_VERSION_INT=0
>+        MESA_LLVM=0
>+        LLVM_VERSION_INT=0
>     fi
> else
>     MESA_LLVM=0
Comment 2 Klemens Baum 2013-06-21 23:06:33 UTC
Created attachment 81188 [details] [review]
Use the new version defines if available

Sorry for the previous comment, didn't mark as patch.
Comment 3 Tom Stellard 2013-06-27 14:39:37 UTC
Hi, this patch looks good at first glance.  Could you generate the patch using git format-patch and send it to the mailing list (mesa-dev@lists.freedesktop.org)
Comment 5 Tom Stellard 2013-07-19 15:08:22 UTC
Committed as 45574ab2e92f0bf74b18448baff49cb2eb5db620

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.