summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <michael@orlitzky.com>2016-09-10 11:20:50 -0400
committerMichael Orlitzky <michael@orlitzky.com>2016-09-10 11:31:49 -0400
commit086f9adc4d6fe58b75e419cd6312afdbf3d90277 (patch)
tree7d7944bfc0f41df00101bc3db93f11716088c4d7
parentd1535da7e6326d3eb739517525a6cb985055767e (diff)
downloadphp-git-086f9adc4d6fe58b75e419cd6312afdbf3d90277.tar.gz
Use AX_CHECK_COMPILE_FLAG macro to check for -fvisibility=hidden support.
The existing check for -fvisibility=hidden support came from a time when only GCC had it. The test for it used a regular expression to parse the GCC major version from the output of `$CC --version`, and would look for version 4 or greater. The regular expression used to accomplish this is doomed, however, since GCC can be built with a custom version string (--with-pkgversion). Moreover, the $CC variable can be set to something that confuses it but is otherwise valid. For example, it would fail with CC=x86_64-pc-linux-gnu-gcc. This commit fixes two aspects of the feature test. First, it no longer limits the test to GCC. At least clang now supports the flag, and can make use of it when GCC is its backend. Second, support for the flag is tested directly, by attempting to pass it to the compiler, rather than by parsing its version string. The latter is accomplished with a new macro, AX_CHECK_COMPILE_FLAG, taken from the autoconf archive. The new macro has been added to acinclude.m4, and the test stanza in configure.in has been replaced with a single call to the new macro. Note that the new macro calls AC_PREREQ(2.64) -- a more stringent requirement than the existing AC_PREREQ(2.59) in configure.in. The difference represents about six years of autoconf releases, from v2.59 in December of 2003 to v2.64 in July of 2009. This problem was noticed by Brian Evans, who also suggested the fix. PHP-Bug: 73062
-rw-r--r--acinclude.m418
-rw-r--r--configure.in18
2 files changed, 22 insertions, 14 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 3eb0f1e914..516e0e4a2e 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -3231,3 +3231,21 @@ AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [
[$have_builtin_ssubll_overflow], [Whether the compiler supports __builtin_ssubll_overflow])
])
+
+dnl This macro hails from the autoconf archive. This revision is
+dnl from 2015-01-06.
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+ AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+ [AS_VAR_SET(CACHEVAR,[yes])],
+ [AS_VAR_SET(CACHEVAR,[no])])
+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/configure.in b/configure.in
index de68932ca1..a83e5f469c 100644
--- a/configure.in
+++ b/configure.in
@@ -285,20 +285,10 @@ case $host_cpu in
;;
esac
-dnl activate some gcc specific optimizations for gcc >= 4
-if test "$GCC" = "yes"; then
- case $host_alias in
- *darwin*)
- GCC_MAJOR_VERSION=`$CC -dumpversion | /usr/bin/sed -nE '1s/([[0-9]]+)\.[[0-9]]+\..*/\1/;1p'`
- ;;
- *)
- GCC_MAJOR_VERSION=`$CC --version | $SED -n '1s/[[^0-9]]*//;1s/\..*//;1p'`
- ;;
- esac
- if test $GCC_MAJOR_VERSION -ge 4; then
- CFLAGS="$CFLAGS -fvisibility=hidden"
- fi
-fi
+dnl Mark symbols hidden by default if the compiler (for example, gcc >= 4)
+dnl supports it. This can help reduce the binary size and startup time.
+AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],
+ [CFLAGS="$CFLAGS -fvisibility=hidden"])
case $host_alias in
*solaris*)