Navigation Menu

Skip to content

Commit

Permalink
Improved PHP binary size and startup speed with GCC4 visibility contr…
Browse files Browse the repository at this point in the history
…ol (Nuno)
  • Loading branch information
dstogov committed Jan 30, 2008
1 parent 71efa39 commit 240fa24
Show file tree
Hide file tree
Showing 25 changed files with 175 additions and 86 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -57,6 +57,8 @@ PHP NEWS


- Removed the experimental RPL (master/slave) functions from mysqli. (Andrey) - Removed the experimental RPL (master/slave) functions from mysqli. (Andrey)


- Improved PHP binary size and startup speed with GCC4 visibility control.
(Nuno)
- Improved engine stack implementation for better performance and stability. - Improved engine stack implementation for better performance and stability.
(Dmitry) (Dmitry)
- Improved php.ini handling: (Jani) - Improved php.ini handling: (Jani)
Expand Down
6 changes: 4 additions & 2 deletions TSRM/TSRM.h
Expand Up @@ -22,10 +22,12 @@


#ifdef TSRM_WIN32 #ifdef TSRM_WIN32
# ifdef TSRM_EXPORTS # ifdef TSRM_EXPORTS
# define TSRM_API __declspec(dllexport) # define TSRM_API __declspec(dllexport)
# else # else
# define TSRM_API __declspec(dllimport) # define TSRM_API __declspec(dllimport)
# endif # endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define TSRM_API __attribute__ ((visibility("default")))
#else #else
# define TSRM_API # define TSRM_API
#endif #endif
Expand Down
14 changes: 8 additions & 6 deletions TSRM/tsrm_virtual_cwd.h
Expand Up @@ -117,13 +117,15 @@ typedef unsigned short mode_t;
#endif #endif


#ifdef TSRM_WIN32 #ifdef TSRM_WIN32
# ifdef CWD_EXPORTS # ifdef CWD_EXPORTS
# define CWD_API __declspec(dllexport) # define CWD_API __declspec(dllexport)
# else # else
# define CWD_API __declspec(dllimport) # define CWD_API __declspec(dllimport)
# endif # endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define CWD_API __attribute__ ((visibility("default")))
#else #else
#define CWD_API # define CWD_API
#endif #endif


#ifdef TSRM_WIN32 #ifdef TSRM_WIN32
Expand Down
10 changes: 8 additions & 2 deletions Zend/acconfig.h
Expand Up @@ -19,8 +19,14 @@


/* $Id$ */ /* $Id$ */


#define ZEND_API #if defined(__GNUC__) && __GNUC__ >= 4
#define ZEND_DLEXPORT # define ZEND_API __attribute__ ((visibility("default")))
# define ZEND_DLEXPORT __attribute__ ((visibility("default")))
#else
# define ZEND_API
# define ZEND_DLEXPORT
#endif

#define ZEND_DLIMPORT #define ZEND_DLIMPORT


@TOP@ @TOP@
Expand Down
8 changes: 8 additions & 0 deletions configure.in
Expand Up @@ -165,6 +165,14 @@ alpha*)
;; ;;
esac esac


dnl activate some gcc specific optimizations for gcc >= 4
if test "$GCC" = "yes"; then
GCC_MAJOR_VERSION=`$CC --version | $SED -n '1s/[[^0-9]]*\([[0-9]]\+\)\.[[0-9]]\+\..*/\1/;1p'`
if test $GCC_MAJOR_VERSION -ge 4; then
CFLAGS="$CFLAGS -fvisibility=hidden"
fi
fi

case $host_alias in case $host_alias in
*solaris*) *solaris*)
CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
Expand Down
18 changes: 10 additions & 8 deletions ext/bz2/php_bz2.h
Expand Up @@ -34,15 +34,17 @@ extern zend_module_entry bz2_module_entry;
#endif #endif


#ifdef PHP_WIN32 #ifdef PHP_WIN32
# ifdef PHP_BZ2_EXPORTS # ifdef PHP_BZ2_EXPORTS
# define PHP_BZ2_API __declspec(dllexport) # define PHP_BZ2_API __declspec(dllexport)
# elif defined(COMPILE_DL_BZ2) # elif defined(COMPILE_DL_BZ2)
# define PHP_BZ2_API __declspec(dllimport) # define PHP_BZ2_API __declspec(dllimport)
# else # else
# define PHP_BZ2_API /* nothing special */ # define PHP_BZ2_API /* nothing special */
# endif # endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_BZ2_API __attribute__ ((visibility("default")))
#else #else
# define PHP_BZ2_API # define PHP_BZ2_API
#endif #endif


PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
Expand Down
21 changes: 13 additions & 8 deletions ext/dom/xml_common.h
Expand Up @@ -35,14 +35,19 @@ typedef struct _dom_object {
} dom_object; } dom_object;


#ifdef PHP_WIN32 #ifdef PHP_WIN32
#ifdef PHPAPI # ifdef PHPAPI
#undef PHPAPI # undef PHPAPI
#endif # endif
#ifdef DOM_EXPORTS # ifdef DOM_EXPORTS
#define PHPAPI __declspec(dllexport) # define PHPAPI __declspec(dllexport)
#else # else
#define PHPAPI __declspec(dllimport) # define PHPAPI __declspec(dllimport)
#endif /* DOM_EXPORTS */ # endif /* DOM_EXPORTS */
#elif defined(__GNUC__) && __GNUC__ >= 4
# ifdef PHPAPI
# undef PHPAPI
# endif
# define PHPAPI __attribute__ ((visibility("default")))
#endif /* PHP_WIN32 */ #endif /* PHP_WIN32 */


#define PHP_DOM_EXPORT PHPAPI #define PHP_DOM_EXPORT PHPAPI
Expand Down
6 changes: 4 additions & 2 deletions ext/gd/php_gd.h
Expand Up @@ -51,9 +51,11 @@
#define PHP_GDIMG_TYPE_GD2PART 10 #define PHP_GDIMG_TYPE_GD2PART 10


#ifdef PHP_WIN32 #ifdef PHP_WIN32
#define PHP_GD_API __declspec(dllexport) # define PHP_GD_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_GD_API __attribute__ ((visibility("default")))
#else #else
#define PHP_GD_API # define PHP_GD_API
#endif #endif


PHPAPI extern const char php_sig_gif[3]; PHPAPI extern const char php_sig_gif[3];
Expand Down
6 changes: 4 additions & 2 deletions ext/hash/php_hash.h
Expand Up @@ -100,9 +100,11 @@ extern zend_module_entry hash_module_entry;
#define phpext_hash_ptr &hash_module_entry #define phpext_hash_ptr &hash_module_entry


#ifdef PHP_WIN32 #ifdef PHP_WIN32
#define PHP_HASH_API __declspec(dllexport) # define PHP_HASH_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_HASH_API __attribute__ ((visibility("default")))
#else #else
#define PHP_HASH_API # define PHP_HASH_API
#endif #endif


#ifdef ZTS #ifdef ZTS
Expand Down
14 changes: 8 additions & 6 deletions ext/iconv/php_iconv.h
Expand Up @@ -23,13 +23,15 @@
#define PHP_ICONV_H #define PHP_ICONV_H


#ifdef PHP_WIN32 #ifdef PHP_WIN32
#ifdef PHP_ICONV_EXPORTS # ifdef PHP_ICONV_EXPORTS
#define PHP_ICONV_API __declspec(dllexport) # define PHP_ICONV_API __declspec(dllexport)
# else
# define PHP_ICONV_API __declspec(dllimport)
# endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_ICONV_API __attribute__ ((visibility("default")))
#else #else
#define PHP_ICONV_API __declspec(dllimport) # define PHP_ICONV_API
#endif
#else
#define PHP_ICONV_API
#endif #endif


#ifdef PHP_ATOM_INC #ifdef PHP_ATOM_INC
Expand Down
6 changes: 4 additions & 2 deletions ext/libxml/php_libxml.h
Expand Up @@ -27,9 +27,11 @@ extern zend_module_entry libxml_module_entry;
#define libxml_module_ptr &libxml_module_entry #define libxml_module_ptr &libxml_module_entry


#ifdef PHP_WIN32 #ifdef PHP_WIN32
#define PHP_LIBXML_API __declspec(dllexport) # define PHP_LIBXML_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_LIBXML_API __attribute__ ((visibility("default")))
#else #else
#define PHP_LIBXML_API # define PHP_LIBXML_API
#endif #endif


#include "ext/standard/php_smart_str.h" #include "ext/standard/php_smart_str.h"
Expand Down
23 changes: 13 additions & 10 deletions ext/mbstring/mbstring.h
Expand Up @@ -52,17 +52,20 @@
#endif #endif


#ifdef PHP_WIN32 #ifdef PHP_WIN32
# undef MBSTRING_API # undef MBSTRING_API
# ifdef MBSTRING_EXPORTS # ifdef MBSTRING_EXPORTS
# define MBSTRING_API __declspec(dllexport) # define MBSTRING_API __declspec(dllexport)
# elif defined(COMPILE_DL_MBSTRING) # elif defined(COMPILE_DL_MBSTRING)
# define MBSTRING_API __declspec(dllimport) # define MBSTRING_API __declspec(dllimport)
# else # else
# define MBSTRING_API /* nothing special */ # define MBSTRING_API /* nothing special */
# endif # endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# undef MBSTRING_API
# define MBSTRING_API __attribute__ ((visibility("default")))
#else #else
# undef MBSTRING_API # undef MBSTRING_API
# define MBSTRING_API /* nothing special */ # define MBSTRING_API /* nothing special */
#endif #endif




Expand Down
6 changes: 5 additions & 1 deletion ext/mysqli/php_mysqli_structs.h
Expand Up @@ -145,7 +145,11 @@ typedef struct {
#define L64(x) x##i64 #define L64(x) x##i64
typedef __int64 my_longlong; typedef __int64 my_longlong;
#else #else
#define PHP_MYSQLI_API # if defined(__GNUC__) && __GNUC__ >= 4
# define PHP_MYSQLI_API __attribute__ ((visibility("default")))
# else
# define PHP_MYSQLI_API
# endif
#define MYSQLI_LLU_SPEC "%llu" #define MYSQLI_LLU_SPEC "%llu"
#define MYSQLI_LL_SPEC "%lld" #define MYSQLI_LL_SPEC "%lld"
#define L64(x) x##LL #define L64(x) x##LL
Expand Down
18 changes: 10 additions & 8 deletions ext/pdo/php_pdo.h
Expand Up @@ -31,15 +31,17 @@ extern zend_module_entry pdo_module_entry;
#define phpext_pdo_ptr &pdo_module_entry #define phpext_pdo_ptr &pdo_module_entry


#ifdef PHP_WIN32 #ifdef PHP_WIN32
# if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO)) # if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
# define PDO_API __declspec(dllexport) # define PDO_API __declspec(dllexport)
# elif defined(COMPILE_DL_PDO) # elif defined(COMPILE_DL_PDO)
# define PDO_API __declspec(dllimport) # define PDO_API __declspec(dllimport)
# else # else
# define PDO_API /* nothing special */ # define PDO_API /* nothing special */
# endif # endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PDO_API __attribute__ ((visibility("default")))
#else #else
# define PDO_API /* nothing special */ # define PDO_API /* nothing special */
#endif #endif


#ifdef ZTS #ifdef ZTS
Expand Down
6 changes: 5 additions & 1 deletion ext/pgsql/php_pgsql.h
Expand Up @@ -42,7 +42,11 @@ extern zend_module_entry pgsql_module_entry;
#endif #endif
#else #else
#include <libpq/libpq-fs.h> #include <libpq/libpq-fs.h>
#define PHP_PGSQL_API /* nothing special */ # if defined(__GNUC__) && __GNUC__ >= 4
# define PHP_PGSQL_API __attribute__ ((visibility("default")))
# else
# define PHP_PGSQL_API
# endif
#endif #endif


#ifdef HAVE_PG_CONFIG_H #ifdef HAVE_PG_CONFIG_H
Expand Down
6 changes: 4 additions & 2 deletions ext/skeleton/php_skeleton.h
Expand Up @@ -7,9 +7,11 @@ extern zend_module_entry extname_module_entry;
#define phpext_extname_ptr &extname_module_entry #define phpext_extname_ptr &extname_module_entry


#ifdef PHP_WIN32 #ifdef PHP_WIN32
#define PHP_EXTNAME_API __declspec(dllexport) # define PHP_EXTNAME_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_EXTNAME_API __attribute__ ((visibility("default")))
#else #else
#define PHP_EXTNAME_API # define PHP_EXTNAME_API
#endif #endif


#ifdef ZTS #ifdef ZTS
Expand Down
18 changes: 10 additions & 8 deletions ext/spl/php_spl.h
Expand Up @@ -32,15 +32,17 @@ extern zend_module_entry spl_module_entry;
#define phpext_spl_ptr &spl_module_entry #define phpext_spl_ptr &spl_module_entry


#ifdef PHP_WIN32 #ifdef PHP_WIN32
# ifdef SPL_EXPORTS # ifdef SPL_EXPORTS
# define SPL_API __declspec(dllexport) # define SPL_API __declspec(dllexport)
# elif defined(COMPILE_DL_SPL) # elif defined(COMPILE_DL_SPL)
# define SPL_API __declspec(dllimport) # define SPL_API __declspec(dllimport)
# else # else
# define SPL_API /* nothing */ # define SPL_API /* nothing */
# endif # endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define SPL_API __attribute__ ((visibility("default")))
#else #else
# define SPL_API # define SPL_API
#endif #endif


#if defined(PHP_WIN32) && !defined(COMPILE_DL_SPL) #if defined(PHP_WIN32) && !defined(COMPILE_DL_SPL)
Expand Down
16 changes: 9 additions & 7 deletions ext/zip/lib/zip.h
Expand Up @@ -41,14 +41,16 @@
/* #defines that rename all zip_ functions and structs */ /* #defines that rename all zip_ functions and structs */
#include "zip_alias.h" #include "zip_alias.h"
#ifdef PHP_WIN32 #ifdef PHP_WIN32
#include "zip_win32.h" # include "zip_win32.h"
# ifdef PHP_ZIP_EXPORTS # ifdef PHP_ZIP_EXPORTS
# define PHPZIPAPI __declspec(dllexport) # define PHPZIPAPI __declspec(dllexport)
# else # else
# define PHPZIPAPI # define PHPZIPAPI
# endif # endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHPZIPAPI __attribute__ ((visibility("default")))
#else #else
#define PHPZIPAPI # define PHPZIPAPI
#endif #endif
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
#include <sys/types.h> #include <sys/types.h>
Expand Down
8 changes: 5 additions & 3 deletions main/SAPI.h
Expand Up @@ -35,12 +35,14 @@


#ifdef PHP_WIN32 #ifdef PHP_WIN32
# ifdef SAPI_EXPORTS # ifdef SAPI_EXPORTS
# define SAPI_API __declspec(dllexport) # define SAPI_API __declspec(dllexport)
# else # else
# define SAPI_API __declspec(dllimport) # define SAPI_API __declspec(dllimport)
# endif # endif
#elif defined(__GNUC__) && __GNUC__ >= 4
# define SAPI_API __attribute__ ((visibility("default")))
#else #else
#define SAPI_API # define SAPI_API
#endif #endif


#undef shutdown #undef shutdown
Expand Down
19 changes: 12 additions & 7 deletions main/php.h
Expand Up @@ -45,17 +45,22 @@
#define PHP_DEBUG ZEND_DEBUG #define PHP_DEBUG ZEND_DEBUG


#ifdef PHP_WIN32 #ifdef PHP_WIN32
#include "tsrm_win32.h" # include "tsrm_win32.h"
#include "win95nt.h" # include "win95nt.h"
# ifdef PHP_EXPORTS # ifdef PHP_EXPORTS
# define PHPAPI __declspec(dllexport) # define PHPAPI __declspec(dllexport)
# else # else
# define PHPAPI __declspec(dllimport) # define PHPAPI __declspec(dllimport)
# endif # endif
#define PHP_DIR_SEPARATOR '\\' # define PHP_DIR_SEPARATOR '\\'
#define PHP_EOL "\r\n" # define PHP_EOL "\r\n"
#else #else
#define PHPAPI # if defined(__GNUC__) && __GNUC__ >= 4
# define PHPAPI __attribute__ ((visibility("default")))
# else
# define PHPAPI
# endif

#define THREAD_LS #define THREAD_LS
#define PHP_DIR_SEPARATOR '/' #define PHP_DIR_SEPARATOR '/'
#if defined(__MacOSX__) #if defined(__MacOSX__)
Expand Down

0 comments on commit 240fa24

Please sign in to comment.