Check the version of LLVM at configure time to make sure it has a matching version.
authorZoltan Varga <vargaz@gmail.com>
Thu, 19 Sep 2013 20:04:49 +0000 (22:04 +0200)
committerZoltan Varga <vargaz@gmail.com>
Thu, 19 Sep 2013 20:05:00 +0000 (22:05 +0200)
Makefile.am
configure.in [changed mode: 0755->0644]

index c9192998d89f82a1627ce526bfcf244d4c39547b..de43007b1ca8e5160f1e9b5ac76db26e8fe7e875 100644 (file)
@@ -155,3 +155,9 @@ package-inputs:
        done
        echo "</root>" >> msvc/scripts/order.xml
 
+# Update llvm version in configure.in to the output of $LLVM_DIR/bin/llvm-config --version
+update-llvm-version:
+       if test "x$$LLVM_DIR" = "x"; then echo "Set the make variable LLVM_DIR to the directory containing the LLVM installation."; exit 1; fi
+       REV=`$(LLVM_DIR)/bin/llvm-config --version` && sed -e "s,expected_llvm_version=.*,expected_llvm_version=\"$$REV\"," < configure.in > tmp && mv tmp configure.in && echo "Version set to $$REV."
+
+
old mode 100755 (executable)
new mode 100644 (file)
index 899fe44..cc5faf1
@@ -2364,6 +2364,7 @@ dnl **************
 
 AC_ARG_ENABLE(llvm,[  --enable-llvm    Enable the LLVM back-end], enable_llvm=$enableval, enable_llvm=no)
 AC_ARG_ENABLE(loadedllvm,[  --enable-loadedllvm        Load the LLVM back-end dynamically], enable_llvm=$enableval && enable_loadedllvm=$enableval, enable_loadedllvm=no)
+AC_ARG_ENABLE(llvm-version-check,[  --enable-llvm-version-check Check that the LLVM matches the version expected by mono], enable_llvm_version_check=$enableval, enable_llvm_version_check=yes)
 
 if test "x$enable_llvm" = "xyes"; then
    AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
@@ -2392,6 +2393,8 @@ if test "x$enable_llvm" = "xyes"; then
    fi
    LLVM_LIBS="$LLVM_LDFLAGS $LLVM_LIBS -lstdc++"
 
+   expected_llvm_version="3.3svn-mono/2c9642d"
+
    # Should be something like '2.6' or '2.7svn'
    llvm_version=`$LLVM_CONFIG --version`
    major_version=`echo $llvm_version | cut -c 1`
@@ -2401,6 +2404,11 @@ if test "x$enable_llvm" = "xyes"; then
    if echo $llvm_version | grep -q 'mono'; then
          AC_DEFINE(LLVM_MONO_BRANCH, 1, [Whenever we are using the mono branch of LLVM])
          LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DLLVM_MONO_BRANCH"       
+         if test "x$enable_llvm_version_check" == "xyes"; then
+                if test "$llvm_version" != "$expected_llvm_version"; then
+                       AC_MSG_ERROR([Expected llvm version $expected_llvm_version, but llvm-config --version returned $llvm_version"])
+                fi
+         fi
    else
          AC_MSG_ERROR([Compiling with stock LLVM is not supported, please use the Mono LLVM repo at https://github.com/mono/llvm, with the GIT branch which matches this version of mono, i.e. 'mono-2-10' for Mono 2.10.])
    fi