diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-05-02 20:05:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-05-02 20:05:58 +0300 |
commit | 780c832477373bb86dc86900d820b7625455929a (patch) | |
tree | 0a40c088a1fbfb339b50124870b5c333435e9eae | |
parent | a0a3f089429d10105c0b29122adacd29674ffba4 (diff) | |
download | evol-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.
-rwxr-xr-x | build.sh | 2 | ||||
-rw-r--r-- | configure.ac | 47 |
2 files changed, 48 insertions, 1 deletions
@@ -13,7 +13,7 @@ autoreconf -i cd build if [[ "${CMD}" == "default" ]]; then export CC=gcc - ../configure --enable-sanitize + ../configure --enable-sanitize --enable-lto elif [[ "${CMD}" == "old" ]]; then ../configure elif [[ "${CMD}" == "gprof" ]]; then 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]) |