Enable link-time optimization.
authorMalte S. Stretz <mss@apache.org>
Tue, 14 Jun 2011 09:00:43 +0000 (11:00 +0200)
committerEmil Mikulic <emikulic@gmail.com>
Tue, 21 Jun 2011 12:22:28 +0000 (22:22 +1000)
Results in a 15% smaller (and probably quicker) binary.

configure.ac

index ce7e3e5..df12f16 100644 (file)
@@ -68,6 +68,20 @@ else
  CFLAGS="$save_cflags"
 fi
 
+AC_MSG_CHECKING(if your C compiler has a link-time optimizer)
+if test x$GCC = xyes; then
+ save_cflags="$CFLAGS"
+ CFLAGS="-flto $CFLAGS"
+ if (eval $ac_link) 2>/dev/null; then
+  AC_MSG_RESULT(sure does)
+ else
+  AC_MSG_RESULT(no)
+  CFLAGS="$save_cflags"
+ fi
+else
+ AC_MSG_RESULT(skipped)
+fi
+
 AC_ARG_ENABLE(mad-warnings, AS_HELP_STRING([--enable-mad-warnings],
  [turn on lots of compile-time warnings, this needs GCC and is only
  really useful for development]),