--- configure
+++ configure
@@ -8147,6 +8147,10 @@
 $RM -r conftest*
 
 
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
 if test -n "$compiler"; then
 
 lt_prog_compiler_no_builtin_flag=
@@ -16686,10 +16690,12 @@
 
     if test "x$enable_lto" = "xyes"; then
         for ac_prog in llvm-config                                     \
-             llvm-config-3.6 llvm-config-3.5 llvm-config-3.4 \
-             llvm-config-3.3 llvm-config-3.2 llvm-config-3.1 \
-             llvm-config36 llvm-config35 llvm-config34       \
-             llvm-config33 llvm-config32 llvm-config31
+             llvm-config-3.7 llvm-config-3.6 llvm-config-3.5 \
+             llvm-config-3.4 llvm-config-3.3 llvm-config-3.2 \
+             llvm-config-3.1                                 \
+             llvm-config37 llvm-config36 llvm-config35       \
+             llvm-config34 llvm-config33 llvm-config32       \
+             llvm-config31
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
--- m4/llvm.m4
+++ m4/llvm.m4
@@ -8,10 +8,12 @@
     if test "x$enable_lto" = "xyes"; then
         AC_PATH_PROGS(LLVM_CONFIG,
             [llvm-config                                     \
-             llvm-config-3.6 llvm-config-3.5 llvm-config-3.4 \
-             llvm-config-3.3 llvm-config-3.2 llvm-config-3.1 \
-             llvm-config36 llvm-config35 llvm-config34       \
-             llvm-config33 llvm-config32 llvm-config31],
+             llvm-config-3.7 llvm-config-3.6 llvm-config-3.5 \
+             llvm-config-3.4 llvm-config-3.3 llvm-config-3.2 \
+             llvm-config-3.1                                 \
+             llvm-config37 llvm-config36 llvm-config35       \
+             llvm-config34 llvm-config33 llvm-config32       \
+             llvm-config31],
         no)
 
         if test "x$LLVM_CONFIG" != "xno"; then
