]> arthur.barton.de Git - netdata.git/commitdiff
check if -flto can build executables before enabling it
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 11 Mar 2017 22:57:51 +0000 (00:57 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 11 Mar 2017 22:57:51 +0000 (00:57 +0200)
Makefile.am
configure.ac
m4/ax_c_lto.m4 [new file with mode: 0644]

index e78bbbbd5e69aee62a72df7034c14a3a68f6d073..3ccf82f8f5e8d76ab149749943df1feec8c7e64e 100644 (file)
@@ -23,8 +23,18 @@ EXTRA_DIST = \
        .eslintignore \
        .eslintrc \
        .travis \
-       m4/ax_check_enable_debug.m4 \
-       m4/ax_c_statement_expressions.m4 \
+       m4/jemalloc.m4 \
+    m4/ax_c___atomic.m4 \
+    m4/ax_check_enable_debug.m4 \
+    m4/ax_c_mallinfo.m4 \
+    m4/ax_gcc_func_attribute.m4 \
+    m4/ax_check_compile_flag.m4 \
+    m4/ax_c_statement_expressions.m4 \
+    m4/ax_pthread.m4 \
+    m4/ax_c_lto.m4 \
+    m4/ax_c_mallopt.m4 \
+    m4/tcmalloc.m4 \
+    m4/ax_c__generic.m4 \
        autogen.sh \
        README.md \
        LICENSE.md \
@@ -48,6 +58,8 @@ SUBDIRS = \
 dist_noinst_DATA= \
        diagrams/config.puml \
        diagrams/registry.puml \
+       diagrams/netdata-for-ephemeral-nodes.xml \
+       diagrams/netdata-proxies-example.xml \
        configs.signatures \
        Dockerfile \
        netdata.spec \
index f4d7e425cab7f631266443271ee7c653eb067e4c..3eeedc4a1c2b01708e22a0ddd37d01a323b6b4f7 100644 (file)
@@ -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])
@@ -410,6 +395,32 @@ AC_MSG_RESULT([${enable_plugin_nfacct}])
 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])
diff --git a/m4/ax_c_lto.m4 b/m4/ax_c_lto.m4
new file mode 100644 (file)
index 0000000..9455277
--- /dev/null
@@ -0,0 +1,21 @@
+# AC_C_LTO
+# -------------
+# Define HAVE_LTO if -flto works.
+AN_IDENTIFIER([lto], [AC_C_LTO])
+AC_DEFUN([AC_C_LTO],
+[AC_CACHE_CHECK([if -flto builds executables], ac_cv_c_lto,
+[AC_RUN_IFELSE(
+   [AC_LANG_SOURCE(
+      [[#include <stdio.h>
+        int main(int argc, char **argv) {
+          return 0;
+        }
+      ]])],
+   [ac_cv_c_lto=yes],
+   [ac_cv_c_lto=no],
+   [ac_cv_c_lto=no])])
+if test $ac_cv_c_lto = yes; then
+  AC_DEFINE([HAVE_LTO], 1,
+           [Define to 1 if -flto works.])
+fi
+])# AC_C_LTO