summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-05-02 20:05:58 +0300
committerAndrei Karas <akaras@inbox.ru>2016-05-02 20:05:58 +0300
commit780c832477373bb86dc86900d820b7625455929a (patch)
tree0a40c088a1fbfb339b50124870b5c333435e9eae /configure.ac
parenta0a3f089429d10105c0b29122adacd29674ffba4 (diff)
downloadevol-hercules-780c832477373bb86dc86900d820b7625455929a.tar.gz
evol-hercules-780c832477373bb86dc86900d820b7625455929a.tar.bz2
evol-hercules-780c832477373bb86dc86900d820b7625455929a.tar.xz
evol-hercules-780c832477373bb86dc86900d820b7625455929a.zip
Add support for building plugin with lto.
Use lto by default.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac47
1 files changed, 47 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 5035edb..2fb99a4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,6 +94,25 @@ AC_ARG_ENABLE(
)
AM_CONDITIONAL(ENABLE_WERROR, test x$enable_werror = xyes)
+AC_ARG_ENABLE(
+ [lto],
+ AC_HELP_STRING(
+ [--enable-lto],
+ [
+ Enables or Disables Linktime Code Optimization (LTO is disabled by default)
+ ]
+ ),
+ [
+ enable_lto="$enableval"
+ case $enableval in
+ "no");;
+ "yes");;
+ *) AC_MSG_ERROR([[invalid argument --enable-lto=$enableval... stopping]]);;
+ esac
+ ],
+ [enable_lto="no"]
+)
+
OLD_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -rdynamic"
AC_MSG_CHECKING([whether $CC accepts -rdynamic])
@@ -151,6 +170,34 @@ AC_DEFUN([AC_CHECK_COMPILER_WFLAG],
]
)
+if test "$enable_lto" != "no" ; then
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -flto -ffat-lto-objects"
+
+ OLD_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -flto -ffat-lto-objects"
+
+ AC_MSG_CHECKING([whether $CC supports -flto])
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([
+ int main(int argc, char **argv){
+ return 0;
+ }
+ ])],
+ [
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$OLD_CFLAGS"
+ LDFLAGS="$OLD_LDFLAGS"
+ ],
+ [
+ AC_MSG_RESULT([guessing no])
+ ]
+ )
+fi
+
AC_DEFUN([AC_CHECK_SANITIZER_FLAG],
[
AC_MSG_CHECKING([whether $CC supports -fsanitize=$1])