Closed Bug 290835 Opened 20 years ago Closed 20 years ago

cairo linkage problems

Categories

(Firefox Build System :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: tor, Assigned: roc)

References

Details

Attachments

(2 files, 4 obsolete files)

We're about to get into a situation where both mozilla's SVG and canvas support
require cairo.  SVG currently links cairo into a component which is always a
seperate library, so that if appropriate versions of freetype/fontconfig are
missing the component can fail and mozilla will still run.

canvas takes the approach of linking cairo directly to gklayout, so any failure
to load the cairo library will cause mozilla to fail to start.

Additionally, with the patch in bug 290518 we're going to linking cairo
statically into both the svg renderer component and gklayout, which is a waste.

Are we willing to assume that freetype/fontconfig are around, in which case we
can link the svg renderer into gklayout?  Or does canvas need to be reengineered
to be in a seperate component or dynamically load cairo?
Flags: blocking1.8b2+
I think we need to just depend on freetype and fontconfig always being around,
although that may mean updating our lowest supported system config (redhat8
currently?)

More and more libraries in Mozilla are going to start depending on cairo
directly or indirectly so trying to move things in to seperate libraries isn't
going to work for long.
RH8's Xrender isn't enough to deal with cairo - there's a patch in bug 286422 to
add that library to the tree (about 20k of code), if we keep that as the base
configuration.

What's the story on win32? Are we using cairo there, which (I presume) has a DLL
dependency on GDI+?
For SVG on win32 we use gdi+ directly, with a shim component checking for the
library before pulling in the renderer code.

Cairo doesn't use gdi+ on win32, so canvas doesn't have that dependency.
Doesn't our GTK2+XFT build require fontconfig already?

If we really want a build that fails gracefully when fontconfig and freetype
aren't around, maybe we could hack cairo-ft-font.c since it seems to be the only
module that uses those libraries.  In fact, that module has very few extern
functions, so we could probably turn that module into a shim DSO if needed. 
But, it seems to me that we could probably just require those libraries and be
done with it.
Since we're turning on <canvas> and linking cairo directly into gklayout, do
the same for the svg cairo renderer so we don't end up carrying around two
copies of the cairo code.
Attachment #181282 - Flags: review?(benjamin)
*** Bug 291086 has been marked as a duplicate of this bug. ***
I talked this through with tor on IRC and we don't want to statically link Cairo
into layout after all, because gfx/src/cairo needs it and we don't want two
copies. So we want something like my patch in bug 291086 to make gklayout link
with -lmozcairo.
This patch works for me. Canvas and SVG both work, and they're both dynamically
linking to libmozcairo.so.
Assignee: nobody → roc
Status: NEW → ASSIGNED
Attachment #181366 - Flags: superreview?(tor)
Attachment #181366 - Flags: review?(bryner)
tor did mention that we might need to do something to make this work with static
builds. I haven't tested that.
Attached patch safer fix (obsolete) — Splinter Review
Perhaps this fix is safer ... force Cairo to be a shared lib so that we know
the dynamic gksvgcairo can get to it. Pick one of these patches :-)
Attachment #181366 - Attachment is obsolete: true
Attachment #181367 - Flags: superreview?(tor)
Attachment #181367 - Flags: review?(bryner)
Since we're building cairo ourself, gksvgcairo doesn't need to be dynamic. In a
static build these should all be statically linked.
Attached patch uber-fix (obsolete) — Splinter Review
This patch merges the other patches together so that
-- the Cairo SVG renderer is no longer a component. It is statically linked
into gklayout when enabled.
-- libmozcairo and libmozpixman are treated like other gfx libraries ... they
are dynamic libraries in nonstatic builds, and static libraries in static
builds.
Attachment #181282 - Attachment is obsolete: true
Attachment #181367 - Attachment is obsolete: true
Attachment #181372 - Flags: superreview?(tor)
Attachment #181372 - Flags: review?(bryner)
Attachment #181366 - Flags: superreview?(tor)
Attachment #181366 - Flags: review?(bryner)
Attachment #181367 - Flags: superreview?(tor)
Attachment #181367 - Flags: review?(bryner)
Attached patch uber-fix #2 (obsolete) — Splinter Review
Add MOZ_CAIRO_LIBS if either MOZ_ENABLE_CAIRO or MOZ_SVG_RENDERER_CAIRO.

(MOZ_ENABLE_CAIRO is misleading ... either it should be renamed
MOZ_ENABLE_CANVAS, or it should be set when MOZ_SVG_RENDERER_CAIRO is
selected.)
Attachment #181372 - Attachment is obsolete: true
Attachment #181372 - Flags: superreview?(tor)
Attachment #181372 - Flags: review?(bryner)
Attached patch uber-fix #3Splinter Review
all of the above, plus links libpixman statically into libmozcairo.so.
Attachment #181373 - Attachment is obsolete: true
Unfortunately this approach doesn't work because cairo.h doesn't have any
"export" annotations, so on gcc with visibility pragmas, and presumably on
Windows, the public API functions don't get exported in the shared library.

So for now I think we just have to go with tor's original fix. That means
regular 1.8 builds will have just one copy of Cairo, statically linked into
gklayout. cairo-gtk2 builds will have two copies of Cairo, but that's acceptable
because they're experimental for the forseeable future. (Here's hoping Cairo
doesn't have any global state!) Post-1.8 we'll need to revisit this situation.
Probably we should push the Cairo people to have export annotations on their
public APIs. I will send email to the list.
You should be thinking about making this optimal in the case of a static firefox
build or in the case of a xulrunner libxul build (one big honking DLL).  The
multi-DLL build is really a thing of the past.  Making that efficient should be
low priority.
Attachment #181282 - Attachment is obsolete: false
Attachment #181282 - Flags: review?(benjamin)
It appears that Cairo does have some global state (global shared caches), so
it's not just a question of efficiency, it's also going to be necessary if
multi-DLL builds are going to work at all without exploding in surprising ways.
My machine may be studly enough to handle building XULRunner debug every time I
make a change during development, but that may not be true for everyone.
Sorry if that last comment was a bit testy. It's been a frustrating afternoon.
Darin was no doubt excluding developer builds in putting emphasis on static
builds ;-).

Why don't we make a deal to do the macro-ized declspec decoration of cairo.h,
and contribute it?

/be
I've sent mail to the cairo list asking if they'd be interested in such a patch.
i totally agree that multi-DLL developer builds should work.  i just meant that
if we have to have two copies of cairo in the developer build, then so be it.
but, i guess that's totally a moot point now ;-)

we need to support a multi-DLL, developer friendly build for xulrunner or else
it won't be any fun for people developing gecko in the new world of libxul.
Comment on attachment 181282 [details] [diff] [review]
link cairo svg renderer into gklayout

I'm assuming this patch is obsolete by now?
Attachment #181282 - Flags: review?(benjamin)
Comment on attachment 181282 [details] [diff] [review]
link cairo svg renderer into gklayout

No, this is the patch that roc and I found to be the best way forwards at this
point.	See comment 16.

It's post bryner's cairo landing, if that's what you were thinking of.
Attachment #181282 - Flags: review?(benjamin)
Comment on attachment 181282 [details] [diff] [review]
link cairo svg renderer into gklayout

layout/svg/renderer/src/cairo/Makefile.in
Please change MOZILLA_INTERNAL_API to LIBXUL_LIBRARY
Attachment #181282 - Flags: review?(benjamin) → review+
Comment on attachment 181282 [details] [diff] [review]
link cairo svg renderer into gklayout

Allows us to build with both canvas and svg, stops us from carrying around two
copies of the cairo code in builds.
Attachment #181282 - Flags: approval1.8b2?
Comment on attachment 181282 [details] [diff] [review]
link cairo svg renderer into gklayout

a=chofmann
Attachment #181282 - Flags: approval1.8b2? → approval1.8b2+
Checked in with LIBXUL_LIBRARY.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: