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

Tobias Droste tdroste at gmx.de
Tue Oct 11 01:44:57 UTC 2016


Consolidate the required LLVM versions at the top where the other
versions for dependencies are listed.
Rework the LLVM_VERSION and LLVM_VERSION_INT calculation to make the
format "x.y.z." possible.

LLVM_VERSION_INT is now including LLVM_VERSION_PATCH.
For the C define HAVE_LLVM is set now which does not include
LLVM_VERSION_PATCH.

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

diff --git a/configure.ac b/configure.ac
index f1b00f1..6c7c914 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,15 @@ XVMC_REQUIRED=1.0.6
 PYTHON_MAKO_REQUIRED=0.8.0
 LIBSENSORS_REQUIRED=4.0.0
 
+dnl LLVM versions
+LLVM_VERSION_REQUIRED_GALLIUM=3.3.0
+LLVM_VERSION_REQUIRED_LLVMPIPE=3.6.0
+LLVM_VERSION_REQUIRED_OPENCL=3.6.0
+LLVM_VERSION_REQUIRED_R600=3.6.0
+LLVM_VERSION_REQUIRED_RADEONSI=3.6.0
+LLVM_VERSION_REQUIRED_RADV=3.9.0
+LLVM_VERSION_REQUIRED_SWR=3.6.0
+
 dnl Check for progs
 AC_PROG_CPP
 AC_PROG_CC
@@ -935,23 +944,30 @@ if test "x$LLVM_CONFIG" != xno; then
         [#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"])
+
+    if test -z "$LLVM_VERSION_PATCH"; then
+        LLVM_VERSION_PATCH=`echo $LLVM_VERSION | cut -d. -f3 | egrep -o '^[[0-9]]+'`
+    fi
 
-    LLVM_VERSION_PATCH=`echo $LLVM_VERSION | cut -d. -f3 | egrep -o '^[[0-9]]+'`
     if test -z "$LLVM_VERSION_PATCH"; then
         LLVM_VERSION_PATCH=0
     fi
 
     if test -n "${LLVM_VERSION_MAJOR}"; 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="${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}"
     fi
 
-    DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
+    LLVM_VERSION_INT=`echo $LLVM_VERSION | sed -e 's/\.\([[1-9]][[0-9]]\)\.\([[0-9]]\)/\1\2/' -e 's/\.\([[0-9]]\)\.\([[0-9]]\)/0\1\2/' -e 's/\.\([[1-9]][[0-9]]\)/\10/' -e 's/\.\([[0-9]]\)/0\10/'`
+    HAVE_LLVM=`echo $LLVM_VERSION | sed -e 's/\.\([[1-9]][[0-9]]\)\.\([[0-9]]\)/\1/' -e 's/\.\([[0-9]]\)\.\([[0-9]]\)/0\1/' -e 's/\.\([[1-9]][[0-9]]\)/\1/' -e 's/\.\([[0-9]]\)/0\1/'`
+
+    DEFINES="${DEFINES} -DHAVE_LLVM=0x0$HAVE_LLVM -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
     MESA_LLVM=1
 else
     MESA_LLVM=0
     LLVM_VERSION_INT=0
+    LLVM_VERSION=0.0.0
 fi
 
 AC_SUBST([MESA_LLVM])
@@ -966,8 +982,10 @@ AC_SUBST([LLVM_INCLUDEDIR])
 AC_SUBST([LLVM_VERSION])
 
 llvm_check_version_for() {
-    if test "x$MESA_LLVM" = x0 || 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])
+    llvm_target_version=`echo $1 | sed -e 's/\.\([[1-9]][[0-9]]\)\.\([[0-9]]\)/\1\2/' -e 's/\.\([[0-9]]\)\.\([[0-9]]\)/0\1\2/' -e 's/\.\([[1-9]][[0-9]]\)/\10/' -e 's/\.\([[0-9]]\)/0\10/'`
+
+    if test "x$MESA_LLVM" = x0 || test "${LLVM_VERSION_INT}" -lt "${llvm_target_version}"; then
+        AC_MSG_ERROR([LLVM $1 or newer is required for $2])
     fi
 
     if test "x$LLVM_DEFAULT_COMPONENTS_ADDED" = "xno"; then
@@ -1027,7 +1045,7 @@ llvm_add_target() {
 }
 
 radeon_llvm_check() {
-    if test ${LLVM_VERSION_INT} -lt 307; then
+    if test ${LLVM_VERSION_INT} -lt 3070; then
         amdgpu_llvm_target_name='r600'
     else
         amdgpu_llvm_target_name='amdgpu'
@@ -1035,9 +1053,9 @@ radeon_llvm_check() {
 
     llvm_check_version_for $*
 
-    llvm_add_target $amdgpu_llvm_target_name $4
-    llvm_add_component "bitreader" $4
-    llvm_add_component "ipo" $4
+    llvm_add_target $amdgpu_llvm_target_name $2
+    llvm_add_component "bitreader" $2
+    llvm_add_component "ipo" $2
 
     NEED_RADEON_LLVM=yes
 
@@ -1901,7 +1919,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_VERSION_REQUIRED_RADV "radv"
             HAVE_RADEON_VULKAN=yes;
             if test "x$with_sha1" == "x"; then
                 AC_MSG_ERROR([radv vulkan driver requires SHA1])
@@ -2190,7 +2208,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_VERSION_REQUIRED_OPENCL "opencl"
 
     llvm_add_component "all-targets" "opencl"
     llvm_add_component "ipos" "opencl"
@@ -2405,7 +2423,7 @@ gallium_require_llvm() {
             AC_MSG_ERROR([--enable-gallium-llvm is required when building $1])
         fi
 
-        llvm_check_version_for "3" "3" "0" "gallium"
+        llvm_check_version_for $LLVM_VERSION_REQUIRED_GALLIUM "gallium"
         llvm_add_target "x86" "gallium"
         ;;
     esac
@@ -2506,10 +2524,10 @@ if test -n "$with_gallium_drivers"; then
         xr600)
             HAVE_GALLIUM_R600=yes
             PKG_CHECK_MODULES([RADEON], [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED])
-            gallium_require_drm "Gallium R600"
+            gallium_require_drm "r600"
             gallium_require_drm_loader
             if test "x$enable_opencl" = xyes; then
-                radeon_llvm_check "3" "6" "0" "r600g"
+                radeon_llvm_check $LLVM_VERSION_REQUIRED_R600 "r600"
                 gallium_require_llvm "r600"
                 llvm_add_component "asmparser" "r600"
             fi
@@ -2520,7 +2538,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_llvm_check "3" "6" "0" "radeonsi"
+            radeon_llvm_check $LLVM_VERSION_REQUIRED_RADEONSI "radeonsi"
             gallium_require_llvm "radeonsi"
             require_egl_drm "radeonsi"
             ;;
@@ -2539,13 +2557,13 @@ if test -n "$with_gallium_drivers"; then
         xswrast)
             HAVE_GALLIUM_SOFTPIPE=yes
             if test "x$MESA_LLVM" = x1 && (test "x$enable_gallium_llvm" = xyes || test "x$enable_gallium_llvm" = xauto); then
-                llvm_check_version_for "3" "6" "0" "llvmpipe"
+                llvm_check_version_for $LLVM_VERSION_REQUIRED_LLVMPIPE "llvmpipe"
                 gallium_require_llvm "llvmpipe"
                 HAVE_GALLIUM_LLVMPIPE=yes
             fi
             ;;
         xswr)
-            llvm_check_version_for "3" "6" "0" "swr"
+            llvm_check_version_for $LLVM_VERSION_REQUIRED_SWR "swr"
             gallium_require_llvm "swr"
 
             swr_require_cxx_feature_flags "C++11" "__cplusplus >= 201103L" \
-- 
2.10.0



More information about the mesa-dev mailing list