configure.ac: Only add default LLVM components if needed
authorTobias Droste <tdroste@gmx.de>
Sat, 19 Nov 2016 01:39:09 +0000 (02:39 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Mon, 5 Dec 2016 14:43:47 +0000 (14:43 +0000)
LLVM components are only added when LLVM is needed.
This means gallium adds this as soon as "--enable-gallium-llvm"
is "yes" and radv + opencl add it explicitly.

v5:
Removed hunk that disabled LLVM for gallium if it was not found.

Signed-off-by: Tobias Droste <tdroste@gmx.de>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
configure.ac

index cd42bdddd06af643eb1db0d757f02e92fc6b67a1..3acaa4448e3980c7e9834561ba339a9dfe118965 100644 (file)
@@ -899,7 +899,11 @@ llvm_add_component() {
     new_llvm_component=$1
     driver_name=$2
 
-    LLVM_COMPONENTS="$LLVM_COMPONENTS $new_llvm_component"
+    if $LLVM_CONFIG --components | grep -iqw $new_llvm_component ; then
+        LLVM_COMPONENTS="${LLVM_COMPONENTS} ${new_llvm_component}"
+    else
+        AC_MSG_ERROR([LLVM component '$new_llvm_component' not enabled in your LLVM build. Required by $driver_name.])
+    fi
 }
 
 llvm_add_default_components() {
@@ -982,8 +986,6 @@ llvm_set_environment_variables() {
             LLVM_VERSION_INT=`echo $LLVM_VERSION | sed -e 's/\([[0-9]]\)\.\([[0-9]]\)/\10\2/g'`
         fi
 
-        llvm_add_default_components "gallium"
-
         DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
         MESA_LLVM=1
     else
@@ -1009,6 +1011,7 @@ radeon_llvm_check() {
 
     llvm_add_target $amdgpu_llvm_target_name $4
 
+    llvm_add_default_components $4
     llvm_add_component "bitreader" $4
     llvm_add_component "ipo" $4
 
@@ -2134,6 +2137,7 @@ if test "x$enable_opencl" = xyes; then
 
     llvm_check_version_for "3" "6" "0" "opencl"
 
+    llvm_add_default_components "opencl"
     llvm_add_component "all-targets" "opencl"
     llvm_add_component "linker" "opencl"
     llvm_add_component "instrumentation" "opencl"
@@ -2508,6 +2512,11 @@ if test -n "$with_gallium_drivers"; then
     done
 fi
 
+if test "x$enable_gallium_llvm" == "xyes"; then
+    llvm_check_version_for "3" "3" "0" "gallium"
+    llvm_add_default_components "gallium"
+fi
+
 dnl Set LLVM_LIBS - This is done after the driver configuration so
 dnl that drivers can add additional components to LLVM_COMPONENTS.
 dnl Previously, gallium drivers were updating LLVM_LIBS directly