Bug 79606

Summary: Accommodate gcc-4.9.0 link-time optimization (LTO) changes
Product: systemd Reporter: jpsinthemix
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: minor    
Priority: medium    
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description jpsinthemix 2014-06-03 20:36:57 UTC
Hi,

Systemd-213 fails to build (symbols not found/resolved during cgls link step) under gcc-4.9.0 due to link-time optimization (lto) changes, in particular from gcc-4.9.0/NEWS:

          + When using a linker plugin, compiling with the -flto option
            now generates slim objects files (.o) which only contain
            intermediate language representation for LTO. Use
            -ffat-lto-objects to create files which contain additionally
            the object code. To generate static libraries suitable for LTO
            processing, use gcc-ar and gcc-ranlib; to list symbols from a
            slim object file use gcc-nm. (Requires that ar, ranlib and nm
            have been compiled with plugin support.)

Both -flto and -ffat-lto-objects are now needed when building and linking against static libs w/LTO. As a quick fix, I simply added the -ffat-lto-objects flag to configure

--- systemd-213.old/configure   2014-05-28 02:49:44.026507777 -0400
+++ systemd-213.new/configure   2014-05-31 18:58:26.079036215 -0400
@@ -14970,7 +14970,7 @@ case $CFLAGS in #(
   *-O[12345\ ]*) :

   for flag in \
-               -flto; do
+               -flto -ffat-lto-objects; do

   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports flag $flag in envvar CFLAGS" >&5
 $as_echo_n "checking if $CC supports flag $flag in envvar CFLAGS... " >&6; }
-----------

--- systemd-213.old/configure.ac        2014-05-28 02:49:22.979663817 -0400
+++ systemd-213.new/configure.ac        2014-06-03 16:32:42.752442525 -0400
@@ -180,7 +180,7 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CF
         --param=ssp-buffer-size=4])
 AS_CASE([$CFLAGS], [*-O[[12345\ ]]*],
         [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-               -flto])],
+               -flto -ffat-lto-objects])],
         [AC_MSG_RESULT([skipping -flto, optimization not enabled])])
 AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
-----------

thanks much for the great software,
John

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.