[ubuntu-uk] Colorzilla GCC-4 incompatibility (was: eyedropper replacement)

Paul Sladen ubuntu at paul.sladen.org
Thu Feb 8 03:16:57 GMT 2007


On Wed, 7 Feb 2007, David M wrote:

Hello David,

> Re: http://www.iosart.com/firefox/colorzilla/

(I've CC'ed Alex Sirota who is the developer of the 'ColorZilla' plugin).

> the eyedropper functionality would work once again, [with] libstdc++5

This package (the C++ standard library) provides support for programs
written in the C++ language and compiled with compiler version GCC-3.
This is already installed by default in Ubuntu/Kubuntu so the 'apt-get'
mentioned would not be necessary.

> [..and also by installing] the 'official' Firefox from Mozilla,

I've been to investigate.  I downloaded and unzipped the '.xpi' package for
'ColorZilla' and unzipped it.  Most of the browser interaction related code
is written in Javascript.

Also in the extension package is a library containing a small amount of
binary code.  This compiled (binary) code is non-portable and so there is a
separate version for several different operating systems ("platforms"):

  $ (cd components/ && file *dll*)
  ColorZilla.dll:          MS Windows (DLL) (GUI) Intel 80386 32-bit
  ColorZilla.dll.linux:    ELF 32-bit LSB shared object, Intel 80386, (SYSV)
  ColorZilla.dll.mac:      Mach-O bundle ppc
  ColorZilla.dll.macintel: Mach-O bundle i386

These four are platforms that the plugin is currently restricted to
(Win32/x86, Linux/x86, OSX/ppc, OSX/x86).

  $ ldd ColorZilla.dll.linux
  ...
  libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0xb7e3e000)

Inside the ".linux" library is the dependency on the old C++ library.
What has happened here is that the world (Ubuntu and Fedora being the two
examples noted) have moved onto building with GCC-4 and the new C++ ABI.

Since the offical Mozilla builds are still being built with the old GCC-3
version---that, is also what the binary-only part of ColorZilla is doing.

The long-term 'solution' is to also include a version of the small binary
library part compiled with GCC-4 and the new C++ ABI.  If I could find the
source code, then this would be as simple as doing a recompile.

Although I can't actually see it mentioned anyway, the plugin appears to be
binary-only.  So to get this done will need the help of the author, Alex
Sirota.  There two functions:

  iosartInstallPlatformLibraryIfNeeded()
  platformSpecificInstall()

currently do some quick detection and select which of the DLLs should be
loaded for the type of computer and operating system that the plugin is
running on.  Ideally these would be extended to also know about more CPU
types:

  linux/ppc
  linux/amd64

and about the old/new C++ ABI versions.  Since I couldn't find the source,
my next thought was wondering what the binary library is /actually doing/
and what function is might be performing.

  $ objdump -R -C -D ColorZilla.dll.linux | less -S

It turns out that for X-on-Linux, the binary library is doing the
following:

int mozColorZilla.GetPixel(int x, int y)
{
  Display *dpy;
  XImage *image;
  XColor col;

  dpy = XOpenDisplay(NULL);
  image = XGetImage(dpy, DefaultRootWindow(dpy),
                    x, y, 1, 1, AllPlanes, ZPixmap);
  col.pixel = XGetPixel(image, 0, 0);
  XDestroyImage(image);
  XQueryColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), &col);
  XCloseDisplay(dpy);
  return (col.red&0xff00)<<8 | (col.green)&0xff00 | (col.blue) >> 8;
}

(I guess that OSX and Win32 DLLs are doing their native equivalents).

Given the symplicity of the code, this could be moved to plain-C; which
would avoid the C++ versioning issues.  Moving the code to an interpretted
language would also solve the problem of having to further recompile the
plugin for ppc and amd64 processors aswell.

Alex: is the source-code available and/or would it be possible to move the
GetPixel() function to plain C and so neatly side-step the backwards
complatibility issue?

This would hopefully solve the issue for Ubuntu and Fedora users, and also
the rest of the distributions once their next releases come out.

David, does that help answer your query?

	-Paul
-- 
Why do one side of a triangle when you can do all three.   Southampton, GB





More information about the ubuntu-uk mailing list