Bug 1698 - RFE: Minimize symbol table in DRI drivers
Summary: RFE: Minimize symbol table in DRI drivers
Status: RESOLVED FIXED
Alias: None
Product: DRI
Classification: Unclassified
Component: General (show other bugs)
Version: XOrg git
Hardware: x86 (IA32) All
: medium enhancement
Assignee: Default DRI bug account
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-23 15:48 UTC by Adam Jackson
Modified: 2005-01-05 01:42 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
dri-declare-exports-1.patch (1.36 KB, patch)
2004-10-25 18:13 UTC, Adam Jackson
no flags Details | Splinter Review

Description Adam Jackson 2004-10-23 15:48:40 UTC
gcc4 (and earlier versions if patched, including gentoo's gcc3.4 and probably
redhat's too) includes an -fvisibility flag, which allows the compiler to change
the assumed symbol visibility for entire objects at once.  traditional unix C
rules state that non-static symbols are exported from the DSO by default; this
usually means exporting many more symbols from the DSO than is strictly necessary.

The symbols that must be exported from the DRI driver should be explicitly
marked with __attribute__ ((visibility("default"))), so that the DRI drivers can
be built with -fvisibility=hidden and still work correctly.  Note that marking
functions this way does not change behaviour for compilers that lack the
-fvisibility flag.

Currently a typical DRI driver exports ~1200 symbols, with ~100 of these defined
by the driver and the rest by the Mesa core.  This can be reduced to 2 or 3 with
no loss in functionality.  In addition to improving symbol resolution
performance, the compiler can generate (marginally) better code when it knows
that a symbol can't be referred to externally.  As an example, r200_dri.so drops
about 70k of text from the driver binary when built with a minimal export list.
 Other drivers show similar improvements.
Comment 1 Adam Jackson 2004-10-25 18:13:41 UTC
Created attachment 1166 [details] [review]
dri-declare-exports-1.patch

this patch defines the magic word DRIEXPORT to tag the symbols the DRI driver
must export.  gcc supports the visibility attribute in version 3.3 and later,
so in that situation we define DRIEXPORT to mean default visibility.  With this
patch, users with compilers that support the -fvisibility flag can add it to
their CFLAGS to get a DRI driver with a minimal exported symbol table.
Comment 2 Brian Paul 2004-10-26 07:32:57 UTC
For Mesa, I was thinking of defining a "PUBLIC" macro in glheader.h for the
visibility attribute.  Could you use that in the DRI drivers too?

On the other hand, if DRIEXPORT is defined in dri_interface.h, that would be
available to DRI drivers not based on Mesa, right?
Comment 3 Adam Jackson 2004-10-26 16:41:36 UTC
(In reply to comment #2)
> For Mesa, I was thinking of defining a "PUBLIC" macro in glheader.h for the
> visibility attribute.  Could you use that in the DRI drivers too?
> 
> On the other hand, if DRIEXPORT is defined in dri_interface.h, that would be
> available to DRI drivers not based on Mesa, right?

do both then?  DRIEXPORT to mark symbols the driver exports, and PUBLIC to mark
what libGL exports.
Comment 4 Adam Jackson 2005-01-05 20:42:47 UTC
fixed in CVS since a while ago, closing.


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.