Bug 139056

Summary: [jhBuild] cairo build error (-flto)
Product: WebKit Reporter: Fabien Vallée <fvallee>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: berto, clopez, commit-queue, gyuyoung.kim, ltilve, mrobinson, nick.diego
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Patch none

Description Fabien Vallée 2014-11-26 01:27:12 PST
Using jhbuild w/ GTK port (but EFL is very likely to have same issue).

Cairo fails to build on Debian Testing using binutils (2.24.90.20141023-1) :


using gnu-ld :

  CC     cairo-boilerplate-svg.lo
  CC     cairo-boilerplate-constructors.lo
/usr/bin/ld: -f may not be used without -shared
collect2: error: ld returned 1 exit status
Makefile:1468: recipe for target 'any2ppm' failed
make[4]: *** [any2ppm] Error 1
make[4]: *** Waiting for unfinished jobs....


using gold:

  CCLD   any2ppm
  CC     cairo-boilerplate-xcb.lo
  CC     cairo-boilerplate-egl.lo
  CC     cairo-boilerplate-glx.lo
  CC     cairo-boilerplate-script.lo
  CC     cairo-boilerplate-ps.lo
  CC     cairo-boilerplate-pdf.lo
  CC     cairo-boilerplate-svg.lo
  CC     cairo-boilerplate-constructors.lo
/usr/lib/gold-ld/ld: fatal error: -f/--auxiliary may not be used without -shared
collect2: error: ld returned 1 exit status
Makefile:1468: recipe for target 'any2ppm' failed
make[4]: *** [any2ppm] Error 1


After investigation, it seems the error is related to LTO support.
Cairo has been added some lto support here : 
http://cgit.freedesktop.org/cairo/commit/?id=d486ea30f1a58640a1178de74f705a73845b1cda

This commit is included in cairo package used by jhbuild (http://www.cairographics.org/news/cairo-1.12.8 for gtk or 1.12.4 for ELF).

The lto related commit has been amended here http://cgit.freedesktop.org/cairo/commit/?id=c3645d97ebd24c6f7ad850785d585aebc706a11c and even reverted here http://cgit.freedesktop.org/cairo/commit/?id=c7ff9bb32e20679d6da4e8a2856be716e5bd9e12, however we don't have theses commits.


Strange thing is that lto support is already supposed to be deactivated in cairo after http://trac.webkit.org/changeset/158866.
But it doesn't seems to work using gcc 4.9.1 / binutils 2.24.90.20141023-1.
Comment 1 Fabien Vallée 2014-11-26 01:43:20 PST
The issue can be fixed in Tools/gtk/jhbuild.modules updating the cairo section:

-  <autotools id="cairo" autogen-sh="configure"
-             autogenargs="--enable-gl=yes --enable-egl=yes --enable-glx=yes ac_cv_func_rsvg_pixbuf_from_file=no"
-             makeargs="CFLAGS=-fno-lto CXXFLAGS=-fno-lto LDFLAGS=-fno-lto">
+  <autotools id="cairo"
+             autogenargs="--enable-gl=yes --enable-egl=yes --enable-glx=yes ac_cv_func_rsvg_pixbuf_from_file=no --disable-lto"
+             makeargs="">
     <dependencies>
       <dep package="fontconfig"/>
       <dep package="pixman"/>
@@ -71,6 +71,7 @@
             repo="cairographics.org"
             hash="sha256:8fbb6fc66117ab4100bad830cb4479497e53c6f3facb98bf05c8d298554ebdd9"
             md5sum="8b3dcade859c44fb7e56fc68edfe9a45">
+      <patch file="cairo-1.12.8-add_disable-lto.patch" strip="1"/>
     </branch>
   </autotools>


1) apply cairo commit "configure.ac: Add a --disable-lto configure option"
http://cgit.freedesktop.org/cairo/commit/?id=c3645d97ebd24c6f7ad850785d585aebc706a11c

2) add the --disable-lto to autogenargs

3) remove makeargs (CFLAGS=-fno-lto CXXFLAGS=-fno-lto LDFLAGS=-fno-lto)

4) remove autogen-sh="configure" to force the updated configure.ac to be reparsed

I don't think the changes are good enough to be submitted as-is (but they are good enough to fix my build and are not breaking build w/ gcc 4.8.1 / ld 2.23.2).
Comment 2 Lorenzo Tilve 2014-11-26 09:46:51 PST
I can confirm that I have applied these changes and they are also repairing my build. I think that it would be a good idea to format them and submit the patch.
Comment 3 Fabien Vallée 2014-12-10 01:42:06 PST
Created attachment 243002 [details]
Patch
Comment 4 Fabien Vallée 2014-12-10 01:45:43 PST
uploaded patch "as-is", if anyone is willing to look at this issue, please feel free to review and/or amend and/or discard the patch and find another way to fix the build. Thanks.
Comment 5 Alberto Garcia 2014-12-10 05:59:31 PST
It works fine, thanks!
Comment 6 WebKit Commit Bot 2014-12-29 04:53:26 PST
Comment on attachment 243002 [details]
Patch

Clearing flags on attachment: 243002

Committed r177789: <http://trac.webkit.org/changeset/177789>
Comment 7 WebKit Commit Bot 2014-12-29 04:53:30 PST
All reviewed patches have been landed.  Closing bug.