Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 87420 - cairo-xlib.h from cairo-0.3.0 lacks C++ handling
Summary: cairo-xlib.h from cairo-0.3.0 lacks C++ handling
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Peter Johanson (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-31 07:18 UTC by Ewgenij Starostin
Modified: 2005-04-11 13:26 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Test programme. (cairo-xlib-test.cc,185 bytes, text/plain)
2005-03-31 07:24 UTC, Ewgenij Starostin
Details
Patch for cairo-xlib.h. (cairo-xlib.patch,621 bytes, patch)
2005-03-31 07:27 UTC, Ewgenij Starostin
Details | Diff
cairo-xlib.h patch (cairo-0.3.0-header-fix.diff,697 bytes, patch)
2005-04-08 17:38 UTC, Peter Johanson (RETIRED)
Details | Diff
Diff to the current 0.3.0-r1 cairo ebuild (cairo-0.3.0-r1.ebuild.diff,747 bytes, patch)
2005-04-08 17:39 UTC, Peter Johanson (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ewgenij Starostin 2005-03-31 07:18:58 UTC
If cairo-xlib.h is included in a C++ source file, the compiler will mangle its symbols. Since the symbols in libcairo.so aren't mangled (at least on my system), this causes problems.

In particular, mozilla-firefox failed to run because of that.

This problem has been addressed in cairo but (apparently) after version 0.3.0. Test programme and patch for 0.3.0 follow.

Reproducible: Always
Steps to Reproduce:
1. g++ -lcairo -I/usr/include/cairo -o cairo-xlib-test cairo-xlib-test.cc
Actual Results:  
/tmp/ccQD4VHq.o(.text+0x63): In function `main':
/home/estar/cairo-xlib-test.cc:8: undefined reference to
`cairo_set_target_drawable(_cairo*, _XDisplay*, unsigned long)'
collect2: ld returned 1 exit status

Expected Results:  
Test programme should have been linked.

$ g++ --version
g++ (GCC) 3.4.3-20050110 (Gentoo Hardened Linux 3.4.3.20050110-r1,
ssp-3.4.3.20050110-0, pie-8.7.7)
<snip>
$ qpkg -nc -q -v cairo | head -n 1
x11-libs/cairo-0.3.0-r1 *
$ pkg-config --modversion cairo
0.3.0
Comment 1 Ewgenij Starostin 2005-03-31 07:24:18 UTC
Created attachment 54931 [details]
Test programme.

Compile with -lcairo -I/usr/include/cairo.
Comment 2 Ewgenij Starostin 2005-03-31 07:27:14 UTC
Created attachment 54932 [details, diff]
Patch for cairo-xlib.h.

The problem has already been addressed in a similar way in cairo's CVS.
Comment 3 Peter Johanson (RETIRED) gentoo-dev 2005-04-07 16:01:35 UTC
Although I agree that this header definitely doesn't have the necessary foo to handle C++ stuff, Checking out the latest cairo CVS (http://cvs.cairographics.org/cairo/src/cairo-xlib.h) doesn't seem to have the fix you refer to.

As to mozilla-firefox, can you please post details of the failures you're having with it?

Comment 4 Olivier Castan 2005-04-08 01:16:26 UTC
(I'm not the orginal submitter but I had the problem on various archs both x86 and ppc)
Please look at http://cvs.cairographics.org/cairo/src/cairo-xlib.h?r1=1.6&r2=1.7
CAIRO_BEGIN_DECLS
CAIRO_END_DECLS

have been added and are defined in cairo.h as :

#ifdef  __cplusplus
# define CAIRO_BEGIN_DECLS  extern "C" {
# define CAIRO_END_DECLS    }
#else
# define CAIRO_BEGIN_DECLS
# define CAIRO_END_DECLS
#endif

To highlight the problem :
$ ldd -r /usr/lib/MozillaFirefox/components/libgklayout.so
[...]
undefined symbol: _Z25cairo_set_target_drawableP6_cairoP9_XDisplaym     (/usr/lib/MozillaFirefox/components/libgklayout.so)

$ readelf -s /usr/lib/libcairo.so.1.0.0 | grep drawable
   194: 000224e4   200 FUNC    GLOBAL DEFAULT    9 cairo_set_target_drawable

libcairo.so.1.0.0 functions names are standard C, but are C++ mangled in /usr/lib/MozillaFirefox/components/libgklayout.so

Because firefox was segfaulting in some configurations and if though it was related to hardened toolchain, I've put some more details in bug #83511
Comment 5 Ewgenij Starostin 2005-04-08 08:58:12 UTC
I was referring to the code posted by Olivier. The Firefox problem is
identical with his; for a description, see bug #86785 (in particular
http://bugs.gentoo.org/show_bug.cgi?id=86785#c8).
Comment 6 Peter Johanson (RETIRED) gentoo-dev 2005-04-08 17:38:29 UTC
Created attachment 55723 [details, diff]
cairo-xlib.h patch

Same patch to the header, just reformated slightly to be nicer to apply in the
ebuild.
Comment 7 Peter Johanson (RETIRED) gentoo-dev 2005-04-08 17:39:57 UTC
Created attachment 55724 [details, diff]
Diff to the current 0.3.0-r1 cairo ebuild

Here's a diff to the current 0.3.0-r1 ebuild to make it apply the cairo-xlib.h
patch. Apply this diff, and drop the cairo-xlib.h patch into the files/ dir,
and install it. Please report back if this fixes your mozilla-firefox problems.
If so, i'll get this commited as 0.3.0-r2 for people. Thanks.
Comment 8 Ewgenij Starostin 2005-04-08 21:04:45 UTC
Applied, dropped, installed, fixed. Thank you.
Comment 9 Peter Johanson (RETIRED) gentoo-dev 2005-04-11 13:26:41 UTC
Ok, i've just commited this as 0.3.0-r2. Thanks for the bug report. Marking FIXED.