Bug 59038

Summary: cairo-1.12 fails to build with gold due to underlinking
Product: cairo Reporter: Chí-Thanh Christopher Nguyễn <chithanh>
Component: qt backendAssignee: cairo-bugs mailing list <cairo-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: nikoli
Version: 1.12.8Keywords: regression
Hardware: Other   
OS: All   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=429580
Whiteboard:
i915 platform: i915 features:
Attachments: full build log
cairo-1.10 build log

Description Chí-Thanh Christopher Nguyễn 2013-01-04 22:38:28 UTC
Created attachment 72525 [details]
full build log

Starting with cairo-1.12 (cairo-1.10 builds fine) the build fails on Gentoo with ld.gold selected as the default linker:

  CCLD   cairo-sphinx
/var/tmp/portage/x11-libs/cairo-1.12.8/work/cairo-1.12.8/src/.libs/libcairo.so: error: undefined reference to '__gxx_personality_v0'
/var/tmp/portage/x11-libs/cairo-1.12.8/work/cairo-1.12.8/src/.libs/libcairo.so: error: undefined reference to '__cxa_begin_catch'
/var/tmp/portage/x11-libs/cairo-1.12.8/work/cairo-1.12.8/src/.libs/libcairo.so: error: undefined reference to '__cxa_end_catch'
/var/tmp/portage/x11-libs/cairo-1.12.8/work/cairo-1.12.8/src/.libs/libcairo.so: error: undefined reference to '__cxa_rethrow'
/var/tmp/portage/x11-libs/cairo-1.12.8/work/cairo-1.12.8/src/.libs/libcairo.so: error: undefined reference to 'std::terminate()'
/var/tmp/portage/x11-libs/cairo-1.12.8/work/cairo-1.12.8/src/.libs/libcairo.so: error: undefined reference to 'typeinfo for std::bad_alloc'
/var/tmp/portage/x11-libs/cairo-1.12.8/temp/cc5T4JaP.ltrans5.ltrans.o:cc5T4JaP.ltrans5.o:function _cairo_boilerplate_qt_create_surface(char const*, _cairo_content, double, double, double, double, cairo_boilerplate_mode_t, void**) [clone .3247]: error: undefined reference to 'operator new(unsigned long)'
/var/tmp/portage/x11-libs/cairo-1.12.8/temp/cc5T4JaP.ltrans5.ltrans.o:cc5T4JaP.ltrans5.o:function _cairo_boilerplate_qt_create_surface(char const*, _cairo_content, double, double, double, double, cairo_boilerplate_mode_t, void**) [clone .3247]: error: undefined reference to 'operator delete(void*)'
collect2: ld returned 1 exit status
Comment 1 Uli Schlachter 2013-01-06 11:25:43 UTC
Are you sure that this really, really, *really* is a regression? I can't see anything that changed in cairo in this regard.

Also, this problem is specific to the qt backend which is the only(?) C++ code in cairo. This backend is so experimental that it is not even listed as an experimental backend.
Comment 2 Chí-Thanh Christopher Nguyễn 2013-01-06 12:03:05 UTC
Created attachment 72584 [details]
cairo-1.10 build log

Indeed the build error goes away after disabling the qt backend.

But cairo-1.10 built fine with gold and qt enabled (see attached log).
Comment 3 Bryce Harrington 2014-07-08 22:53:21 UTC
We also have a skia backend which is C++, but that's probably even more experimental than the qt backend.  :-)

Looks like the beos also needs C++, fwiw.

Fwiw, `./configure --enable-qt` appears to result in a successful build on Ubuntu 12.04.  But on Ubuntu 14.04 (gcc 4.8) using libqt4-dev, I see this error:

  CCLD     cairo-test-suite
/usr/bin/ld: ../boilerplate/.libs/libcairoboilerplate.a(libcairoboilerplate_cxx_la-cairo-boilerplate-qt.o): undefined reference to symbol '__gxx_personality_v0@@CXXABI_1.3'
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[4]: *** [cairo-test-suite] Error 1

This is just saying that the library wasn't included in the linker command line.  So it needs -lstdc++ added someplace, at a minimum.  Almost certainly the cause of the originally reported problem.

I've drummed up a patch that adds -lstdc++ and -lQtGui when --enable-qt is given, which seems to result in a successful build on 14.04 for me.
Comment 4 Bryce Harrington 2014-07-10 23:25:20 UTC
commit b384e86c6a2b15d26908ede73cb29098afe5e809
Author: Bryce Harrington <b.harrington@samsung.com>
Date:   Tue Jul 8 15:53:41 2014 -0700

    configure.ac: Fix broken build for Qt backend

    When --enable-qt is specified, the build will break due to missing
    libstdc++:

      CCLD     cairo-test-suite
    /usr/bin/ld: ../boilerplate/.libs/libcairoboilerplate.a(libcairoboilerplate_cxx_la-cairo-boilerplate-qt.o): undefined reference to symbol '__gxx_personality_v0@@CX$
    //usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status

    When using g++ to compile and link code, g++ automatically links
    libstdc++.  However, in cairo we're using g++ only to compile, so need
    to explicitly link against libstdc++ for backends that need iostream,
    stl, or other stdc++ features.

    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=59038
    Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
    Reviewed-by: Uli Schlachter <psychon@znc.in>
Comment 5 Chí-Thanh Christopher Nguyễn 2014-07-11 14:52:15 UTC
This commit appears to have not yet reached cairo git yet.

Also, I think -lm is also needed besides -lstdc++ for linking with ld.gold, but I will check once the fix is available.
Comment 6 Bryce Harrington 2014-07-12 01:35:35 UTC
Sorry, pushed

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.