[Mesa-dev] [PATCH v2 2/6] configure.ac: Add helper to add LLVM components/targets

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


This adds helper function to add components and/or targets anywhere
i configure.ac.
The first driver that calls "llvm_check_version_for()" adds the
default components.
This is done so that they only get added and checked for if there
is a driver that actually needs them.

WARNING: Still a broken build!!!

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

diff --git a/configure.ac b/configure.ac
index a2a7ed1..be802d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -929,6 +929,7 @@ if test "x$LLVM_CONFIG" != xno; then
     LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"`
     LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir`
     LLVM_LIBDIR=`$LLVM_CONFIG --libdir`
+    LLVM_DEFAULT_COMPONENTS_ADDED="no"
 
     AC_COMPUTE_INT([LLVM_VERSION_MAJOR], [LLVM_VERSION_MAJOR],
         [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"])
@@ -952,12 +953,6 @@ if test "x$LLVM_CONFIG" != xno; then
         AC_MSG_ERROR([LLVM $LLVM_REQUIRED_VERSION_MAJOR.$LLVM_REQUIRED_VERSION_MINOR or newer is required])
     fi
 
-    LLVM_COMPONENTS="engine bitwriter mcjit mcdisassembler"
-
-    if $LLVM_CONFIG --components | grep -q inteljitevents ; then
-        LLVM_COMPONENTS="${LLVM_COMPONENTS} inteljitevents"
-    fi
-
     if test "x$enable_opencl" = xyes; then
         llvm_check_version_for "3" "6" "0" "opencl"
 
@@ -993,9 +988,64 @@ AC_SUBST([LLVM_INCLUDEDIR])
 AC_SUBST([LLVM_VERSION])
 
 llvm_check_version_for() {
-    if test "${LLVM_VERSION_INT}${LLVM_VERSION_PATCH}" -lt "${1}0${2}${3}"; then
+    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])
     fi
+
+    if test "x$LLVM_DEFAULT_COMPONENTS_ADDED" = "xno"; then
+        LLVM_DEFAULT_COMPONENTS_ADDED="yes"
+        llvm_add_default_components $driver_name
+    fi
+}
+
+llvm_add_default_components() {
+    driver_name=$1
+
+    # Required default components
+    llvm_add_component "engine" $driver_name
+    llvm_add_component "bitwriter" $driver_name
+    llvm_add_component "mcjit" $driver_name
+    llvm_add_component "mcdisassembler" $driver_name
+
+    # Optional default components
+    llvm_add_component_optional "inteljitevents" $driver_name
+}
+
+llvm_add_component_optional() {
+    new_llvm_component=$1
+    driver_name=$2
+
+    if echo "$LLVM_COMPONENTS" | grep -iqw $new_llvm_component ; then
+        # Component already added
+        return
+    fi
+
+    if $LLVM_CONFIG --components | grep -iqw $new_llvm_component ; then
+        LLVM_COMPONENTS="${LLVM_COMPONENTS} ${new_llvm_component}"
+    fi
+}
+
+llvm_add_component() {
+    new_llvm_component=$1
+    driver_name=$2
+
+    llvm_add_component_optional $new_llvm_component $driver_name
+
+    if echo "$LLVM_COMPONENTS" | grep -ivqw $new_llvm_component ; then
+        # Component was not added
+        AC_MSG_ERROR([LLVM component '$new_llvm_component' not enabled in your LLVM build. Required by $driver_name.])
+    fi
+}
+
+llvm_add_target() {
+    new_llvm_target=$1
+    driver_name=$2
+
+    if $LLVM_CONFIG --targets-built | grep -iqw $new_llvm_target ; then
+        llvm_add_component $new_llvm_target $fail_if_not_present $driver_name
+    else
+        AC_MSG_ERROR([LLVM target '$new_llvm_target' not enabled in your LLVM build. Required by $driver_name.])
+    fi
 }
 
 radeon_llvm_check() {
-- 
2.10.0



More information about the mesa-dev mailing list