Use AX_CHECK_COMPILE_FLAG macro to check for -fvisibility=hidden #2124
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The existing check for
-fvisibility=hidden
support came from a timewhen only GCC had it. The test for it used a regular expression to
parse the GCC major version from the output of
$CC --version
, andwould 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, theCC
variable can be set tosomething 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 stringentrequirement than the existing
AC_PREREQ(2.59)
in configure.in. Thedifference 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