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.
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.
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?
(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.
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.