Skip to content

Commit

Permalink
build adjustments: CURL_HIDDEN_SYMBOLS no longer defined in config files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yangtse committed Apr 11, 2012
1 parent a144bb8 commit 9e24b9c
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 66 deletions.
45 changes: 4 additions & 41 deletions configure.ac
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions lib/Makefile.am
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 9 additions & 8 deletions lib/config-os400.h
@@ -1,14 +1,13 @@
/* ================================================================ */
/* lib/config-os400.h - Hand crafted config file for OS/400 */
/* ================================================================ */
#ifndef HEADER_CURL_CONFIG_OS400_H
#define HEADER_CURL_CONFIG_OS400_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* 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
Expand All @@ -23,6 +22,10 @@
*
***************************************************************************/

/* ================================================================ */
/* Hand crafted config file for OS/400 */
/* ================================================================ */

#pragma enum(int)

#undef PACKAGE
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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 */
7 changes: 2 additions & 5 deletions lib/config-symbian.h
Expand Up @@ -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 */
Expand Down
5 changes: 1 addition & 4 deletions lib/config-vxworks.h
Expand Up @@ -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 */

Expand Down
5 changes: 1 addition & 4 deletions 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}
Expand Down Expand Up @@ -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}

Expand Down
112 changes: 110 additions & 2 deletions m4/curl-compilers.m4
Expand Up @@ -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
Expand All @@ -21,7 +21,7 @@
#***************************************************************************

# File version for 'aclocal' use. Keep it a single number.
# serial 58
# serial 59


dnl CURL_CHECK_COMPILER
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9e24b9c

Please sign in to comment.