Browse code

bb#11254 - added --with-llvm-linking option to specify system-llvm linking method

Kevin Lin authored on 2015/02/07 07:59:43
Showing 3 changed files
... ...
@@ -173,6 +173,11 @@ AC_OUTPUT
173 173
 if test "$enable_llvm" = "yes" && test "$subdirfailed" != "no"; then
174 174
     AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested])
175 175
 fi
176
+if test "$enable_llvm" = "auto" && test "$subdirfailed" != "no"; then
177
+    system_llvm="MIA"
178
+    llvm_linking=""
179
+fi
180
+
176 181
 AM_CONDITIONAL([ENABLE_LLVM],
177 182
 	       [test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"])
178 183
 no_recursion="yes";
... ...
@@ -216,7 +221,11 @@ have_jit="no"
216 216
 if test "$subdirfailed" = "no"; then
217 217
     have_jit="yes"
218 218
 fi
219
-CL_MSG_STATUS([llvm        ],[$have_jit, from $system_llvm],[$enable_llvm])
219
+if test "x$llvm_linking" = "x"; then
220
+   CL_MSG_STATUS([llvm        ],[$have_jit, from $system_llvm],[$enable_llvm])
221
+else
222
+   CL_MSG_STATUS([llvm        ],[$have_jit, from $system_llvm ($llvm_linking)],[$enable_llvm])
223
+fi
220 224
 CL_MSG_STATUS([mempool     ],[$have_mempool],[$enable_mempool])
221 225
 
222 226
 AC_MSG_NOTICE([Summary of engine detection features])
... ...
@@ -77,6 +77,26 @@ AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm],
77 77
  fi
78 78
 ])
79 79
 
80
+llvm_linking=
81
+AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking],
82
+[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])],
83
+[
84
+if test "x$llvmconfig" = "x"; then
85
+   AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without valid llvm-config])  
86
+else
87
+case "$withval" in
88
+  static)
89
+    llvm_linking="static"
90
+    ;;
91
+  dynamic)
92
+    llvm_linking="dynamic"
93
+    ;;
94
+  *)
95
+    AC_MSG_ERROR([Invalid argument to --with-llvm-linking])
96
+esac
97
+fi
98
+], [])
99
+
80 100
 AC_MSG_CHECKING([for supported LLVM version])
81 101
 if test "x$llvmconfig" = "x"; then
82 102
     dnl macro not available in older autotools
... ...
@@ -112,16 +132,24 @@ fi
112 112
 dnl aquire the required flags to properly link in external LLVM
113 113
 if test "x$llvmconfig" != "x"; then
114 114
     AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`])
115
-    if test $llvmver_test -ge 350; then
116
-        dnl LLVM 3.5.0 and after splits linker flags into two sets
117
-        ldflags=`$llvmconfig --ldflags`
118
-        syslibs=`$llvmconfig --system-libs`
119
-        AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"])
120
-    else
115
+
116
+    if test "x$llvm_linking" = "xdynamic"; then
121 117
         AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
118
+        AC_SUBST(LLVMCONFIG_LIBS, [-lLLVM-$llvmver])
119
+        AC_SUBST(LLVMCONFIG_LIBFILES, [])
120
+    else
121
+        if test $llvmver_test -ge 350; then
122
+           dnl LLVM 3.5.0 and after splits linker flags into two sets
123
+           ldflags=`$llvmconfig --ldflags`
124
+           syslibs=`$llvmconfig --system-libs`
125
+           AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"])
126
+        else
127
+           AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
128
+        fi
129
+        AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`])
130
+        AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`])
122 131
     fi
123
-    AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`])
124
-    AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`])
132
+
125 133
     AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS])
126 134
     AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS])
127 135
     AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS])
... ...
@@ -13,6 +13,31 @@ AC_ARG_WITH([system-llvm], [AC_HELP_STRING([--with-system-llvm],
13 13
  esac
14 14
 ], [system_llvm="built-in"])
15 15
 
16
+AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking],
17
+[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])],
18
+[
19
+if test "x$system_llvm" = "xbuilt-in"; then
20
+   AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without specifying system-llvm])  
21
+else
22
+case "$withval" in
23
+  static)
24
+    llvm_linking="static"
25
+    ;;
26
+  dynamic)
27
+    llvm_linking="dynamic"
28
+    ;;
29
+  *)
30
+    AC_MSG_ERROR([Invalid argument to --with-llvm-linking])
31
+esac
32
+fi
33
+], [
34
+if test "x$system_llvm" = "xbuilt-in"; then
35
+   llvm_linking=""
36
+else
37
+   llvm_linking="auto"
38
+fi
39
+])
40
+
16 41
 AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
17 42
 [enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
18 43
 [enable_llvm=$enableval],
... ...
@@ -29,4 +54,5 @@ if test "$enable_llvm" != "no"; then
29 29
     AC_CONFIG_SUBDIRS_OPTIONAL([libclamav/c++])
30 30
 else
31 31
     system_llvm="none"
32
+    llvm_linking=""
32 33
 fi