Skip to content
Browse files

Improved PHP binary size and startup speed with GCC4 visibility contr…

…ol (Nuno)
  • Loading branch information...
1 parent 71efa39 commit 240fa244c345141b13485713f16525c169ffa49a Dmitry Stogov committed Jan 30, 2008
View
2 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)
View
6 TSRM/TSRM.h
@@ -22,10 +22,12 @@
#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
View
14 TSRM/tsrm_virtual_cwd.h
@@ -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
View
10 Zend/acconfig.h
@@ -19,8 +19,14 @@
/* $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@
View
8 configure.in
@@ -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"
View
18 ext/bz2/php_bz2.h
@@ -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);
View
21 ext/dom/xml_common.h
@@ -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
View
6 ext/gd/php_gd.h
@@ -51,9 +51,11 @@
#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];
View
6 ext/hash/php_hash.h
@@ -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
View
14 ext/iconv/php_iconv.h
@@ -23,13 +23,15 @@
#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
View
6 ext/libxml/php_libxml.h
@@ -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"
View
23 ext/mbstring/mbstring.h
@@ -52,17 +52,20 @@
#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
View
6 ext/mysqli/php_mysqli_structs.h
@@ -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
View
18 ext/pdo/php_pdo.h
@@ -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
View
6 ext/pgsql/php_pgsql.h
@@ -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
View
6 ext/skeleton/php_skeleton.h
@@ -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
View
18 ext/spl/php_spl.h
@@ -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)
View
16 ext/zip/lib/zip.h
@@ -41,14 +41,16 @@
/* #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>
View
8 main/SAPI.h
@@ -35,12 +35,14 @@
#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
View
19 main/php.h
@@ -45,17 +45,22 @@
#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__)
View
6 sapi/apache/mod_php5.h
@@ -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 */
/*
View
6 sapi/apache2filter/php_apache.h
@@ -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 */
View
5 sapi/apache2handler/php_apache.h
@@ -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 */
View
7 sapi/apache_hooks/mod_php5.h
@@ -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 */
/*
View
6 sapi/pi3web/pi3web_sapi.h
@@ -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;

0 comments on commit 240fa24

Please sign in to comment.
Something went wrong with that request. Please try again.