diff options
author | Yang Tse <yangsita@gmail.com> | 2012-04-11 19:33:54 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2012-04-11 19:33:54 +0200 |
commit | 9e24b9c7afbcb81120af4cf3f6cdee49a06d8224 (patch) | |
tree | 0c671c32f59daa6848636e7f34c6071ed2bcae37 | |
parent | a144bb8b767b1c9ae40a0e7853db88ed67c9e8c3 (diff) |
build adjustments: CURL_HIDDEN_SYMBOLS no longer defined in config files
configure script now provides conditional definitions for Makefile.am
that result in CURL_HIDDEN_SYMBOLS being defined by resulting makefiles
when appropriate.
Additionally, configure script option for symbol hiding control is now
named --enable-symbol-hiding --disable-symbol-hiding. While still valid,
old option name --enable-hidden-symbols --disable-hidden-symbols will
be deprecated in some future release.
-rw-r--r-- | configure.ac | 45 | ||||
-rw-r--r-- | lib/Makefile.am | 11 | ||||
-rw-r--r-- | lib/config-os400.h | 17 | ||||
-rw-r--r-- | lib/config-symbian.h | 7 | ||||
-rw-r--r-- | lib/config-vxworks.h | 5 | ||||
-rw-r--r-- | lib/curl_config.h.cmake | 5 | ||||
-rw-r--r-- | m4/curl-compilers.m4 | 112 | ||||
-rw-r--r-- | m4/curl-confopts.m4 | 77 | ||||
-rw-r--r-- | tests/libtest/Makefile.am | 9 |
9 files changed, 222 insertions, 66 deletions
diff --git a/configure.ac b/configure.ac index 976553c10..dbdde18c9 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,7 @@ CURL_CHECK_OPTION_OPTIMIZE CURL_CHECK_OPTION_WARNINGS CURL_CHECK_OPTION_WERROR CURL_CHECK_OPTION_CURLDEBUG +CURL_CHECK_OPTION_SYMBOL_HIDING CURL_CHECK_OPTION_ARES CURL_CHECK_PATH_SEPARATOR_REQUIRED @@ -299,6 +300,7 @@ fi CURL_CHECK_COMPILER_HALT_ON_ERROR CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE +CURL_CHECK_COMPILER_SYMBOL_HIDING CURL_CHECK_NO_UNDEFINED AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes) @@ -3060,48 +3062,9 @@ AC_HELP_STRING([--disable-cookies],[Disable cookies support]), ) 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 and SunPro C. +dnl hiding of library internal symbols 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]) -AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]), -[ case "$enableval" in - no) - AC_MSG_RESULT(no) - ;; - *) - AC_MSG_CHECKING([whether $CC supports it]) - if test "$GCC" = yes ; then - if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null || - dnl clang always supports -fvisibility= but it doesn't show up - dnl under --help. - test "$compiler_id" = "CLANG"; then - AC_MSG_RESULT(yes) - AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols]) - AC_DEFINE(CURL_EXTERN_SYMBOL, [__attribute__ ((visibility ("default")))], [to make a symbol visible]) - CFLAGS="$CFLAGS -fvisibility=hidden" - else - AC_MSG_RESULT(no) - fi - - else - dnl Test for SunPro cc - if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then - AC_MSG_RESULT(yes) - AC_DEFINE(CURL_HIDDEN_SYMBOLS, 1, [to enable hidden symbols]) - AC_DEFINE(CURL_EXTERN_SYMBOL, [__global], [to make a symbol visible]) - CFLAGS="$CFLAGS -xldscope=hidden" - else - AC_MSG_RESULT(no) - fi - fi - ;; - esac ], - AC_MSG_RESULT(no) -) +CURL_CONFIGURE_SYMBOL_HIDING dnl ************************************************************ dnl enforce SONAME bump diff --git a/lib/Makefile.am b/lib/Makefile.am index 76fd66040..5a8b3aa95 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -48,6 +48,8 @@ LIBCURL_LIBS = @LIBCURL_LIBS@ # This might hold -Werror CFLAGS += @CURL_CFLAG_EXTRAS@ +CFLAG_SYMBOL_HIDING = @CFLAG_SYMBOL_HIDING@ + # Specify our include paths here, and do it relative to $(top_srcdir) and # $(top_builddir), to ensure that these paths which belong to the library # being currently built and tested are searched before the library which @@ -134,6 +136,14 @@ endif libcurl_la_LDFLAGS = $(UNDEF) $(VERSIONINFO) $(MIMPURE) $(VERSIONED_SYMBOLS) $(LIBCURL_LIBS) +if DOING_SYMBOL_HIDING +libcurl_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_HIDDEN_SYMBOLS +libcurl_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_SYMBOL_HIDING) +else +libcurl_la_CPPFLAGS = $(AM_CPPFLAGS) +libcurl_la_CFLAGS = $(AM_CFLAGS) +endif + # unit testing static library built only along with unit tests if BUILD_UNITTESTS noinst_LTLIBRARIES = libcurlu.la @@ -143,6 +153,7 @@ endif libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DUNITTESTS libcurlu_la_LDFLAGS = -static $(LIBCURL_LIBS) +libcurlu_la_CFLAGS = $(AM_CFLAGS) # Makefile.inc provides the CSOURCES and HHEADERS defines include Makefile.inc diff --git a/lib/config-os400.h b/lib/config-os400.h index 4d2730928..208c02903 100644 --- a/lib/config-os400.h +++ b/lib/config-os400.h @@ -1,6 +1,5 @@ -/* ================================================================ */ -/* lib/config-os400.h - Hand crafted config file for OS/400 */ -/* ================================================================ */ +#ifndef HEADER_CURL_CONFIG_OS400_H +#define HEADER_CURL_CONFIG_OS400_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -8,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,6 +22,10 @@ * ***************************************************************************/ +/* ================================================================ */ +/* Hand crafted config file for OS/400 */ +/* ================================================================ */ + #pragma enum(int) #undef PACKAGE @@ -434,10 +437,7 @@ /* To disable LDAP */ #undef CURL_DISABLE_LDAP -/* To avoid external use of library hidden symbols */ -#define CURL_HIDDEN_SYMBOLS - -/* External symbols need no special keyword. */ +/* Definition to make a library symbol externally visible. */ #define CURL_EXTERN_SYMBOL /* Define if you have the ldap_url_parse procedure. */ @@ -542,3 +542,4 @@ #define qadrt_use_fread_inline /* Generate fread() wrapper inline. */ #define qadrt_use_fwrite_inline /* Generate fwrite() wrapper inline. */ +#endif /* HEADER_CURL_CONFIG_OS400_H */ diff --git a/lib/config-symbian.h b/lib/config-symbian.h index b4dc03288..d70498fa9 100644 --- a/lib/config-symbian.h +++ b/lib/config-symbian.h @@ -65,11 +65,8 @@ /* to disable verbose strings */ /* #define CURL_DISABLE_VERBOSE_STRINGS 1*/ -/* to make a symbol visible */ -/*#define CURL_EXTERN_SYMBOL __declspec(dllexport)*/ - -/* to enable hidden symbols */ -/*#define CURL_HIDDEN_SYMBOLS 1*/ +/* Definition to make a library symbol externally visible. */ +/* #undef CURL_EXTERN_SYMBOL */ /* Use Windows LDAP implementation */ /* #undef CURL_LDAP_WIN */ diff --git a/lib/config-vxworks.h b/lib/config-vxworks.h index 53266c021..83cf72375 100644 --- a/lib/config-vxworks.h +++ b/lib/config-vxworks.h @@ -71,12 +71,9 @@ /* to disable verbose strings */ /* #undef CURL_DISABLE_VERBOSE_STRINGS */ -/* to make a symbol visible */ +/* Definition to make a library symbol externally visible. */ /* #undef CURL_EXTERN_SYMBOL */ -/* to enable hidden symbols */ -/* #undef CURL_HIDDEN_SYMBOLS */ - /* Use Windows LDAP implementation */ /* #undef CURL_LDAP_WIN */ diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index a321302a6..68251e4a7 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -1,4 +1,4 @@ -/* lib/curl_config.h.in. Generated from configure.ac by autoheader. */ +/* lib/curl_config.h.in. Generated somehow by cmake. */ /* when building libcurl itself */ #cmakedefine BUILDING_LIBCURL ${BUILDING_LIBCURL} @@ -52,9 +52,6 @@ #define CURL_EXTERN_SYMBOL #endif -/* to enable hidden symbols */ -#cmakedefine CURL_HIDDEN_SYMBOLS ${CURL_HIDDEN_SYMBOLS} - /* Use Windows LDAP implementation */ #cmakedefine CURL_LDAP_WIN ${CURL_LDAP_WIN} diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4 index c0f18c897..9b212e462 100644 --- a/m4/curl-compilers.m4 +++ b/m4/curl-compilers.m4 @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -21,7 +21,7 @@ #*************************************************************************** # File version for 'aclocal' use. Keep it a single number. -# serial 58 +# serial 59 dnl CURL_CHECK_COMPILER @@ -1375,6 +1375,114 @@ AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [ ]) +dnl CURL_CHECK_COMPILER_SYMBOL_HIDING +dnl ------------------------------------------------- +dnl Verify if compiler supports hiding library internal symbols, setting +dnl shell variable supports_symbol_hiding value as appropriate, as well as +dnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported. + +AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [ + AC_REQUIRE([CURL_CHECK_COMPILER])dnl + AC_BEFORE([$0],[CURL_CONFIGURE_SYMBOL_HIDING])dnl + AC_MSG_CHECKING([if compiler supports hiding library internal symbols]) + supports_symbol_hiding="no" + symbol_hiding_CFLAGS="" + symbol_hiding_EXTERN="" + tmp_CFLAGS="" + tmp_EXTERN="" + case "$compiler_id" in + CLANG) + dnl All versions of clang support -fvisibility= + tmp_EXTERN="__attribute__ ((visibility (\"default\")))" + tmp_CFLAGS="-fvisibility=hidden" + supports_symbol_hiding="yes" + ;; + GNU_C) + dnl Only gcc 3.4 or later + if test "$compiler_num" -ge "304"; then + if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then + tmp_EXTERN="__attribute__ ((visibility (\"default\")))" + tmp_CFLAGS="-fvisibility=hidden" + supports_symbol_hiding="yes" + fi + fi + ;; + INTEL_UNIX_C) + dnl Only icc 9.0 or later + if test "$compiler_num" -ge "900"; then + if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then + tmp_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fvisibility=hidden" + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ +# include <stdio.h> + ]],[[ + printf("icc fvisibility bug test"); + ]]) + ],[ + tmp_EXTERN="__attribute__ ((visibility (\"default\")))" + tmp_CFLAGS="-fvisibility=hidden" + supports_symbol_hiding="yes" + ]) + CFLAGS="$tmp_save_CFLAGS" + fi + fi + ;; + SUNPRO_C) + if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then + tmp_EXTERN="__global" + tmp_CFLAGS="-xldscope=hidden" + supports_symbol_hiding="yes" + fi + ;; + esac + if test "$supports_symbol_hiding" = "yes"; then + tmp_save_CFLAGS="$CFLAGS" + CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" + squeeze CFLAGS + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $tmp_EXTERN char *dummy(char *buff); + char *dummy(char *buff) + { + if(buff) + return ++buff; + else + return buff; + } + ]],[[ + char b[16]; + char *r = dummy(&b[0]); + if(r) + return (int)*r; + ]]) + ],[ + supports_symbol_hiding="yes" + if test -f conftest.err; then + grep 'visibility' conftest.err >/dev/null + if test "$?" -eq "0"; then + supports_symbol_hiding="no" + fi + fi + ],[ + supports_symbol_hiding="no" + echo " " >&6 + sed 's/^/cc-src: /' conftest.$ac_ext >&6 + sed 's/^/cc-err: /' conftest.err >&6 + echo " " >&6 + ]) + CFLAGS="$tmp_save_CFLAGS" + fi + if test "$supports_symbol_hiding" = "yes"; then + AC_MSG_RESULT([yes]) + symbol_hiding_CFLAGS="$tmp_CFLAGS" + symbol_hiding_EXTERN="$tmp_EXTERN" + else + AC_MSG_RESULT([no]) + fi +]) + + dnl CURL_VAR_MATCH (VARNAME, VALUE) dnl ------------------------------------------------- dnl Verifies if shell variable VARNAME contains VALUE. diff --git a/m4/curl-confopts.m4 b/m4/curl-confopts.m4 index 9d4315626..f335b7a60 100644 --- a/m4/curl-confopts.m4 +++ b/m4/curl-confopts.m4 @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -21,7 +21,7 @@ #*************************************************************************** # File version for 'aclocal' use. Keep it a single number. -# serial 16 +# serial 17 dnl CURL_CHECK_OPTION_THREADED_RESOLVER dnl ------------------------------------------------- @@ -258,6 +258,50 @@ AC_HELP_STRING([--disable-optimize],[Disable compiler optimizations]), ]) +dnl CURL_CHECK_OPTION_SYMBOL_HIDING +dnl ------------------------------------------------- +dnl Verify if configure has been invoked with option +dnl --enable-symbol-hiding or --disable-symbol-hiding, +dnl setting shell variable want_symbol_hiding value. + +AC_DEFUN([CURL_CHECK_OPTION_SYMBOL_HIDING], [ + AC_BEFORE([$0],[CURL_CHECK_COMPILER_SYMBOL_HIDING])dnl + AC_MSG_CHECKING([whether to enable hiding of library internal symbols]) + OPT_SYMBOL_HIDING="default" + AC_ARG_ENABLE(symbol-hiding, +AC_HELP_STRING([--enable-symbol-hiding],[Enable hiding of library internal symbols]) +AC_HELP_STRING([--disable-symbol-hiding],[Disable hiding of library internal symbols]), + OPT_SYMBOL_HIDING=$enableval) + AC_ARG_ENABLE(hidden-symbols, +AC_HELP_STRING([--enable-hidden-symbols],[To be deprecated, use --enable-symbol-hiding]) +AC_HELP_STRING([--disable-hidden-symbols],[To be deprecated, use --disable-symbol-hiding]), + OPT_SYMBOL_HIDING=$enableval) + case "$OPT_SYMBOL_HIDING" in + no) + dnl --disable-symbol-hiding option used. + dnl This is an indication to not attempt hiding of library internal + dnl symbols. Default symbol visibility will be used, which normally + dnl exposes all library internal symbols. + want_symbol_hiding="no" + AC_MSG_RESULT([no]) + ;; + default) + dnl configure's symbol-hiding option not specified. + dnl Handle this as if --enable-symbol-hiding option was given. + want_symbol_hiding="yes" + AC_MSG_RESULT([yes]) + ;; + *) + dnl --enable-symbol-hiding option used. + dnl This is an indication to attempt hiding of library internal + dnl symbols. This is only supported on some compilers/linkers. + want_symbol_hiding="yes" + AC_MSG_RESULT([yes]) + ;; + esac +]) + + dnl CURL_CHECK_OPTION_THREADS dnl ------------------------------------------------- dnl Verify if configure has been invoked with option @@ -411,6 +455,35 @@ AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [ ]) +dnl CURL_CONFIGURE_SYMBOL_HIDING +dnl ------------------------------------------------- +dnl Depending on --enable-symbol-hiding or --disable-symbol-hiding +dnl configure option, and compiler capability to actually honor such +dnl option, this will modify compiler flags as appropriate and also +dnl provide needed definitions for configuration and Makefile.am files. +dnl This macro should not be used until all compilation tests have +dnl been done to prevent interferences on other tests. + +AC_DEFUN([CURL_CONFIGURE_SYMBOL_HIDING], [ + AC_MSG_CHECKING([whether hiding of library internal symbols will actually happen]) + CFLAG_SYMBOL_HIDING="" + doing_symbol_hiding="no" + if test x"$ac_cv_native_windows" != "xyes" && + test "$want_symbol_hiding" = "yes" && + test "$supports_symbol_hiding" = "yes"; then + doing_symbol_hiding="yes" + CFLAG_SYMBOL_HIDING="$symbol_hiding_CFLAGS" + AC_DEFINE_UNQUOTED(CURL_EXTERN_SYMBOL, $symbol_hiding_EXTERN, + [Definition to make a library symbol externally visible.]) + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + AM_CONDITIONAL(DOING_SYMBOL_HIDING, test x$doing_symbol_hiding = xyes) + AC_SUBST(CFLAG_SYMBOL_HIDING) +]) + + dnl CURL_CHECK_LIB_ARES dnl ------------------------------------------------- dnl When c-ares library support has been requested, diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index be667ee22..e4538b750 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,6 +53,8 @@ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc +CFLAG_SYMBOL_HIDING = @CFLAG_SYMBOL_HIDING@ + # Dependencies (may need to be overriden) LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ DEPENDENCIES = $(top_builddir)/lib/libcurl.la @@ -86,3 +88,10 @@ libhostname_la_LIBADD = libhostname_la_DEPENDENCIES = libhostname_la_LDFLAGS = -module -avoid-version $(UNDEF) -rpath /nowhere +if DOING_SYMBOL_HIDING +libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_HIDDEN_SYMBOLS +libhostname_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_SYMBOL_HIDING) +else +libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) +libhostname_la_CFLAGS = $(AM_CFLAGS) +endif |