[Mesa-dev] [PATCH v4 18/18] configure.ac: Add required LLVM versions to the top

Tobias Droste tdroste at gmx.de
Sun Oct 16 00:20:55 UTC 2016


Consolidate the required LLVM versions at the top where the other
versions for dependencies are listed.

This also tries to get the patch version from the LLVM headers.
It defaults to 0 if it does not find it.
This is good enough since the patch version is in the header since
3.6.0 and the only driver that need this require >=3.6.0.

Signed-off-by: Tobias Droste <tdroste at gmx.de>
---
 configure.ac | 72 +++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 57 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9e7130ad..770db66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,14 @@ XVMC_REQUIRED=1.0.6
 PYTHON_MAKO_REQUIRED=0.8.0
 LIBSENSORS_REQUIRED=4.0.0
 
+dnl LLVM versions
+LLVM_REQUIRED_GALLIUM=3.3.0
+LLVM_REQUIRED_OPENCL=3.6.0
+LLVM_REQUIRED_R600=3.6.0
+LLVM_REQUIRED_RADEONSI=3.6.0
+LLVM_REQUIRED_RADV=3.9.0
+LLVM_REQUIRED_SWR=3.6.0
+
 dnl Check for progs
 AC_PROG_CPP
 AC_PROG_CC
@@ -972,16 +980,18 @@ llvm_set_environment_variables() {
             [#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"])
+        AC_COMPUTE_INT([LLVM_VERSION_PATCH], [LLVM_VERSION_PATCH],
+            [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
 
-        LLVM_VERSION_PATCH=`echo $LLVM_VERSION | cut -d. -f3 | egrep -o '^[[0-9]]+'`
+        # Only needed for LLVM < 3.6.0
         if test -z "$LLVM_VERSION_PATCH"; then
             LLVM_VERSION_PATCH=0
         fi
 
-        if test -n "${LLVM_VERSION_MAJOR}"; then
+        if test "$LLVM_VERSION_MINOR" -lt 10; 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'`
+            LLVM_VERSION_INT="${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}"
         fi
 
         DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
@@ -993,9 +1003,41 @@ llvm_set_environment_variables() {
 }
 
 llvm_check_version_for() {
-    if test "${LLVM_VERSION_INT}${LLVM_VERSION_PATCH}" -lt "${1}0${2}${3}"; then
-        AC_MSG_ERROR([LLVM $1.$2.$3 or newer is required for $4])
+    if test "x$MESA_LLVM" = x0; then
+        AC_MSG_ERROR([LLVM $1 or newer is required for $2])
+        return
+    fi
+
+    llvm_target_version_major=`echo $1 | cut -d. -f1 | egrep -o '^[[0-9]]+'`
+    llvm_target_version_minor=`echo $1 | cut -d. -f2 | egrep -o '^[[0-9]]+'`
+    llvm_target_version_patch=`echo $1 | cut -d. -f3 | egrep -o '^[[0-9]]+'`
+
+    if test "$LLVM_VERSION_MAJOR" -gt "$llvm_target_version_major"; then
+        # major > required major
+        #  --> OK
+        return
+    fi
+
+    if test "$LLVM_VERSION_MAJOR" -eq "$llvm_target_version_major"; then
+        if test "$LLVM_VERSION_MINOR" -gt "$llvm_target_version_minor"; then
+            # major = required major and
+            # minor > required minor
+            #  --> OK
+            return
+        else
+            if test "$LLVM_VERSION_MINOR" -eq "$llvm_target_version_minor"; then
+                if test "$LLVM_VERSION_PATCH" -ge "$llvm_target_version_patch"; then
+                    # major = required major and
+                    # minor = required minor and
+                    # patch >= required patch
+                    #  --> OK
+                    return
+                fi
+            fi
+        fi
     fi
+
+    AC_MSG_ERROR([LLVM $1 or newer is required for $2])
 }
 
 radeon_llvm_check() {
@@ -1007,11 +1049,11 @@ radeon_llvm_check() {
 
     llvm_check_version_for $*
 
-    llvm_add_target $amdgpu_llvm_target_name $4
+    llvm_add_target $amdgpu_llvm_target_name $2
 
-    llvm_add_default_components $4
-    llvm_add_component "bitreader" $4
-    llvm_add_component "ipo" $4
+    llvm_add_default_components $2
+    llvm_add_component "bitreader" $2
+    llvm_add_component "ipo" $2
 
     NEED_RADEON_LLVM=yes
     if test "x$have_libelf" != xyes; then
@@ -1887,7 +1929,7 @@ if test -n "$with_vulkan_drivers"; then
             ;;
         xradeon)
             PKG_CHECK_MODULES([AMDGPU], [libdrm_amdgpu >= $LIBDRM_AMDGPU_REQUIRED])
-            radeon_llvm_check "3" "9" "0" "radv"
+            radeon_llvm_check $LLVM_REQUIRED_RADV "radv"
             HAVE_RADEON_VULKAN=yes;
             if test "x$with_sha1" == "x"; then
                 AC_MSG_ERROR([radv vulkan driver requires SHA1])
@@ -2176,7 +2218,7 @@ if test "x$enable_opencl" = xyes; then
        AC_MSG_ERROR([Clover requires libelf])
     fi
 
-    llvm_check_version_for "3" "6" "0" "opencl"
+    llvm_check_version_for $LLVM_REQUIRED_OPENCL "opencl"
 
     llvm_add_default_components "opencl"
     llvm_add_component "all-targets" "opencl"
@@ -2396,7 +2438,7 @@ gallium_require_drm() {
 
 gallium_require_llvm() {
     if test "x$enable_gallium_llvm" == "xyes"; then
-        llvm_check_version_for "3" "3" "0" "gallium"
+        llvm_check_version_for $LLVM_REQUIRED_GALLIUM "gallium"
     else
         AC_MSG_ERROR([--enable-gallium-llvm is required when building $1])
     fi
@@ -2507,7 +2549,7 @@ if test -n "$with_gallium_drivers"; then
             gallium_require_drm "r600"
             gallium_require_drm_loader
             if test "x$enable_opencl" = xyes; then
-                radeon_gallium_llvm_check "3" "6" "0" "r600"
+                radeon_gallium_llvm_check $LLVM_REQUIRED_R600 "r600"
 
                 llvm_add_component "asmparser" "r600"
                 llvm_add_component "bitreader" "r600"
@@ -2519,7 +2561,7 @@ if test -n "$with_gallium_drivers"; then
             PKG_CHECK_MODULES([AMDGPU], [libdrm_amdgpu >= $LIBDRM_AMDGPU_REQUIRED])
             gallium_require_drm "radeonsi"
             gallium_require_drm_loader
-            radeon_gallium_llvm_check "3" "6" "0" "radeonsi"
+            radeon_gallium_llvm_check $LLVM_REQUIRED_RADEONSI "radeonsi"
             require_egl_drm "radeonsi"
             ;;
         xnouveau)
@@ -2541,7 +2583,7 @@ if test -n "$with_gallium_drivers"; then
             fi
             ;;
         xswr)
-            llvm_check_version_for "3" "6" "0" "swr"
+            llvm_check_version_for $LLVM_REQUIRED_SWR "swr"
             gallium_require_llvm "swr"
 
             swr_require_cxx_feature_flags "C++11" "__cplusplus >= 201103L" \
-- 
2.10.1



More information about the mesa-dev mailing list