]> granicus.if.org Git - php/commitdiff
Improved PHP binary size and startup speed with GCC4 visibility control (Nuno)
authorDmitry Stogov <dmitry@php.net>
Wed, 30 Jan 2008 09:41:12 +0000 (09:41 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 30 Jan 2008 09:41:12 +0000 (09:41 +0000)
25 files changed:
NEWS
TSRM/TSRM.h
TSRM/tsrm_virtual_cwd.h
Zend/acconfig.h
configure.in
ext/bz2/php_bz2.h
ext/dom/xml_common.h
ext/gd/php_gd.h
ext/hash/php_hash.h
ext/iconv/php_iconv.h
ext/libxml/php_libxml.h
ext/mbstring/mbstring.h
ext/mysqli/php_mysqli_structs.h
ext/pdo/php_pdo.h
ext/pgsql/php_pgsql.h
ext/skeleton/php_skeleton.h
ext/spl/php_spl.h
ext/zip/lib/zip.h
main/SAPI.h
main/php.h
sapi/apache/mod_php5.h
sapi/apache2filter/php_apache.h
sapi/apache2handler/php_apache.h
sapi/apache_hooks/mod_php5.h
sapi/pi3web/pi3web_sapi.h

diff --git a/NEWS b/NEWS
index 0d508563cb72282873239792b22519dd951e9fa2..1bd1e391a600d2c292b029a5d6f74ef654bacb67 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -57,6 +57,8 @@ PHP                                                                        NEWS
 
 - 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.
   (Dmitry)
 - Improved php.ini handling: (Jani)
index 4a73c3487bc04fd35357395ebd532ff9b9909904..9695a726ecfe7872bc4e544273903912ea175d7f 100644 (file)
 
 #ifdef TSRM_WIN32
 #      ifdef TSRM_EXPORTS
-#      define TSRM_API __declspec(dllexport)
+#              define TSRM_API __declspec(dllexport)
 #      else
-#      define TSRM_API __declspec(dllimport)
+#              define TSRM_API __declspec(dllimport)
 #      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define TSRM_API __attribute__ ((visibility("default")))
 #else
 #      define TSRM_API
 #endif
index 238c08035cfc9e5845e91a6dc42019b7acf0066f..d4e2415b1053aa1f57ffa0d9ecd9442e48acb630 100644 (file)
@@ -117,13 +117,15 @@ typedef unsigned short mode_t;
 #endif
 
 #ifdef TSRM_WIN32
-#       ifdef CWD_EXPORTS
-#       define CWD_API __declspec(dllexport)
-#       else
-#       define CWD_API __declspec(dllimport)
-#       endif
+#      ifdef CWD_EXPORTS
+#              define CWD_API __declspec(dllexport)
+#      else
+#              define CWD_API __declspec(dllimport)
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define CWD_API __attribute__ ((visibility("default")))
 #else
-#define CWD_API
+#      define CWD_API
 #endif
 
 #ifdef TSRM_WIN32
index 7fd5a07661b4ddc2a626c07a2c22349747b6e999..8e3176c0f11a0da70d5173971ecdcb1bde69b220 100644 (file)
 
 /* $Id$ */
 
-#define ZEND_API
-#define ZEND_DLEXPORT
+#if defined(__GNUC__) && __GNUC__ >= 4
+# define ZEND_API __attribute__ ((visibility("default")))
+# define ZEND_DLEXPORT __attribute__ ((visibility("default")))
+#else
+# define ZEND_API
+# define ZEND_DLEXPORT
+#endif
+
 #define ZEND_DLIMPORT
 
 @TOP@
index b627a676ec7f80b7e814bfb0e4f33357d5ec09f6..e5dff11c713b12ab33dc70fc783cb3d9baf058a2 100644 (file)
@@ -165,6 +165,14 @@ alpha*)
     ;;
 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
 *solaris*)
     CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
index 5d453a545745a4d43b50d6dd1037fa94c2dcff76..9ef05568553f05488c0b6edc6d5bf6d42758759a 100644 (file)
@@ -34,15 +34,17 @@ extern zend_module_entry bz2_module_entry;
 #endif
 
 #ifdef PHP_WIN32
-# ifdef PHP_BZ2_EXPORTS
-#  define PHP_BZ2_API __declspec(dllexport)
-# elif defined(COMPILE_DL_BZ2)
-#  define PHP_BZ2_API __declspec(dllimport)
-# else
-#  define PHP_BZ2_API /* nothing special */
-# endif
+#      ifdef PHP_BZ2_EXPORTS
+#              define PHP_BZ2_API __declspec(dllexport)
+#      elif defined(COMPILE_DL_BZ2)
+#              define PHP_BZ2_API __declspec(dllimport)
+#      else
+#              define PHP_BZ2_API /* nothing special */
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHP_BZ2_API __attribute__ ((visibility("default")))
 #else
-# define PHP_BZ2_API
+#      define PHP_BZ2_API
 #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);
index 4193416218a6acff5f67e54aceac5fac4e664d6f..2b019301451a94c3ee9990c768535fdbe58ec91a 100644 (file)
@@ -35,14 +35,19 @@ typedef struct _dom_object {
 } dom_object;
 
 #ifdef PHP_WIN32
-#ifdef PHPAPI
-#undef PHPAPI
-#endif
-#ifdef DOM_EXPORTS
-#define PHPAPI __declspec(dllexport)
-#else
-#define PHPAPI __declspec(dllimport)
-#endif /* DOM_EXPORTS */
+#      ifdef PHPAPI
+#              undef PHPAPI
+#      endif
+#      ifdef DOM_EXPORTS
+#              define PHPAPI __declspec(dllexport)
+#      else
+#              define PHPAPI __declspec(dllimport)
+#      endif /* DOM_EXPORTS */
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      ifdef PHPAPI
+#              undef PHPAPI
+#      endif
+#      define PHPAPI __attribute__ ((visibility("default")))
 #endif /* PHP_WIN32 */
 
 #define PHP_DOM_EXPORT PHPAPI
index e4b5ad2ce491b46e4241b9a7ddd4ab42d70afca7..382a53cfce75c237d0b01331dd53773de2d217b6 100644 (file)
 #define PHP_GDIMG_TYPE_GD2PART 10
 
 #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
-#define PHP_GD_API
+#      define PHP_GD_API
 #endif
 
 PHPAPI extern const char php_sig_gif[3];
index e2309201f9564957cc77b9889a3b24ce27e47722..0f660c785aa3b14021d3d3cc25df73186430e181 100644 (file)
@@ -100,9 +100,11 @@ extern zend_module_entry hash_module_entry;
 #define phpext_hash_ptr &hash_module_entry
 
 #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
-#define PHP_HASH_API
+#      define PHP_HASH_API
 #endif
 
 #ifdef ZTS
index 20e52c9e6a1ea216aa6ee5690369dc36d46df738..8f098b9ecd03e7bb4b173e7942ee90eb1f3ce23a 100644 (file)
 #define PHP_ICONV_H
 
 #ifdef PHP_WIN32
-#ifdef PHP_ICONV_EXPORTS
-#define PHP_ICONV_API __declspec(dllexport)
+#      ifdef PHP_ICONV_EXPORTS
+#              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
-#define PHP_ICONV_API __declspec(dllimport)
-#endif 
-#else
-#define PHP_ICONV_API
+#      define PHP_ICONV_API
 #endif
 
 #ifdef PHP_ATOM_INC
index 468c088fe1a6b6e94a7c2aa4ae4c3c8bae045a93..27729162dc3a02cd50a3bb1e667417863ce4471c 100644 (file)
@@ -27,9 +27,11 @@ extern zend_module_entry libxml_module_entry;
 #define libxml_module_ptr &libxml_module_entry
 
 #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
-#define PHP_LIBXML_API
+#      define PHP_LIBXML_API
 #endif
 
 #include "ext/standard/php_smart_str.h"
index 63afaf50942487887b29f0f9443e8065049e1a9c..1393559f8e9b4a8e414154130aa275b5475f8b3f 100644 (file)
 #endif
 
 #ifdef PHP_WIN32
-# undef MBSTRING_API
-# ifdef MBSTRING_EXPORTS
-#  define MBSTRING_API __declspec(dllexport)
-# elif defined(COMPILE_DL_MBSTRING)
-#  define MBSTRING_API __declspec(dllimport)
-# else
-#  define MBSTRING_API /* nothing special */
-# endif
+#      undef MBSTRING_API
+#      ifdef MBSTRING_EXPORTS
+#              define MBSTRING_API __declspec(dllexport)
+#      elif defined(COMPILE_DL_MBSTRING)
+#              define MBSTRING_API __declspec(dllimport)
+#      else
+#              define MBSTRING_API /* nothing special */
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      undef MBSTRING_API
+#      define MBSTRING_API __attribute__ ((visibility("default")))
 #else
-# undef MBSTRING_API
-# define MBSTRING_API /* nothing special */
+#      undef MBSTRING_API
+#      define MBSTRING_API /* nothing special */
 #endif
 
 
index 7177e42d514d85878d3fe79214ca7c0faa983813..81003c16babefcf84727fcb17476478185ba2595 100644 (file)
@@ -145,7 +145,11 @@ typedef struct {
 #define L64(x) x##i64
 typedef __int64 my_longlong;
 #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_LL_SPEC "%lld"
 #define L64(x) x##LL
index fa83596e484e21e0d1c3c3aa01dc69d6e8c0e92a..b2e146894946e22b5517be6568f87f16581f988c 100755 (executable)
@@ -31,15 +31,17 @@ extern zend_module_entry pdo_module_entry;
 #define phpext_pdo_ptr &pdo_module_entry
 
 #ifdef PHP_WIN32
-# if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
-#  define PDO_API __declspec(dllexport)
-# elif defined(COMPILE_DL_PDO)
-#  define PDO_API __declspec(dllimport)
-# else
-#  define PDO_API /* nothing special */
-# endif
+#      if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
+#              define PDO_API __declspec(dllexport)
+#      elif defined(COMPILE_DL_PDO)
+#              define PDO_API __declspec(dllimport)
+#      else
+#              define PDO_API /* nothing special */
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PDO_API __attribute__ ((visibility("default")))
 #else
-# define PDO_API /* nothing special */
+#      define PDO_API /* nothing special */
 #endif
 
 #ifdef ZTS
index 0e384348685c12990430e2f82ee4c0ae58055831..96ce461b6fd1a38ec3f201e9809121b58532c6ad 100644 (file)
@@ -42,7 +42,11 @@ extern zend_module_entry pgsql_module_entry;
 #endif
 #else
 #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
 
 #ifdef HAVE_PG_CONFIG_H
index 7508f4f97934f85c9316dfdd0d7e37c12d4371a4..495907bbd16ed2c19ef475bfa5152ed78968d945 100644 (file)
@@ -7,9 +7,11 @@ extern zend_module_entry extname_module_entry;
 #define phpext_extname_ptr &extname_module_entry
 
 #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
-#define PHP_EXTNAME_API
+#      define PHP_EXTNAME_API
 #endif
 
 #ifdef ZTS
index 75ec338285feb3d515f1636474899bf6c89bd5f6..baf2d9115f867eb300550bcbca0879c3c3a72c43 100755 (executable)
@@ -32,15 +32,17 @@ extern zend_module_entry spl_module_entry;
 #define phpext_spl_ptr &spl_module_entry
 
 #ifdef PHP_WIN32
-# ifdef SPL_EXPORTS
-#  define SPL_API __declspec(dllexport)
-# elif defined(COMPILE_DL_SPL)
-#  define SPL_API __declspec(dllimport)
-# else
-#  define SPL_API /* nothing */
-# endif
+#      ifdef SPL_EXPORTS
+#              define SPL_API __declspec(dllexport)
+#      elif defined(COMPILE_DL_SPL)
+#              define SPL_API __declspec(dllimport)
+#      else
+#              define SPL_API /* nothing */
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define SPL_API __attribute__ ((visibility("default")))
 #else
-# define SPL_API
+#      define SPL_API
 #endif
 
 #if defined(PHP_WIN32) && !defined(COMPILE_DL_SPL)
index 04ffb1471b5544b0f433ebb6c2429f9b1ef73715..87151174b0fa2512d2aa737edad778da6719b907 100644 (file)
 /* #defines that rename all zip_ functions and structs */
 #include "zip_alias.h"
 #ifdef PHP_WIN32
-#include "zip_win32.h"
-# ifdef PHP_ZIP_EXPORTS
-#  define PHPZIPAPI __declspec(dllexport)
-# else
-#  define PHPZIPAPI
-# endif
+#      include "zip_win32.h"
+#      ifdef PHP_ZIP_EXPORTS
+#              define PHPZIPAPI __declspec(dllexport)
+#      else
+#              define PHPZIPAPI
+#      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define PHPZIPAPI __attribute__ ((visibility("default")))
 #else
-#define PHPZIPAPI
+#      define PHPZIPAPI
 #endif
 BEGIN_EXTERN_C()
 #include <sys/types.h>
index e3d7279785b7a143ab5cd01f0d51fbdbfb83df79..39a9a85b2663627358e1cfcfac89bb96753467a1 100644 (file)
 
 #ifdef PHP_WIN32
 #      ifdef SAPI_EXPORTS
-#      define SAPI_API __declspec(dllexport) 
+#              define SAPI_API __declspec(dllexport) 
 #      else
-#      define SAPI_API __declspec(dllimport) 
+#              define SAPI_API __declspec(dllimport) 
 #      endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+#      define SAPI_API __attribute__ ((visibility("default")))
 #else
-#define SAPI_API
+#      define SAPI_API
 #endif
 
 #undef shutdown
index 77d499f3db0e2565dd76a6e7aa2d8c26dc8fd119..65dd2419fea38e7c518610cf97c4178e33d5094a 100644 (file)
 #define PHP_DEBUG ZEND_DEBUG
 
 #ifdef PHP_WIN32
-#include "tsrm_win32.h"
-#include "win95nt.h"
+#      include "tsrm_win32.h"
+#      include "win95nt.h"
 #      ifdef PHP_EXPORTS
-#      define PHPAPI __declspec(dllexport)
+#              define PHPAPI __declspec(dllexport)
 #      else
-#      define PHPAPI __declspec(dllimport)
+#              define PHPAPI __declspec(dllimport)
 #      endif
-#define PHP_DIR_SEPARATOR '\\'
-#define PHP_EOL "\r\n"
+#      define PHP_DIR_SEPARATOR '\\'
+#      define PHP_EOL "\r\n"
 #else
-#define PHPAPI
+#      if defined(__GNUC__) && __GNUC__ >= 4
+#              define PHPAPI __attribute__ ((visibility("default")))
+#      else
+#              define PHPAPI
+#      endif
+
 #define THREAD_LS
 #define PHP_DIR_SEPARATOR '/'
 #if defined(__MacOSX__)
index 1daa476c7e9356a8f478d4c92a47d74363292e2b..7533530de511a243595353090adde35059928ede 100644 (file)
@@ -44,6 +44,12 @@ extern php_apache_info_struct php_apache_info;
 #define AP(v) (php_apache_info.v)
 #endif
 
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef MODULE_VAR_EXPORT
+# define MODULE_VAR_EXPORT PHPAPI
+#endif
+
 #endif                                                 /* MOD_PHP5_H */
 
 /*
index 78050a7de573008fb4eb3db4e9146525e855ca21..53bfb9c223025302e5f8a9e79da1f9d6a2c584c0 100644 (file)
@@ -74,4 +74,10 @@ static long php_apache_fteller_stream(void * TSRMLS_DC);
 
 #define APR_ARRAY_FOREACH_CLOSE() }}
 
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef AP_MODULE_DECLARE_DATA
+# define AP_MODULE_DECLARE_DATA PHPAPI
+#endif
+
 #endif /* PHP_APACHE_H */
index 3d41439170950c7da4ab4546f8c229550165d38f..af9da3a23044b8a77a5bf46635d9479586e52b51 100644 (file)
@@ -82,5 +82,10 @@ extern php_apache2_info_struct php_apache2_info;
 #define AP2(v) (php_apache2_info.v)
 #endif
 
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef AP_MODULE_DECLARE_DATA
+# define AP_MODULE_DECLARE_DATA PHPAPI
+#endif
 
 #endif /* PHP_APACHE_H */
index 0d61bf89822a388a7e76adc02210184cee3de2ce..1549dbf2636f9c37969ead07d46d18914354668f 100644 (file)
@@ -71,6 +71,13 @@ extern php_apache_info_struct php_apache_info;
 #define AP_LOGGING 10
 #define AP_CLEANUP 11
 
+
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef MODULE_VAR_EXPORT
+# define MODULE_VAR_EXPORT PHPAPI
+#endif
+
 #endif                                                 /* MOD_PHP5_H */
 
 /*
index 9300241d449200dc18b714d4a4c674347e774e5e..d229fec53faf33b6838943ca59ec6c600f12c168 100644 (file)
@@ -9,8 +9,12 @@
 #              define MODULE_API __declspec(dllimport) 
 #      endif
 #else
+#      if defined(__GNUC__) && __GNUC__ >= 4
+#              define MODULE_API __attribute__ ((visibility("default")))
+#      else
+#              define MODULE_API
+#      endif
 #      define far
-#      define MODULE_API
 
        typedef int BOOL;
        typedef void far *LPVOID;