Bug 48489

Summary: Build fails with unreferenced _cairo_xlib_screen_put_gc error symbol
Product: cairo Reporter: mark
Component: xlib backendAssignee: Uli Schlachter <psychon>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: major    
Priority: medium    
Version: 1.12.0   
Hardware: SPARC   
OS: Solaris   
Whiteboard:
i915 platform: i915 features:

Description mark 2012-04-09 20:07:04 UTC
Recipe:

    setenv CC "cc"
    setenv CFLAGS "-L/usr/local/lib -I/usr/local/include"
    setenv CPPFLAGS "-I/usr/local/include"

    cd /var/tmp
    rm -rf /cairo cairo-1.12.0
    untgz /usr/local/src/graphics/cairo-1.12.0.tar.gz
    mkdir /cairo
    cd cairo-1.12.0
    ./configure --prefix=/cairo \
        --enable-xml \
        --enable-xlib-xcb \
        --disable-silent-rules
    gmake

Results in:
libtool: link: cc -G -z defs -h libcairo.so.2 -o .libs/libcairo.so.2.11200.0  .libs/cairo-analysis-surface.o .libs/cairo-arc.o .libs/cairo-array.o .libs/cairo-atomic.o .libs/cairo-base64-stream.o .libs/cairo-base85-stream.o .libs/cairo-bentley-ottmann.o .libs/cairo-bentley-ottmann-rectangular.o .libs/cairo-bentley-ottmann-rectilinear.o .libs/cairo-botor-scan-converter.o .libs/cairo-boxes.o .libs/cairo-boxes-intersect.o .libs/cairo.o .libs/cairo-cache.o .libs/cairo-clip.o .libs/cairo-clip-boxes.o .libs/cairo-clip-polygon.o .libs/cairo-clip-region.o .libs/cairo-clip-surface.o .libs/cairo-color.o .libs/cairo-composite-rectangles.o .libs/cairo-compositor.o .libs/cairo-contour.o .libs/cairo-damage.o .libs/cairo-debug.o .libs/cairo-default-context.o .libs/cairo-device.o .libs/cairo-error.o .libs/cairo-fallback-compositor.o .libs/cairo-fixed.o .libs/cairo-font-face.o .libs/cairo-font-face-twin.o .libs/cairo-font-face-twin-data.o .libs/cairo-font-options.o .libs/cairo-freelist.o .libs/cairo-freed-pool.o .libs/cairo-gstate.o .libs/cairo-hash.o .libs/cairo-hull.o .libs/cairo-image-compositor.o .libs/cairo-image-info.o .libs/cairo-image-source.o .libs/cairo-image-surface.o .libs/cairo-lzw.o .libs/cairo-matrix.o .libs/cairo-mask-compositor.o .libs/cairo-mesh-pattern-rasterizer.o .libs/cairo-misc.o .libs/cairo-mono-scan-converter.o .libs/cairo-mutex.o .libs/cairo-no-compositor.o .libs/cairo-observer.o .libs/cairo-output-stream.o .libs/cairo-paginated-surface.o .libs/cairo-path-bounds.o .libs/cairo-path.o .libs/cairo-path-fill.o .libs/cairo-path-fixed.o .libs/cairo-path-in-fill.o .libs/cairo-path-stroke.o .libs/cairo-path-stroke-boxes.o .libs/cairo-path-stroke-polygon.o .libs/cairo-path-stroke-tristrip.o .libs/cairo-pattern.o .libs/cairo-pen.o .libs/cairo-polygon.o .libs/cairo-polygon-intersect.o .libs/cairo-polygon-reduce.o .libs/cairo-raster-source-pattern.o .libs/cairo-recording-surface.o .libs/cairo-rectangle.o .libs/cairo-rectangular-scan-converter.o .libs/cairo-region.o .libs/cairo-rtree.o .libs/cairo-scaled-font.o .libs/cairo-shape-mask-compositor.o .libs/cairo-slope.o .libs/cairo-spans.o .libs/cairo-spans-compositor.o .libs/cairo-spline.o .libs/cairo-stroke-dash.o .libs/cairo-stroke-style.o .libs/cairo-surface.o .libs/cairo-surface-clipper.o .libs/cairo-surface-fallback.o .libs/cairo-surface-observer.o .libs/cairo-surface-offset.o .libs/cairo-surface-snapshot.o .libs/cairo-surface-subsurface.o .libs/cairo-surface-wrapper.o .libs/cairo-time.o .libs/cairo-tor-scan-converter.o .libs/cairo-tor22-scan-converter.o .libs/cairo-clip-tor-scan-converter.o .libs/cairo-toy-font-face.o .libs/cairo-traps.o .libs/cairo-tristrip.o .libs/cairo-traps-compositor.o .libs/cairo-unicode.o .libs/cairo-user-font.o .libs/cairo-version.o .libs/cairo-wideint.o .libs/cairo-cff-subset.o .libs/cairo-scaled-font-subsets.o .libs/cairo-truetype-subset.o .libs/cairo-type1-fallback.o .libs/cairo-type1-glyph-names.o .libs/cairo-type1-subset.o .libs/cairo-type3-glyph-surface.o .libs/cairo-pdf-operators.o .libs/cairo-pdf-shading.o .libs/cairo-deflate-stream.o .libs/cairo-xlib-display.o .libs/cairo-xlib-core-compositor.o .libs/cairo-xlib-fallback-compositor.o .libs/cairo-xlib-render-compositor.o .libs/cairo-xlib-screen.o .libs/cairo-xlib-source.o .libs/cairo-xlib-surface.o .libs/cairo-xlib-visual.o .libs/cairo-xlib-xcb-surface.o .libs/cairo-xcb-connection.o .libs/cairo-xcb-connection-core.o .libs/cairo-xcb-connection-render.o .libs/cairo-xcb-connection-shm.o .libs/cairo-xcb-screen.o .libs/cairo-xcb-shm.o .libs/cairo-xcb-surface.o .libs/cairo-xcb-surface-cairo.o .libs/cairo-xcb-surface-core.o .libs/cairo-xcb-surface-render.o .libs/cairo-png.o .libs/cairo-script-surface.o .libs/cairo-ft-font.o .libs/cairo-ps-surface.o .libs/cairo-pdf-surface.o .libs/cairo-svg-surface.o .libs/cairo-xml-surface.o   -R/usr/local/lib -R/usr/local/lib -L/usr/local/lib /usr/local/lib/libpixman-1.so /usr/local/lib/libfontconfig.so /usr/local/lib/libfreetype.so /usr/local/lib/libpng14.so -L/usr/local/lib/X11 /usr/local/lib/libxcb-shm.so /usr/local/lib/libX11-xcb.so /usr/local/lib/libxcb-render.so /usr/local/lib/libxcb.so /usr/local/lib/libXrender.so /usr/local/lib/libX11.so -lz -lrt -lm -lc   
Undefined                       first referenced
 symbol                             in file
_cairo_xlib_screen_put_gc           .libs/cairo-xlib-fallback-compositor.o  (symbol scope specifies local binding)
ld: fatal: symbol referencing errors. No output written to .libs/libcairo.so.2.11200.0
gmake[3]: *** [libcairo.la] Error 2
gmake[3]: Leaving directory `/var/tmp/cairo-1.12.0/src'

Cause:
Missing #if !CAIRO_HAS_XLIB_XCB_FUNCTIONS filter in src/cairo-xlib-fallback-compositor.c

Fix:
    /bin/perl -pe 'm%^#include% && ($. == 45) && s%^#include%#if \!CAIRO_HAS_XLIB_XCB_FUNCTIONS\n#include%' -i src/cairo-xlib-fallback-compositor.c
    echo "#endif" >> src/cairo-xlib-fallback-compositor.c
    gmake
Comment 1 Chris Wilson 2012-04-10 15:28:30 UTC
Uli, care to look at this? I know you've worked wonders with the convoluted set of ifdefs in the build system...
Comment 2 Uli Schlachter 2012-04-11 12:46:47 UTC
Wonders? Me?

Anyway, from a quick look at this, the proposed solution looks correct to me. I even managed to convince GCC to generate the same error message.

commit 07fc63676dfdaa57ed919ad7be8f59c97c615473
Author: Uli Schlachter <psychon@znc.in>
Date:   Wed Apr 11 21:37:55 2012 +0200

    xlib: Disable fallback compositor with xlib-xcb
    
    When xlib-xcb is enabled, this is just dead code which is never used. Thus, this
    shouldn't hurt. However, this does include cairo-xlib-private.h. Shouldn't be a
    problem? Well, that header contains static inline functions which some compiler
    on Solaris will emit even when they are unused.
    
    This brings us to the real problem: That static inline function refers to a
    function which isn't compiled with xlib-xcb and thus linking fails with
    undefined symbols.
    
    This can be reproduced with GCC by adding a call to
    _cairo_xlib_screen_put_gc(NULL, NULL, 0, 0); to
    _cairo_xlib_fallback_compositor_get.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=48489
    Signed-off-by: Uli Schlachter <psychon@znc.in>

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.