[systemd-devel] [PATCH] Changing configure.ac to make LTO optional.

Kinsella, Ray ray.kinsella at intel.com
Mon Jul 20 07:56:16 PDT 2015


There is a bug in GCC LTO such that it ignores assembler directives.
This patch makes LTO enabled by default but also allows it to be disabled
if required.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47785

Ray Kinsella
---
 configure.ac | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 999f9f8..294c440 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,11 +194,18 @@ AS_CASE([$CC], [*clang*],
                -Wno-gnu-variable-sized-type-not-at-end \
         ])])
 
-AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
-        [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-               -flto -ffat-lto-objects])],
-        [AC_MSG_RESULT([skipping -flto, optimization not enabled])])
-AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
+AC_ARG_ENABLE(lto,
+        [AS_HELP_STRING([--enable-lto], [Enable link time optimization])],
+               enable_lto=$enableval,
+               enable_lto=yes; default_enable_lto=yes)
+
+if test "x$enable_lto" != "xno"; then
+        AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
+                [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
+                    -flto -ffat-lto-objects])],
+                [AC_MSG_RESULT([skipping -flto, optimization not enabled])])
+        AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
+fi
 
 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
         [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
-- 
2.1.0



More information about the systemd-devel mailing list