aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2006-06-12 20:33:04 +0000
committerDan Fandrich <dan@coneharvesters.com>2006-06-12 20:33:04 +0000
commit59582a9d9dccada1cdc492168e089dc91f17b4fe (patch)
tree4ba936dc78db87eb7859223ab4daa4fc7320eec6
parent6246bbc6563eb328ee34df81bf99e95723dbea5e (diff)
Implemented --enable-hidden-symbols configure option to enable
-fvisibility=hidden on gcc >= 4.0. This reduces the size of the libcurl binary and speeds up dynamic linking by hiding all the internal symbols from the symbol table.
-rw-r--r--configure.ac23
-rw-r--r--docs/INSTALL26
-rw-r--r--include/curl/curl.h12
3 files changed, 56 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 41ebf6000..bb44612cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1954,6 +1954,29 @@ AC_HELP_STRING([--disable-cookies],[Disable cookies support]),
AC_MSG_RESULT(yes)
)
+dnl ************************************************************
+dnl Enable hiding of internal symbols in library to reduce its size and
+dnl speed dynamic linking of applications. This currently is only supported
+dnl on gcc >= 4.0
+dnl
+AC_MSG_CHECKING([whether to enable hidden symbols in the library])
+AC_ARG_ENABLE(hidden-symbols,
+AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library (gcc>=4)])
+AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
+[ case "$enableval" in
+ no)
+ AC_MSG_RESULT(no)
+ ;;
+ *) AC_MSG_RESULT(yes)
+ AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols])
+ AC_SUBST(CURL_HIDDEN_SYMBOLS)
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+ ;;
+ esac ],
+ AC_MSG_RESULT(no)
+)
+
+dnl ************************************************************
if test "x$ws2" = "xyes"; then
dnl If ws2_32 is wanted, make sure it is the _last_ lib in LIBS (makes
diff --git a/docs/INSTALL b/docs/INSTALL
index b44168051..c892283b2 100644
--- a/docs/INSTALL
+++ b/docs/INSTALL
@@ -506,13 +506,17 @@ CROSS COMPILE
./configure --host=ARCH-OS
+REDUCING SIZE
+=============
+
There are a number of configure options that can be used to reduce the
size of libcurl for embedded applications where binary size is an
- important factor. First, be sure to set the CFLAGS environment variable
- when configuring with any compiler optimization flags to reduce the
- size of the binary. For gcc, this would mean at minimum:
+ important factor. First, be sure to set the CFLAGS variable when
+ configuring with any relevant compiler optimization flags to reduce the
+ size of the binary. For gcc, this would mean at minimum the -Os option
+ and probably the -march=X option as well, e.g.:
- env CFLAGS='-Os' ./configure ...
+ ./configure CFLAGS='-Os' ...
Be sure to specify as many --disable- and --without- flags on the configure
command-line as you can to disable all the libcurl features that you
@@ -526,10 +530,24 @@ CROSS COMPILE
--disable-crypto-auth (disables HTTP cryptographic authentication)
--disable-ipv6 (disables support for IPv6)
--disable-verbose (eliminates debugging strings and error code strings)
+ --enable-hidden-symbols (eliminates unneeded symbols in library)
--without-libidn (disables support for the libidn DNS library)
--without-ssl (disables support for SSL/TLS)
--without-zlib (disables support for on-the-fly decompression)
+ The GNU linker has a number of options to reduce the size of the libcurl
+ dynamic libraries on some platforms even further. Specify them by giving
+ the options -Wl,-Bsymbolic and -Wl,-s on the gcc command-line.
+ Be sure also to strip debugging symbols from your binaries after
+ compiling using 'strip' (or the appropriate variant if cross-compiling).
+ If space is really tight, you may be able to remove some unneeded
+ sections of the library using the -R option to objcopy (e.g. the
+ .comment section).
+
+ Using these techniques it is possible to create an HTTP-only shared
+ libcurl library for i386 Linux platforms that is less than 90 KB in
+ size (as of version 7.15.4).
+
You may find that statically linking libcurl to your application will
result in a lower total size.
diff --git a/include/curl/curl.h b/include/curl/curl.h
index 94c4551e0..bd9236ed3 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -58,7 +58,17 @@ extern "C" {
#define CURL_EXTERN __declspec(dllimport)
#endif
#else
-#define CURL_EXTERN
+
+#ifdef CURL_HIDDEN_SYMBOLS
+/*
+ * On gcc >= 4 if -fvisibility=hidden is given then this is used to cause
+ * external definitions to be put into the shared library. It makes no
+ * difference to applications whether this is set or not, only the library.
+ */
+#define CURL_EXTERN __attribute__ ((visibility ("default")))
+#else
+#define CURL_EXTERN
+#endif
#endif
/*