diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-03-12 00:57:51 +0200 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-03-12 00:57:51 +0200 |
commit | a2b6ad6782b46f97a092addfa082e19e11053a9b (patch) | |
tree | d34d773949a47c5629485ccbfd5c8b38cda34b05 /configure.ac | |
parent | 7b74c9aad41793211f2aefd0e33bdaaa5ac1bcf3 (diff) |
check if -flto can build executables before enabling it
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/configure.ac b/configure.ac index f4d7e425ca..3eeedc4a1c 100644 --- a/configure.ac +++ b/configure.ac @@ -256,21 +256,6 @@ if test "${SSE_CANDIDATE}" = "yes" -a "${enable_x86_sse}" = "yes"; then AX_CHECK_COMPILE_FLAG(${opt}, [CFLAGS="${CFLAGS} ${opt}"], []) fi -if test "${enable_lto}" != "no"; then - opt="-flto" - AX_CHECK_COMPILE_FLAG(${opt}, [have_lto=yes], [have_lto=no]) -fi -test "${enable_lto}" = "yes" -a "${have_lto}" != "yes" && \ - AC_MSG_ERROR([LTO is required but is not available.]) -AC_MSG_CHECKING([if LTO should be enabled]) -if test "${enable_lto}" != "no" -a "${have_lto}" = "yes"; then - enable_lto="yes" - CFLAGS="${CFLAGS} -flto" -else - enable_lto="no" -fi -AC_MSG_RESULT([${enable_lto}]) - if test "${GCC}" = "yes"; then AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization]) AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization]) @@ -411,6 +396,32 @@ AM_CONDITIONAL([ENABLE_PLUGIN_NFACCT], [test "${enable_plugin_nfacct}" = "yes"]) # ----------------------------------------------------------------------------- +# Link-Time-Optimization + +if test "${enable_lto}" != "no"; then + opt="-flto" + AX_CHECK_COMPILE_FLAG(${opt}, [have_lto=yes], [have_lto=no]) +fi +if test "${have_lto}" = "yes"; then + oCFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} -flto ${OPTIONAL_MATH_CLFAGS} ${OPTIONAL_NFACCT_CLFAGS} ${OPTIONAL_ZLIB_CLFAGS} ${OPTIONAL_UUID_CLFAGS} ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS}" + AC_C_LTO + CFLAGS="${oCFLAGS}" + test "${ac_cv_c_lto}" = "no" && have_lto="no" +fi +test "${enable_lto}" = "yes" -a "${have_lto}" != "yes" && \ + AC_MSG_ERROR([LTO is required but is not available.]) +AC_MSG_CHECKING([if LTO should be enabled]) +if test "${enable_lto}" != "no" -a "${have_lto}" = "yes"; then + enable_lto="yes" + CFLAGS="${CFLAGS} -flto" +else + enable_lto="no" +fi +AC_MSG_RESULT([${enable_lto}]) + + +# ----------------------------------------------------------------------------- AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged]) |