summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-02-10 11:28:01 +0100
committerThomas Haller <thaller@redhat.com>2017-02-10 12:11:21 +0100
commita981c6c355f752a7866222d2a2629445b232d8c2 (patch)
treeb42a351115a18c12253623fafcc2ca0802ea80e5 /m4
parent8bc88bcc7cc6e60abfabacd00591e01aaab9eac3 (diff)
downloadNetworkManager-a981c6c355f752a7866222d2a2629445b232d8c2.tar.gz
build: add m4 macros for --enable-lto and --enable-ld-gc
Diffstat (limited to 'm4')
-rw-r--r--m4/compiler_options.m427
1 files changed, 27 insertions, 0 deletions
diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4
index c998711d72..fa35b91681 100644
--- a/m4/compiler_options.m4
+++ b/m4/compiler_options.m4
@@ -124,3 +124,30 @@ else
AC_MSG_RESULT(no)
fi
])
+
+AC_DEFUN([NM_LTO],
+[AC_ARG_ENABLE(lto, AS_HELP_STRING([--enable-lto], [Enable Link Time Optimization for smaller size (default: no)]))
+if (test "${enable_lto}" = "yes"); then
+ CFLAGS="-flto $CFLAGS"
+else
+ enable_lto='no'
+fi
+])
+
+AC_DEFUN([NM_LD_GC],
+[AC_ARG_ENABLE(ld-gc, AS_HELP_STRING([--enable-ld-gc], [Enable garbage collection of unused symbols on linking (default: auto)]))
+if (test "${enable_ld_gc}" != "no"); then
+ CC_CHECK_FLAG_APPEND([ld_gc_flags], [CFLAGS], [-fdata-sections -ffunction-sections -Wl,--gc-sections])
+ if (test -n "${ld_gc_flags}"); then
+ enable_ld_gc="yes"
+ CFLAGS="$CFLAGS $ld_gc_flags"
+ else
+ if (test "${enable_ld_gc}" = "yes"); then
+ AC_MSG_ERROR([Unused symbol eviction requested but not supported.])
+ else
+ enable_ld_gc="no"
+ fi
+ fi
+fi
+])
+