[Xcb] hidden-visibility and library size
Vincent Torri
Vincent.Torri at iecn.u-nancy.fr
Tue Dec 27 15:14:46 PST 2005
On Tue, 27 Dec 2005, Jamey Sharp wrote:
> On Tue, Dec 27, 2005 at 09:26:18PM +0100, Vincent Torri wrote:
> > There are the acinclude.m4 file and a diff of configure.ac attached
> > $(VISIBILITY_CFLAGS) must be added in src/Makefile.am of course
>
> Nothing seems to be attached. I would like to see the changes though.
oups :) i've forgotten to attach them :) Here they are.
> Would you ensure that you've made all the necessary changes and that XCB
> still builds and works (and passes its test suite?) -- and then run
> cvs add acinclude.m4
> and post just the output of `cvs diff -Nu`?
xcb builds fine, but i've not verified the test suite.
Of course, we need to specify all the exported functions. There's an
example in xcb.h.diff.
> > Maybe we can modify it so that your modifications are taken into
> > account.
>
> I can merge my changes after we've got the hidden visibility stuff
> committed, if you want. Or I can just commit and you can merge. Let me
> know which way you'd like to go.
verify my changes before. They work here, but maybe i've mised something
>
> > On Tue, 27 Dec 2005, Jamey Sharp wrote:
> > > Interesting statistics: compiling --with-opt=small saves 15kB (59.6kB
> > > total) over --with-opt (73.4kB total) and --without-opt (74.1kB).
> >
> > I also guess that adding -s during linking should decrease even more the
> > library size (libXCB_la_LDFLAGS = -s in src/Makefile.am). I've not tried
> > it, i've just used strip on the library directly.
>
> Won't make any difference on the numbers I'm quoting though, since I'm
> just measuring the size of the text, data, and bss segments.
>
> Since you can just run strip after compiling, or set LDFLAGS in the
> environment, I'm not inclined to add anything to configure or the
> Makefiles to run it automatically.
ok
> > i also think that we must be sure that, if debugging is set, only the
> > warning flags and -g must be passed to gcc during compilation and -s not
> > be passed during linking.
>
> I don't think I want that. If you give an odd combination of
> optimization and debugging flags, you probably know what you're doing.
> For example, I frequently build XCB with both -O3 and -g, which is a
> pretty reasonable thing to do.
i'm not sure of that. I've once tried to debug with -g -O2 a lib (evas,
iirc) and gdb has given me odd values when i used bt f
my point of view is : when i debug my code, i don't want to debug the
compiler optimizations. that's why I prefer to use only -g.
Vincent
-------------- next part --------------
--- xcb.h.~1.8.~ 2005-12-08 08:15:12.000000000 +0100
+++ xcb.h 2005-12-27 22:05:05.130837960 +0100
@@ -42,6 +42,16 @@
#define deprecated
#endif
+#ifdef XCBAPI
+#undef XCBAPI
+#endif
+#ifdef HAVE_VISIBILITY_FEATURE
+# define XCBAPI __attribute__ ((visibility("default")))
+#else
+# define XCBAPI
+#endif
+
+
/* Pre-defined constants */
/* current protocol version */
@@ -107,21 +117,21 @@
char *data;
} XCBAuthInfo;
-int XCBGetAuthInfo(int fd, XCBAuthInfo *info) deprecated;
+XCBAPI int XCBGetAuthInfo(int fd, XCBAuthInfo *info) deprecated;
/* xcb_out.c */
-int XCBFlush(XCBConnection *c);
-CARD32 XCBGetMaximumRequestLength(XCBConnection *c);
+XCBAPI int XCBFlush(XCBConnection *c);
+XCBAPI CARD32 XCBGetMaximumRequestLength(XCBConnection *c);
/* xcb_in.c */
-XCBGenericEvent *XCBWaitEvent(XCBConnection *c) deprecated;
-XCBGenericEvent *XCBWaitForEvent(XCBConnection *c);
-XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error);
-unsigned int XCBGetRequestRead(XCBConnection *c);
+XCBAPI XCBGenericEvent *XCBWaitEvent(XCBConnection *c) deprecated;
+XCBAPI XCBGenericEvent *XCBWaitForEvent(XCBConnection *c);
+XCBAPI XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error);
+XCBAPI unsigned int XCBGetRequestRead(XCBConnection *c);
/* xcb_ext.c */
@@ -130,32 +140,32 @@
/* Do not free the returned XCBQueryExtensionRep - on return, it's aliased
* from the cache. */
-const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext);
+XCBAPI const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext);
-void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext);
+XCBAPI void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext);
/* xcb_conn.c */
-XCBConnSetupSuccessRep *XCBGetSetup(XCBConnection *c);
-int XCBGetFileDescriptor(XCBConnection *c);
+XCBAPI XCBConnSetupSuccessRep *XCBGetSetup(XCBConnection *c);
+XCBAPI int XCBGetFileDescriptor(XCBConnection *c);
-XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info);
-void XCBDisconnect(XCBConnection *c);
+XCBAPI XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info);
+XCBAPI void XCBDisconnect(XCBConnection *c);
/* xcb_util.c */
-int XCBParseDisplay(const char *name, char **host, int *display, int *screen);
-int XCBOpen(const char *host, int display) deprecated;
-int XCBOpenTCP(const char *host, unsigned short port) deprecated;
-int XCBOpenUnix(const char *file) deprecated;
-
-XCBConnection *XCBConnectBasic(void) deprecated;
-XCBConnection *XCBConnect(const char *displayname, int *screenp);
-XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *display, XCBAuthInfo *auth, int *screen);
+XCBAPI int XCBParseDisplay(const char *name, char **host, int *display, int *screen);
+XCBAPI int XCBOpen(const char *host, int display) deprecated;
+XCBAPI int XCBOpenTCP(const char *host, unsigned short port) deprecated;
+XCBAPI int XCBOpenUnix(const char *file) deprecated;
+
+XCBAPI XCBConnection *XCBConnectBasic(void) deprecated;
+XCBAPI XCBConnection *XCBConnect(const char *displayname, int *screenp);
+XCBAPI XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *display, XCBAuthInfo *auth, int *screen);
-int XCBSync(XCBConnection *c, XCBGenericError **e);
+XCBAPI int XCBSync(XCBConnection *c, XCBGenericError **e);
#ifdef __cplusplus
-------------- next part --------------
--- Makefile.am.~1.26.~ 2005-12-24 14:59:59.000000000 +0100
+++ Makefile.am 2005-12-27 22:09:59.053154976 +0100
@@ -41,8 +41,9 @@
xcbinclude_HEADERS = xcb.h xcbext.h xcbxlib.h $(COREHEADERS) $(EXTHEADERS)
CFLAGS =
-AM_CFLAGS = -include config.h $(CDEBUGFLAGS) $(XCBPROTO_CFLAGS) $(XPROTO_CFLAGS) $(XAU_CFLAGS)
+AM_CFLAGS = -include config.h $(CDEBUGFLAGS) $(VISIBILITY_CFLAGS) $(XCBPROTO_CFLAGS) $(XPROTO_CFLAGS) $(XAU_CFLAGS)
libXCB_la_LIBADD = $(XCBPROTO_LIBS) $(XPROTO_LIBS) $(XAU_LIBS)
+libXCB_la_LDFLAGS = -s
libXCB_la_SOURCES = \
xcb_conn.c xcb_out.c xcb_in.c xcb_ext.c xcb_xid.c \
xcb_list.c xcb_util.c xcb_xlib.c xcb_auth.c xcb_des.c \
-------------- next part --------------
dnl Detection and configuration of the visibility feature of gcc
dnl Vincent Torri 2005-12-24
dnl
dnl AC_CHECK_VISIBILITY([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Check the visibility feature of gcc and define VISIBILITY_CFLAGS
dnl
AC_DEFUN([AC_CHECK_VISIBILITY],
[VISIBILITY_CFLAGS=""
AC_MSG_CHECKING([whether ${CC} supports -fvisibility=hidden])
save_CFLAGS=${CFLAGS}
CFLAGS="$CFLAGS -fvisibility=hidden"
AC_TRY_LINK(
[],
[return 0;],
[VISIBILITY_CFLAGS="-fvisibility=hidden -DHAVE_VISIBILITY_FEATURE"
m4_if([$1], [], [:], [$1])],
[m4_if([$2], [], [:], [$2])])
AC_MSG_RESULT(${visibility})
CFLAGS=${save_CFLAGS}
AC_SUBST(VISIBILITY_CFLAGS)
])
-------------- next part --------------
--- configure.ac 2005-12-27 22:53:31.313031112 +0100
+++ configure.ac.new 2005-12-27 22:53:14.602571488 +0100
@@ -5,7 +5,9 @@
AC_INIT([libXCB],
0.9,
[xcb at lists.freedesktop.org])
+
AC_CONFIG_SRCDIR([xcb.pc.in])
+
AM_INIT_AUTOMAKE([foreign dist-bzip2])
dnl This ifdef has no useful effect prior to automake 1.9, but in 1.9
@@ -78,4 +80,29 @@
-Wstrict-prototypes -Wmissing-declarations -Wnested-externs"
AC_SUBST(CDEBUGFLAGS)
-AC_OUTPUT([Makefile src/Makefile tests/Makefile xcb.pc])
+AC_CHECK_VISIBILITY([has_visibility="yes"], [has_visibility="no"])
+
+AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])
+AC_CONFIG_FILES([xcb.pc])
+
+AC_OUTPUT
+
+#####################################################################
+## Info
+
+echo
+echo "------------------------------------------------------------------------"
+echo " $PACKAGE $VERSION"
+echo "------------------------------------------------------------------------"
+echo
+echo " Visibility feature..: $has_visibility"
+echo " Optimisation flags..: $optflags"
+echo
+echo " Install path........: $prefix"
+echo " binaries..........: $bindir"
+echo " libraries.........: ${libdir}"
+echo " headers...........: ${xcbincludedir}"
+echo
+echo " Compilation.........: make"
+echo " Installation........: make install"
+echo
More information about the Xcb
mailing list