Package: contextfree Version: 3.0.5+dfsg1-2 Severity: serious Tags: upstream patch Justification: fails to build from source (but built successfully in the past)
contextfree fails to build on mips/mipsel/sparc and m68k/sh4 with the following error message: | cc -Wl,-z,relro objs/cfdg.o objs/Rand64.o objs/makeCFfilename.o objs/cfdgimpl.o objs/renderimpl.o objs/builder.o objs/shape.o objs/variation.o objs/countable.o objs/tempfile.o objs/aggCanvas.o objs/HSBColor.o objs/SVGCanvas.o objs/primShape.o objs/bounds.o objs/shapeSTL.o objs/tiledCanvas.o objs/astexpression.o objs/astreplacement.o objs/pathIterator.o objs/stacktype.o objs/CmdInfo.o objs/abstractPngCanvas.o objs/ast.o objs/ffCanvasDummy.o objs/pngCanvas.o objs/posixSystem.o objs/main.o objs/posixTimer.o objs/posixVersion.o objs/lex.yy.o objs/cfdg.tab.o objs/agg_trans_affine.o objs/agg_curves.o objs/agg_vcgen_contour.o objs/agg_vcgen_stroke.o objs/agg_bezier_arc.o objs/agg_color_rgba.o -Lsrc-ffmpeg/lib -L/usr/local/lib -lstdc++ -lpng -lm -fexceptions -o cfdg | objs/posixSystem.o: In function `PosixSystem::tempFileForWrite(std::string&)': | /«BUILDDIR»/contextfree-3.0.5+dfsg1/src-unix/posixSystem.cpp:126: warning: the use of `mktemp' is dangerous, better use `mkstemp' or `mkdtemp' | objs/astreplacement.o: In function `AST::ASTcompiledPath::NextPathUID()': | /«BUILDDIR»/contextfree-3.0.5+dfsg1/src-common/astreplacement.cpp:952: undefined reference to `__sync_fetch_and_add_8' | /«BUILDDIR»/contextfree-3.0.5+dfsg1/src-common/astreplacement.cpp:952: undefined reference to `__sync_fetch_and_add_8' | /«BUILDDIR»/contextfree-3.0.5+dfsg1/src-common/astreplacement.cpp:952: undefined reference to `__sync_fetch_and_add_8' | objs/CmdInfo.o: In function `AST::CommandInfo::tryInit(unsigned int, AST::ASTcompiledPath*, double, AST::ASTpathCommand const*)': | /«BUILDDIR»/contextfree-3.0.5+dfsg1/src-common/CmdInfo.cpp:61: undefined reference to `__sync_bool_compare_and_swap_8' | collect2: error: ld returned 1 exit status The problem is that the new version of contextfree try to uses 64-bit GCC legacy atomic builtins [1], which are not all available on all architectures. The solution to this problem is to use the new GCC atomics, similar to the C11 ones [2]. For that you need GCC 4.8, which is unfortunately not the default on all architectures, and to link with libatomic. The later library provides a fallback implementation if a given atomic bultin is not available natively, which is usually the case for 64-bit atomics on 32-bit platforms. The patch below implements that and should fix the problem, though I have only tested it on mips so far. --- contextfree-3.0.5+dfsg1/debian/control +++ contextfree-3.0.5+dfsg1/debian/control @@ -3,7 +3,7 @@ Priority: extra Maintainer: Bram Senders <b...@luon.net> Uploaders: Paul van Tilburg <pau...@debian.org> -Build-Depends: debhelper (>= 9), flex, bison, libpng-dev +Build-Depends: debhelper (>= 9), flex, bison, libpng-dev, g++-4.8 Standards-Version: 3.9.5 Homepage: http://contextfreeart.org/ --- contextfree-3.0.5+dfsg1/debian/patches/04-gcc-4.8-atomic.patch +++ contextfree-3.0.5+dfsg1/debian/patches/04-gcc-4.8-atomic.patch @@ -0,0 +1,36 @@ +--- a/Makefile ++++ b/Makefile +@@ -45,7 +45,7 @@ + AGG_SRCS = agg_trans_affine.cpp agg_curves.cpp agg_vcgen_contour.cpp \ + agg_vcgen_stroke.cpp agg_bezier_arc.cpp agg_color_rgba.cpp + +-LIBS = stdc++ png m ++LIBS = stdc++ png m atomic + + # + # FFmpeg support +--- a/src-common/CmdInfo.cpp ++++ b/src-common/CmdInfo.cpp +@@ -58,7 +58,10 @@ + (__int64)(std::numeric_limits<uint64_t>::max()), + (__int64)0) == (__int64)(std::numeric_limits<uint64_t>::max())) + #else +- if (__sync_bool_compare_and_swap(&mPathUID, std::numeric_limits<UIDtype>::max(), (UIDtype)0)) ++ const UIDtype expected = std::numeric_limits<UIDtype>::max(); ++ const UIDtype desired = 0; ++ if (__atomic_compare_exchange(&mPathUID, &expected, &desired, ++ false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + #endif + init(i, path, w, c); + } +--- a/src-common/astreplacement.cpp ++++ b/src-common/astreplacement.cpp +@@ -949,7 +949,7 @@ + return (uint64_t)next; + } while (true); + #else +- return __sync_fetch_and_add(&GlobalPathUID, (CommandInfo::UIDtype)1); ++ return __atomic_fetch_add (&GlobalPathUID, (CommandInfo::UIDtype)1, __ATOMIC_SEQ_CST); + #endif + } + --- contextfree-3.0.5+dfsg1/debian/patches/series +++ contextfree-3.0.5+dfsg1/debian/patches/series @@ -1,3 +1,4 @@ 01_disable_ffmpeg_support.patch 02_do_not_link_against_libz.patch 03_fix-arch-native.patch +04-gcc-4.8-atomic.patch --- contextfree-3.0.5+dfsg1/debian/rules +++ contextfree-3.0.5+dfsg1/debian/rules @@ -1,4 +1,8 @@ #!/usr/bin/make -f + +export CC=gcc-4.8 +export CXX=g++-4.8 + %: dh $@ [1] http://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html [2] http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html -- System Information: Debian Release: jessie/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: mips (mips64) Kernel: Linux 3.2.0-4-5kc-malta Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org