[webkit-dev] exporting symbols for building .so/.dll's

Dirk Pranke dpranke at chromium.org
Fri Mar 9 13:52:10 PST 2012


On Thu, Mar 8, 2012 at 7:52 PM, Ami Fischman <fischman at chromium.org> wrote:
> Hi webkittens,
>
> The over-all question: how should webkit libraries declare which symbols
> they export?
> The trigger for the question: as described in bug 80062, the chromium
> shared-library-based build links test code into the (non-test) libwebkit.so
> target, which is terrible.
>
> The details:
> I took a crack at fixing the above bug (see patch in the bug) by pulling the
> test files out of the non-test build target, and sprinkling various
> {WTF,WEBKIT}_EXPORT{,DATA} macros around declarations that need them (as
> discovered by build-time and run-time failures).  This style of export
> declaration is what the webkit codebase does in various places
> (WTF, Platform, WebCore, and WebKit, AFAICT), and incidentally also what
> the chromium project uses for its sub-components.
> But I'm told other ports use different mechanisms such as .exp.in files for
> apple/mac (and maybe others for other ports? IDK).
>
> Is there consensus on the list for what the Right Thing To Do(tm) is?
> ISTM my options are:
> 1) Add EXPORT declarations as in the patch on the bug.
> 2) Drop the patch from the bug and replace it with chromium-specific
> .exp.in-style files, one per layer from which I need to export (WebCore,
> WTF, WebKit).  And build the build-time machinery to use them.  I don't
> really know what's involved here and would appreciate any pointers/hints
> people had if this is the way to go.
> 3) Something else (preferably unifying other ports' approaches).
>

I haven't really done much with the export macros in WebKit, but I
have had plenty of experience w/ this stuff in Chromium ...

As far as I know, if you take the EXPORT macro approach you should be
able to build everywhere; i.e., there's no platform I'm aware of that
requires .def / .exp files. If there was, I would hope that we could
generate those from the annotated source.

In addition, the EXPORT macros have the benefit (at least, I think
it's a benefit) of being in the source file, so it's one less place to
look and one less thing to keep in sync. I believe overall maintenance
is lowest this way.

So, my preference would be to use EXPORT macros.

I believe the fact that different ports carve up the components
differently can be addressed through the proper definition of the
macros (we do this in Chromium today, as you probably know).

The whole "this symbol only needs to be exported for testing purposes"
problem is somewhat orthogonal and I don't know of a good solution to
this; either you export more than you want, or you have to link test
code into the library, or your test build is different from your
release build :(.

-- Dirk


More information about the webkit-dev mailing list