Skip to content

Commit

Permalink
bb#11254 - added --with-llvm-linking option to specify system-llvm li…
Browse files Browse the repository at this point in the history
…nking method
  • Loading branch information
Kevin Lin committed Feb 6, 2015
1 parent 3897b37 commit 08db174
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 9 deletions.
11 changes: 10 additions & 1 deletion configure.ac
Expand Up @@ -173,6 +173,11 @@ AC_OUTPUT
if test "$enable_llvm" = "yes" && test "$subdirfailed" != "no"; then
AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested])
fi
if test "$enable_llvm" = "auto" && test "$subdirfailed" != "no"; then
system_llvm="MIA"
llvm_linking=""
fi

AM_CONDITIONAL([ENABLE_LLVM],
[test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"])
no_recursion="yes";
Expand Down Expand Up @@ -216,7 +221,11 @@ have_jit="no"
if test "$subdirfailed" = "no"; then
have_jit="yes"
fi
CL_MSG_STATUS([llvm ],[$have_jit, from $system_llvm],[$enable_llvm])
if test "x$llvm_linking" = "x"; then
CL_MSG_STATUS([llvm ],[$have_jit, from $system_llvm],[$enable_llvm])
else
CL_MSG_STATUS([llvm ],[$have_jit, from $system_llvm ($llvm_linking)],[$enable_llvm])
fi
CL_MSG_STATUS([mempool ],[$have_mempool],[$enable_mempool])

AC_MSG_NOTICE([Summary of engine detection features])
Expand Down
44 changes: 36 additions & 8 deletions libclamav/c++/configure.ac
Expand Up @@ -77,6 +77,26 @@ AC_ARG_WITH([system-llvm], AC_HELP_STRING([--with-system-llvm],
fi
])

llvm_linking=
AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking],
[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])],
[
if test "x$llvmconfig" = "x"; then
AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without valid llvm-config])
else
case "$withval" in
static)
llvm_linking="static"
;;
dynamic)
llvm_linking="dynamic"
;;
*)
AC_MSG_ERROR([Invalid argument to --with-llvm-linking])
esac
fi
], [])

AC_MSG_CHECKING([for supported LLVM version])
if test "x$llvmconfig" = "x"; then
dnl macro not available in older autotools
Expand Down Expand Up @@ -112,16 +132,24 @@ fi
dnl aquire the required flags to properly link in external LLVM
if test "x$llvmconfig" != "x"; then
AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`])
if test $llvmver_test -ge 350; then
dnl LLVM 3.5.0 and after splits linker flags into two sets
ldflags=`$llvmconfig --ldflags`
syslibs=`$llvmconfig --system-libs`
AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"])
else

if test "x$llvm_linking" = "xdynamic"; then
AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
AC_SUBST(LLVMCONFIG_LIBS, [-lLLVM-$llvmver])
AC_SUBST(LLVMCONFIG_LIBFILES, [])
else
if test $llvmver_test -ge 350; then
dnl LLVM 3.5.0 and after splits linker flags into two sets
ldflags=`$llvmconfig --ldflags`
syslibs=`$llvmconfig --system-libs`
AC_SUBST(LLVMCONFIG_LDFLAGS, ["$ldflags $syslibs"])
else
AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
fi
AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`])
AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`])
fi
AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`])
AC_SUBST(LLVMCONFIG_LIBFILES, [`$llvmconfig --libfiles jit nativecodegen scalaropts ipo`])

AC_MSG_NOTICE([CXXFLAGS from llvm-config: $LLVMCONFIG_CXXFLAGS])
AC_MSG_NOTICE([LDFLAGS from llvm-config: $LLVMCONFIG_LDFLAGS])
AC_MSG_NOTICE([LIBS from llvm-config: $LLVMCONFIG_LIBS])
Expand Down
26 changes: 26 additions & 0 deletions m4/reorganization/llvm.m4
Expand Up @@ -13,6 +13,31 @@ AC_ARG_WITH([system-llvm], [AC_HELP_STRING([--with-system-llvm],
esac
], [system_llvm="built-in"])

AC_ARG_WITH([llvm-linking], [AC_HELP_STRING([--with-llvm-linking],
[specifies method to linking llvm @<:@static|dynamic@:>@, only valid with --with-system-llvm])],
[
if test "x$system_llvm" = "xbuilt-in"; then
AC_MSG_ERROR([Failed to configure LLVM, and LLVM linking was specified without specifying system-llvm])
else
case "$withval" in
static)
llvm_linking="static"
;;
dynamic)
llvm_linking="dynamic"
;;
*)
AC_MSG_ERROR([Invalid argument to --with-llvm-linking])
esac
fi
], [
if test "x$system_llvm" = "xbuilt-in"; then
llvm_linking=""
else
llvm_linking="auto"
fi
])

AC_ARG_ENABLE([llvm],AC_HELP_STRING([--enable-llvm],
[enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
[enable_llvm=$enableval],
Expand All @@ -29,4 +54,5 @@ if test "$enable_llvm" != "no"; then
AC_CONFIG_SUBDIRS_OPTIONAL([libclamav/c++])
else
system_llvm="none"
llvm_linking=""
fi

0 comments on commit 08db174

Please sign in to comment.