Browse code

config: unified llvm-opts handling, changed llvm defaults

Kevin Lin authored on 2016/05/03 04:45:01
Showing 5 changed files
... ...
@@ -231,10 +231,12 @@ have_jit="no"
231 231
 if test "$subdirfailed" = "no"; then
232 232
     have_jit="yes"
233 233
 fi
234
-if test "x$llvm_linking" = "x"; then
235
-   CL_MSG_STATUS([llvm        ],[$have_jit, from $system_llvm],[$enable_llvm])
234
+if test "$enable_llvm" = "no"; then
235
+   CL_MSG_STATUS([llvm        ],[$have_jit],[$enable_llvm])
236
+elif test "x$llvm_linking" = "x"; then
237
+   CL_MSG_STATUS([llvm        ],[$have_jit($llvmver), from $system_llvm],[$enable_llvm])
236 238
 else
237
-   CL_MSG_STATUS([llvm        ],[$have_jit, from $system_llvm ($llvm_linking)],[$enable_llvm])
239
+   CL_MSG_STATUS([llvm        ],[$have_jit($llvmver), from $system_llvm ($llvm_linking)],[$enable_llvm])
238 240
 fi
239 241
 CL_MSG_STATUS([mempool     ],[$have_mempool],[$enable_mempool])
240 242
 
... ...
@@ -50,13 +50,89 @@ AC_CHECK_GNU_MAKE
50 50
 GMAKE="$llvm_cv_gnu_make_command"
51 51
 AC_SUBST([GMAKE])
52 52
 
53
-m4_include(m4/llvm-flags.m4)
53
+m4_include(m4/llvm-opts.m4)
54
+if test "x$llvmflagerrmsg" != "x"; then
55
+    AC_MSG_ERROR([$llvmflagerrmsg])
56
+fi
54 57
 
55
-if test "x$llvmconfig" = "x"; then
58
+dnl Version number check
59
+if test "x$llvmconfig" != "x"; then
60
+    AC_MSG_NOTICE([Using external LLVM])
61
+else
62
+    packaged_llvm="yes"
56 63
     dnl macro not available in older autotools
57 64
     AC_CONFIG_SUBDIRS([llvm])
58 65
 fi
59 66
 
67
+llvmver_val=`echo "$llvmver" | sed -e 's/svn//g'`
68
+AC_CANONICAL_HOST
69
+case $host_os in
70
+  darwin* )
71
+    llvmver_sval=`echo "$llvmver_val" | sed -Ee 's/[[0-9]]+//' | sed -e 's/^\.//'`
72
+    llvmver_major=`echo "$llvmver_val"  | sed -Ee 's/([[0-9]]+).*/\1/'`
73
+    llvmver_minor=`echo "$llvmver_sval" | sed -Ee 's/([[0-9]]+).*/\1/'`
74
+    llvmver_patch=`echo "$llvmver_sval" | sed -Ee 's/[[0-9]]+//' | sed -e 's/^\.//' | sed -Ee 's/([[0-9]]+).*/\1/'`
75
+    ;;
76
+  *)
77
+    llvmver_sval=`echo "$llvmver_val" | sed -re 's/[[0-9]]+//' | sed -e 's/^\.//'`
78
+    llvmver_major=`echo "$llvmver_val"  | sed -re 's/([[0-9]]+).*/\1/'`
79
+    llvmver_minor=`echo "$llvmver_sval" | sed -re 's/([[0-9]]+).*/\1/'`
80
+    llvmver_patch=`echo "$llvmver_sval" | sed -re 's/[[0-9]]+//' | sed -e 's/^\.//' | sed -re 's/([[0-9]]+).*/\1/'`
81
+    ;;
82
+esac
83
+dnl suffix unused as of LLVM 3.4.1
84
+llvmver_suffix=
85
+if test "x$llvmver_patch" = "x"; then
86
+    llvmver_patch=0
87
+fi
88
+
89
+AC_MSG_CHECKING([for supported LLVM version])
90
+llvmver_test=${llvmver_major}${llvmver_minor}${llvmver_patch}
91
+if test "x$packaged_llvm" = "xyes"; then
92
+    AC_MSG_RESULT([ok ($llvmver)])
93
+elif test $llvmver_test -lt 290; then
94
+    AC_MSG_RESULT([no ($llvmver)])
95
+    AC_MSG_ERROR([LLVM >= 2.9 required, but "$llvmver"($llvmver_test) found])
96
+elif test $llvmver_test -lt 360; then
97
+    llvmcomp="jit nativecodegen scalaropts ipo"
98
+    AC_MSG_RESULT([ok ($llvmver)])
99
+elif test $llvmver_test -lt 370; then
100
+    dnl LLVM 3.6.0 removed jit, so we have to use mcjit
101
+    dnl and we're using InitializeNativeTargetAsmParser, so we need the architecture specific parsers
102
+    llvmcomp="mcjit nativecodegen scalaropts ipo x86asmparser powerpcasmparser"
103
+    AC_MSG_RESULT([ok ($llvmver)])
104
+else
105
+    AC_MSG_RESULT([no ($llvmver)])
106
+    AC_MSG_ERROR([LLVM < 3.7 required, but "$llvmver"($llvmver_test) found])
107
+fi
108
+
109
+dnl acquire the required flags to properly link in external LLVM
110
+if test "x$llvmconfig" != "x"; then
111
+    AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`])
112
+
113
+    if test "x$llvm_linking" = "xdynamic"; then
114
+        AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
115
+        AC_SUBST(LLVMCONFIG_LIBS, [-lLLVM-$llvmver])
116
+        AC_SUBST(LLVMCONFIG_LIBFILES, [])
117
+    else
118
+        if test $llvmver_test -ge 350; then
119
+           dnl LLVM 3.5.0 and after splits linker flags into two sets
120
+           ldflags=`$llvmconfig --ldflags`
121
+           syslibs=`$llvmconfig --system-libs`
122
+           AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"])
123
+        else
124
+           AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
125
+        fi
126
+        AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs $llvmcomp`])
127
+        AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles $llvmcomp`])
128
+    fi
129
+
130
+    AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS])
131
+    AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS])
132
+    AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS])
133
+fi
134
+dnl patch does not affect clamav source (yet)
135
+llvmver_int=${llvmver_major}${llvmver_minor}
60 136
 AC_SUBST([LLVM_VERSION], [$llvmver_int])
61 137
 
62 138
 AC_ARG_ENABLE([llvm],AC_HELP_STRING([-enable-llvm],
63 139
deleted file mode 100644
... ...
@@ -1,137 +0,0 @@
1
-dnl Act as a single handler point for LLVM options
2
-dnl Compile a set of compile and linker flags for LLVM
3
-dnl Populates LLVMCONFIG_CXXFLAGS, LLVMCONFIG_LDFLAGS, LLVMCONFIG_LIBS, and LLVMCONFIG_LIBFILES macros
4
-dnl Assigns llvmver_int, system_llvm, llvm_linking, and enable_llvm variables (for tracking in features summary)
5
-
6
-dnl Determine if LLVM is requested (or auto, reassigned if system-llvm specified)
7
-AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
8
-[enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
9
-[enable_llvm=$enableval], [enable_llvm="auto"])
10
-
11
-dnl Determine whether to user built in LLVM or to use system-specified LLVM
12
-dnl locate the llvmconfig program
13
-AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm],
14
-[Use system llvm instead of built-in, uses full path to llvm-config or bin directory
15
-     (default=search PATH environment variable)]),
16
-[case "$withval" in
17
-  yes)
18
-     AC_PATH_PROG([llvmconfig], [llvm-config])
19
-     if test "x$llvmconfig" = "x"; then
20
-         AC_MSG_ERROR([llvm-config cannot be found within PATH])
21
-     fi
22
-     ;;
23
-  no) ;;
24
-  *)
25
-     if test -d "$withval"; then
26
-         AC_PATH_PROG([llvmconfig], [llvm-config], [], [$withval/bin])
27
-     else
28
-         llvmconfig=$withval
29
-         if test ! -x "$llvmconfig"; then
30
-             llvmconfig=""
31
-         fi
32
-     fi
33
-
34
-     if test "x$llvmconfig" = "x"; then
35
-         AC_MSG_ERROR([llvm-config does not exist at $withval])
36
-     fi
37
-     ;;
38
-  esac
39
-])
40
-
41
-dnl Determine linking method to external LLVM, built-in only does static linking
42
-AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking],
43
-[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])],
44
-[if test "x$llvmconfig" = "x"; then
45
-   AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without valid llvm-config])  
46
-else
47
-   case "$withval" in
48
-     static)
49
-         llvm_linking="static"
50
-         ;;
51
-     dynamic)
52
-         llvm_linking="dynamic"
53
-         ;;
54
-     *)
55
-         AC_MSG_ERROR([Invalid argument to --with-llvm-linking])
56
-   esac
57
-fi
58
-], [llvm_linking=""])
59
-
60
-dnl Version number check
61
-if test "x$llvmconfig" != "x"; then
62
-    llvmver=`$llvmconfig --version`
63
-    AC_MSG_NOTICE([Using external LLVM])
64
-else
65
-    llvmver="2.8"
66
-    packaged_llvm="yes"
67
-fi
68
-
69
-llvmver_val=`echo "$llvmver" | sed -e 's/svn//g'`
70
-AC_CANONICAL_HOST
71
-case $host_os in
72
-  darwin* )
73
-    llvmver_sval=`echo "$llvmver_val" | sed -Ee 's/[[0-9]]+//' | sed -e 's/^\.//'`
74
-    llvmver_major=`echo "$llvmver_val"  | sed -Ee 's/([[0-9]]+).*/\1/'`
75
-    llvmver_minor=`echo "$llvmver_sval" | sed -Ee 's/([[0-9]]+).*/\1/'`
76
-    llvmver_patch=`echo "$llvmver_sval" | sed -Ee 's/[[0-9]]+//' | sed -e 's/^\.//' | sed -Ee 's/([[0-9]]+).*/\1/'`
77
-    ;;
78
-  *)
79
-    llvmver_sval=`echo "$llvmver_val" | sed -re 's/[[0-9]]+//' | sed -e 's/^\.//'`
80
-    llvmver_major=`echo "$llvmver_val"  | sed -re 's/([[0-9]]+).*/\1/'`
81
-    llvmver_minor=`echo "$llvmver_sval" | sed -re 's/([[0-9]]+).*/\1/'`
82
-    llvmver_patch=`echo "$llvmver_sval" | sed -re 's/[[0-9]]+//' | sed -e 's/^\.//' | sed -re 's/([[0-9]]+).*/\1/'`
83
-    ;;
84
-esac
85
-dnl suffix unused as of LLVM 3.4.1
86
-llvmver_suffix=
87
-if test "x$llvmver_patch" = "x"; then
88
-    llvmver_patch=0
89
-fi
90
-
91
-AC_MSG_CHECKING([for supported LLVM version])
92
-llvmver_test=${llvmver_major}${llvmver_minor}${llvmver_patch}
93
-if test "x$packaged_llvm" = "xyes"; then
94
-    AC_MSG_RESULT([ok ($llvmver)])
95
-elif test $llvmver_test -lt 290; then
96
-    AC_MSG_RESULT([no ($llvmver)])
97
-    AC_MSG_ERROR([LLVM >= 2.9 required, but "$llvmver"($llvmver_test) found])
98
-elif test $llvmver_test -lt 360; then
99
-    llvmcomp="jit nativecodegen scalaropts ipo"
100
-    AC_MSG_RESULT([ok ($llvmver)])
101
-elif test $llvmver_test -lt 370; then
102
-    dnl LLVM 3.6.0 removed jit, so we have to use mcjit
103
-    dnl and we're using InitializeNativeTargetAsmParser, so we need the architecture specific parsers
104
-    llvmcomp="mcjit nativecodegen scalaropts ipo x86asmparser powerpcasmparser"
105
-    AC_MSG_RESULT([ok ($llvmver)])
106
-else
107
-    AC_MSG_RESULT([no ($llvmver)])
108
-    AC_MSG_ERROR([LLVM < 3.7 required, but "$llvmver"($llvmver_test) found])
109
-fi
110
-
111
-dnl aquire the required flags to properly link in external LLVM
112
-if test "x$llvmconfig" != "x"; then
113
-    AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`])
114
-
115
-    if test "x$llvm_linking" = "xdynamic"; then
116
-        AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
117
-        AC_SUBST(LLVMCONFIG_LIBS, [-lLLVM-$llvmver])
118
-        AC_SUBST(LLVMCONFIG_LIBFILES, [])
119
-    else
120
-        if test $llvmver_test -ge 350; then
121
-           dnl LLVM 3.5.0 and after splits linker flags into two sets
122
-           ldflags=`$llvmconfig --ldflags`
123
-           syslibs=`$llvmconfig --system-libs`
124
-           AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"])
125
-        else
126
-           AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
127
-        fi
128
-        AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs $llvmcomp`])
129
-        AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles $llvmcomp`])
130
-    fi
131
-
132
-    AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS])
133
-    AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS])
134
-    AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS])
135
-fi
136
-dnl patch does not affect clamav source (yet)
137
-llvmver_int=${llvmver_major}${llvmver_minor}
138 1
new file mode 100644
... ...
@@ -0,0 +1,74 @@
0
+dnl Act as a single handler point for LLVM options
1
+dnl Assigns enable_llvm, system_llvm, llvm_linking, and llvmver variables
2
+dnl Assigns llvmoptserrmsg variable on error
3
+
4
+dnl Determine if LLVM is requested (or auto, reassigned if system-llvm specified)
5
+dnl Overrides "auto" with "yes" if a system-llvm is specified
6
+AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
7
+[enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
8
+[enable_llvm=$enableval], [enable_llvm="auto"])
9
+
10
+if test "$enable_llvm" != "no"; then
11
+
12
+dnl Determine whether to user built in LLVM or to use system-specified LLVM
13
+dnl locate the llvmconfig program
14
+AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm],
15
+[Specify system llvm location or to use old package, uses full path to llvm-config or bin directory
16
+     (default=search PATH environment variable)]),
17
+[system_llvm=$withval; if test "$enable_llvm" = "auto"; then enable_llvm="yes"; fi], [system_llvm="yes"])
18
+
19
+case "$system_llvm" in
20
+  yes)
21
+     AC_PATH_PROG([llvmconfig], [llvm-config])
22
+     if test "x$llvmconfig" = "x"; then
23
+         llvmoptserrmsg="llvm-config cannot be found within PATH"
24
+     fi
25
+     ;;
26
+  no) ;;
27
+  *)
28
+     if test -d "$withval"; then
29
+         AC_PATH_PROG([llvmconfig], [llvm-config], [], [$withval/bin])
30
+     else
31
+         llvmconfig=$withval
32
+         if test ! -x "$llvmconfig"; then
33
+             llvmconfig=""
34
+         fi
35
+     fi
36
+
37
+     if test "x$llvmconfig" = "x"; then
38
+         llvmoptserrmsg="llvm-config does not exist at $withval"
39
+     fi
40
+     ;;
41
+esac
42
+
43
+if test "x$llvmconfig" != "x"; then
44
+
45
+dnl Determine linking method to external LLVM, built-in only does static linking
46
+AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking],
47
+[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])],
48
+[if test "x$llvmconfig" = "x"; then
49
+   AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without valid llvm-config])
50
+else
51
+   case "$withval" in
52
+     static)
53
+         llvm_linking="static"
54
+         ;;
55
+     dynamic)
56
+         llvm_linking="dynamic"
57
+         ;;
58
+     *)
59
+         AC_MSG_ERROR([Invalid argument to --with-llvm-linking])
60
+   esac
61
+fi
62
+], [llvm_linking=""])
63
+
64
+llvmver=`$llvmconfig --version`
65
+
66
+else dnl test "x$llvmconfig" != "x"
67
+
68
+llvmver="2.8"
69
+system_llvm="internal"
70
+
71
+fi dnl test "x$llvmconfig" != "x"
72
+
73
+fi dnl test "enable_llvm" != "no
... ...
@@ -1,53 +1,13 @@
1
-AC_ARG_WITH([system-llvm], [AC_HELP_STRING([--with-system-llvm],
2
-[use system llvm instead of built-in, uses full path to llvm-config
3
-@<:@default=/usr/local or /usr if not found in /usr/local@:>@])],
4
-[case "$withval" in
5
-  yes)
6
-    system_llvm="default"
7
-    ;;
8
-  no)
9
-    system_llvm="built-in"
10
-    ;;
11
-  *)
12
-    system_llvm=$withval
13
- esac
14
-], [system_llvm="built-in"])
1
+m4_include([libclamav/c++/m4/llvm-opts.m4])
15 2
 
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
-
41
-AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
42
-[enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
43
-[enable_llvm=$enableval],
44
-[
45
-if test "x$system_llvm" != "xbuilt-in"; then
46
-    enable_llvm="yes"
47
-else
48
-    enable_llvm="auto"
3
+if test "x$llvmoptserrmsg" != "x"; then
4
+    if test "$enable_llvm" = "auto"; then
5
+        enable_llvm="no"
6
+    else
7
+        AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested])
8
+        dnl AC_MSG_ERROR([$llvmoptserrmsg])
9
+    fi
49 10
 fi
50
-])
51 11
 
52 12
 if test "$enable_llvm" != "no"; then
53 13
     dnl Try to configure subdir, optionally