1ff636
From 2d5ee8de927f69784d8380c24ca5505b3f6e7672 Mon Sep 17 00:00:00 2001
1ff636
From: systemd team <systemd-maint@redhat.com>
1ff636
Date: Tue, 14 Apr 2015 15:00:06 +0200
1ff636
Subject: [PATCH] build-sys: add configure option to disableLTO/gold
1ff636
1ff636
---
1ff636
 configure.ac | 15 ++++++++++-----
1ff636
 1 file changed, 10 insertions(+), 5 deletions(-)
1ff636
1ff636
diff --git a/configure.ac b/configure.ac
181b3f
index 081ed0f6e..9103f9b92 100644
1ff636
--- a/configure.ac
1ff636
+++ b/configure.ac
1ff636
@@ -208,10 +208,15 @@ AS_CASE([$CC], [*clang*],
1ff636
                -Wno-gnu-variable-sized-type-not-at-end \
1ff636
         ])])
1ff636
 
1ff636
-AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
1ff636
-        [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
1ff636
-               -flto -ffat-lto-objects])],
1ff636
-        [AC_MSG_RESULT([skipping -flto, optimization not enabled])])
1ff636
+AC_ARG_ENABLE([lto], AS_HELP_STRING([--disable-lto], [Disable Link time optimization]))
1ff636
+AS_IF([test "x$enable_lto" != "xno"], [
1ff636
+AS_CASE([$CFLAGS], [*-O[[12345\ ]]*], [
1ff636
+         CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-flto -ffat-lto-objects])
1ff636
+         CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS],[-Wl,-fuse-ld=gold])
1ff636
+         ],
1ff636
+[AC_MSG_RESULT([skipping -flto, optimization not enabled])])
1ff636
+])
1ff636
+
1ff636
 AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
1ff636
 
1ff636
 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
1ff636
@@ -227,7 +232,7 @@ CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
1ff636
         -Wl,-z,relro \
1ff636
         -Wl,-z,now \
1ff636
         -pie \
1ff636
-        -Wl,-fuse-ld=gold])
1ff636
+        ])
1ff636
 AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags")
1ff636
 
1ff636
 AC_CHECK_SIZEOF(pid_t)