Using the m4_normalize, the source files can be added more intuitively
using blank-or-newline delimited list of files. This adds also some
basic help text.
Quoted m4_normalize will expand and change its argument later in the
macro call when M4 is processing the *.m4 sources. Without quotes the
already normalized string is passed to the macro directly. In these
specific cases generated configure script is the same. This is more for
consistency to have this synced and not repeat the pattern too much
in the future when copy/pasting. Note, that many AC_* macros require
similar behavior already (for example, AC_CHECK_FUNCS.)
- ZEND_EXTRA_LIBS holds all possible libraries appended during the
checks related to Zend.m4, moved after the ZEND_INIT check to make it
more clear, redundant double quotes removed;
- EXTRA_LIBS has already been populated above in the configure.ac
- redundant 'unset LIBS' removed
Cachegrind supports cg_annotate --diff, which makes it much easier to compare
the performance of two patches.
Co-authored-by: Peter Kokot <peterkokot@gmail.com>
As this script is still needed across the PHP build system its path can
be also set on once place for both phpize usage and regular php-src's
configure.ac.
This creates a single M4 macro PHP_CHECK_BUILTIN and removes other
PHP_CHECK_BUILTIN_* macros. Checks are wrapped in AC_CACHE_CHECK and
PHP_HAVE_BUILTIN_* CPP macro definitions are defined to 1 if builtin
is found and undefined if not.
This also changes all PHP_HAVE_BUILTIN_ symbols to be either undefined
or defined (to value 1) and syncs all #if/ifdef/defined usages of them
in the php-src code. This way it is simpler to use them because they
don't need to be defined to value 0 on Windows, for example. This is
done as previous usages in php-src were mixed and on many places they
were only checked with ifdef.
OpenSSL versions before 0.9.7 provided its own crypt() function (and
des_* functions) in its Crypto library that interfered with the
implementation relying on crypt() from some other crypt library. This is
at this point obsolete as crypt and other functions that caused clashes
were removed in OpenSSL version 1.1.0.
In OpenSSL 0.9.7 des_old.c and des_old.h files were provided for BC.
In OpenSSL 0.9.8 crypt() function was renamed to _ossl_old_crypt and the
crypt macro definition was commented out in the des_old.h header.
In OpenSSL 1.1.0 the old DES API was removed, meaning OpenSSL's crypto
library no longer provides crypt() function as it used to.
References:
- Some further historic notes on this:
https://www.openldap.org/faq/data/cache/1041.html
- OpenSSL Git commit history and changelogs
This uses AC_CONFIG_COMMANDS macro to conditionally output the warning
message at the end of configure phase if non-threaded Apache
installation has been found and PHP is built without --enable-zts.
Variables set in the 2nd argument (init-cmds) are for the command
invocation scope as the first argument doesn't have any knowledge of
configure variables as described in the Autoconf docs.
This is moved as it is related only to apache2handler SAPI and also
now warning is displayed a bit nicer at the end of the configure phase
after files are generated. This also enables outputting warning when
using config.status script.
This removes the unused DEBUG_CFLAGS variable from configure.ac. It has
been once set in the build files similarly to Zend.m4 but was then
removed and simplified.
CS synced and DEBUG_CFLAGS checked and appended with AS_VAR_* macros.
AS_VAR_SET_IF doesn't behave the same as "test -n" and/or "test -z",
which becomes an issue for Apache's ZTS automatic enabling and CFLAGS
edge case where it would be explicitly set to empty value. It is safer
to use AS_VAR_IF instead of AS_VAR_SET_IF in these cases.
Apache 2.2 has been marked as EOL in December 2017 and doesn't receive
security patches any longer. Also, most *nix distributions and packages
mostly support 2.4 as minimum by now.
On Windows, this removes the configure option --enable-apache2-2handler
and merges the --enable-apache2handler and --enable-apache2-4handler
into a single option with favoring the --enable-apache2handler.
- The upstream MODULE_MAGIC_NUMBER is deprecated in favor of
MODULE_MAGIC_NUMBER_MAJOR in apache2/ap_mmn.h
- The initial upstream MODULE_MAGIC_NUMBER_MAJOR was 20111025 in Apache
2.4.0
- The upstream APLOG_USE_MODULE is always available since Apache 2.3.6
- The upstream CORE_PRIVATE is unnecessary and ignored since Apache
2.4.0
See:
https://forum.apachehaus.com/news-general-discussion/apache-2-2-users-your-time-is-running-out/
Discussion: https://news-web.php.net/php.internals/124067
The PTHREADS_CHECK is using cache variables so it is run only once early
during the configuration phase, before including SAPI and other M4
files. This removes the TSRM_CHECK_PTHREADS macro and moves the POSIX
Threads check after the PHP_THREAD_SAFETY variable is set in
configure.ac.
The check and error throw in PHP_BUILD_THREAD_SAFE is also joing into
this single check.
This removes the redundant tsrm.m4 file and PHP_CONFIGURE_PART call for
TSRM as it doesn't run any configuration checks anymore.
- This syncs Autoconf syntax with AS_VAR_* macros in phpize and
configure.ac
- The cross-compiling check synced with configure.ac (the check message
printed after program check message)
- Some redundant quoting removed
When configuring PHP with:
./configure --with-valgrind and --enable-address-sanitizer
configuration now errors now since these two are not compatible
configurations.
- Configure option and check grouped together for readability
- Cache variable ac_cv_ipv6_support renamed to php_cv_have_ipv6
- AS_VAR_IF used and CS synced
- Over-quoted argument reduced
- Synced CS: AS_VAR_IF style checks and M4 macro arguments quoted
- Error message normalized without checking other errors appended (once
more dependencies were required and additional error messages were
appended)
- All arguments quoted
- PHP_VERSION, PHP_VERSION_ID, PHP_LDFLAGS are used only in templates
with @...@ placeholders
- These are not used in generated Makefile neither in templates:
abs_builddir, abs_srcdir, DEBUG_CFLAGS
- These are used only in generated Makefile: EXTRA_LDFLAGS,
EXTRA_LDFLAGS_PROGRAM, ZEND_EXTRA_LIBS, INCLUDES, EXTRA_INCLUDES,
INSTALL_IT, NATIVE_RPATHS
When Valgrind is enabled and not found on the system, default error can
be thrown by PKG_CHECK_MODULES instead of writing a manual error step.
- This uses less redundant variables and has synced CS.
- AS_VAR_IF used instead of raw shell ifs
- Added some basic help descriptions for macro definitions
The m4_normalize is for Autoconf < 2.70 (on 2.70 and later versions a
blank-or-newline separated items can be expanded without using
backslash-newline). The order of headers in configure.ac is left as is
because the first few headers depend on checking other headers (for
those includes the 4th argument).
The sys/sdt.h is required header when using DTrace, HAVE_DTRACE can be
defined together when initializing and PHP_DTRACE_OBJS can be
substituted to simplify the macro usage a bit further.
The m4_normalize is for Autoconf < 2.70 (on 2.70 and later versions a
blank-or-newline separated items can be expanded without using
backslash-newline).
This also syncs the 1st argument quotes.
* Include from build dir first
This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.
Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :
-I$(top_builddir)/main
-I$(top_srcdir)
-I$(top_builddir)/TSRM
-I$(top_builddir)/Zend
-I$(top_srcdir)/main
-I$(top_srcdir)/Zend
-I$(top_srcdir)/TSRM
-I$(top_builddir)/
As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.
After this change, the include path is defined as follows:
-I$(top_builddir)/main
-I$(top_builddir)
-I$(top_srcdir)/main
-I$(top_srcdir)
-I$(top_builddir)/TSRM
-I$(top_builddir)/Zend
-I$(top_srcdir)/Zend
-I$(top_srcdir)/TSRM
* Fix extension include path for out of tree builds
* Include config.h with the brackets form
`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.
Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
Since Autoconf >= 2.70 the _GNU_SOURCE and some other extensions are
defined unconditionally regardless whether the __EXTENSIONS__ can be
safely defined. Some obsolete Solaris systems once had issues with
compiling a default set of standard system headers when __EXTENSIONS__
was defined. Autoconf 2.69 and earlier checked based on that and defined
the _GNU_SOURCE conditionally. This condition is not relevant on current
systems anymore.
When the computed goto extension is available to optimize conditional
jumps, option --enable-re2c-cgoto adds the -g flag to re2c.
In this case the AC_LANG_SOURCE is used instead of the AC_LANG_PROG to
not wrap the compilation check program in another main() function. Code
is also simplified and help messages updated. This is a
compiler-agnostic extension, not only available with GCC.
When the check is successful, the -g is added, otherwise not.
The --no-generation-date flag is a common re2c flag used in all re2c
invocations. This adds the 2nd optional argument to PHP_PROG_RE2C M4
macro in BC manner to set the default re2c command-line options and sets
the default RE2C_FLAGS similarly on Windows.
This fixes -Wundef warnings present where SHADOW_STACK_SYSCALL should
be defined to value 0 and refactors the check with cache variable
php_cv_have_shadow_stack_syscall. The SHADOW_STACK_SYSCALL CPP macro
definition is removed from php_config.h in favor of a compilation
definition on asm files and Zend engine files.
This enables cross-compiling edge cases to override checks with
php_cv_have_common_page_size and php_cv_have_max_page_size cache
variables when target matches one of the conditions in case pattern.
Not done as link check yet due to Clang 9 bug and similar issues:
https://github.com/php/php-src/pull/5123
By default compilers may not treat attribute warnings as errors when
encountering an unknown __attribute__, unless some error option is
provided (-Werror=attributes, -Werror=unknown-attributes, -Werror...).
This fixes the check and wraps it into a separate M4 macro to be
extendable in the future if needed. It checks if conftest.err file was
generated by the compilation check when warnings appear. Also, PHP check
is a bit customized by using __alignof__ keyword, so it is left in there
for now to not break existing checks.
This reduces -Wunused-variable and -Wunused-but-set-variable warnings
generated in the Autoconf's config.log to comply with possible stricter
default compiler configuration on the system to avoid having false
results.
The socketpair():
* C library: Solaris 11.4 and most other systems
* libsocket: Solaris <= 11.3 and illumos
* libnetwork: Haiku
The gethostname() check is moved to AC_CHECK_FUNCS:
* C library: most systems
* libnsl: none
* libnetwork: Haiku (which is already checked in the libraries section)
The gethostbyaddr():
* C library: most systems, Solaris 11.4
* libnsl: Solaris 11.3, illumos
* libnetwork: Haiku
This also removes redundant unused symbols:
- HAVE_GETHOSTBYADDR
- HAVE_LIBNETWORK
- HAVE_LIBNSL
The outdated comment about -lnsl and -lsocket linking has been removed
because these systems are long not supported anymore and this issue is
not relevant anymore like mentioned. The initial solution was different
than the one with the PHP_CHECK_FUNC macros at the current versions.
See commit a188fac946 where the
gethostbyaddr() was checked conditionally based on the gethostname()
availability in libc. Main issue was mostly related to the redundant nsl
library being always linked because of the AC_CHECK_LIB.
When not using --with-pear configure option, the Makefile doesn't need
the PEAR_INSTALLDIR variable. Also, this variable isn't directly
substituted using the @PEAR_INSTALLDIR@ in any template, so the
PHP_SUBST can be used.
The PHP_SUBST_OLD adds variables to generated Makefile and creates
output shell variables to replace the @variable_name@ placeholders in
templates. These changed variables are not used in the generated
Makefile so the AC_SUBST is sufficient.
- ext/odbc
- sapi/embed
- sapi/fpm
- only substituted in scripts/php-config.in:
- PHP_INSTALLED_SAPIS
- SAPI_LIBNAME_SHARED
- SAPI_LIBNAME_STATIC
This inlines .gdbinit and php_gdb.py in the .debug_gdb_scripts section of the PHP binary so that GDB can auto-load them regardless of the current directory or the availability of the PHP source code (albeit some functionalities of php_gdb.py currently rely on the source being available).
This adds all root build directories in one call. PEAR directory is
created only when enabled and duplicated Zend directory creation is
removed, because it was intended for the zend_config.h when building
out-of-source or using the config.status manually before the
PHP_ADD_BUILD_DIR was introduced in the build system.
And make locatable by via `php-config`. Prior to this, `libphp.*`
would always install to `$prefix/lib`. After this, they will install
to `$libdir`.
In practice, this will make it so that programs embedding libphp can
use `php-config` to determine appropriate compile flags without
guessing.
In `configure.ac`, it seems `$libdir` is mutated in some instances.
Ideally the mutated version would be stored in `$phplibdir` or
something. Instead of tracking down all uses of that variable, I
introduced another variable `$orig_libdir` that holds the original
value passed to the configure script.
This is a no-op for users unless they are compiling with `--libdir`
set to something other than `$prefix/lib`, the default.
Closes GH-12389
Shared objects of extensions during the *nix build are copied to the
`modules` directory. It is a practice established since the early days
of the PHP build system. Other build systems may have similar concept of
"library destination directory". On Windows, they are put into the root
build directory. Such directory simplifies collection of the shared
extensions during testing, or when running the cli executable at the end
of the build process.
This change ensures that the directory is consistently created in a
single location, for both the primary PHP build process and when
utilizing `phpize` within community extensions.
The AC_CONFIG_COMMANDS_PRE is executed at the end of the configuration
phase, before creating the config.status script, where also build
directories and global Makefile are created.
The pwd is executed using the recommended $(...) instead of the obsolete
backticks. Autoconf automatically locates the proper shell and
re-executes the configure script if such case is found that $(...) is
not supported (the initial /bin/sh on Solaris 10, for example).
autoconf/libtool generating code to test features missed `void` for
C calls prototypes w/o arguments.
Note that specific changes related to libtool have to be upstreamed.
Co-authored-by: Peter Kokot <petk@php.net>
close GH-13732
The non-standard major(), minor(), and makedev() can be defined as
macros. These are usually used together with the Autoconf macro
AC_HEADER_MAJOR, which defines the MAJOR_IN_MKDEV if sys/mkdev.h is
available, or MAJOR_IN_SYSMACROS if sys/sysmacros.h is available.
On Solaris/illumos they are in the sys/mkdev.h header (macro defined to
libc implementation) and in sys/sysmacros.h (macro defined with binary
operators and bits shifting). On systems with musl and glibc 2.28 or
later they are defined in sys/sysmacros.h, in glibc 2.27 and earlier
they were in sys/types.h. On BSD-based systems and macOS they are in the
sys/types.h.
Autoconf 2.70 has fixed the AC_HEADER_MAJOR macro, so it detects the
headers properly due to glibc 2.25 throwing deprecation warnings when
using the macros from sys/types.h. With Autoconf 2.69 and earlier the
ac_cv_header_sys_types_h_makedev cache variable can skip the
improper sys/types.h check in the macro.
This change syncs the usage within the ext/fileinfo/libmagic bundled
library and ext/posix.
When sys/mkdev.h header is available, code includes that, otherwise
it conditionally includes the sys/sysmacros.h. The ext/posix has
additional check whether linker sees the makedev, otherwise it checks
if makedev is declared within the given set of headers accoring to the
AC_HEADER_MAJOR logic. Previously the AC_CHECK_FUNCS didn't detect it.
The '__asm__ goto' support is properly recognized by a simpler linking
check instead of a run check for easier cross-compilation. The
compile only check (AC_COMPILE_IFELSE) might produce false positives
results with certain compiler options.
This was tested on OpenBSD sparc64 and all fiber related tests pass.
On OpenBSD stackghost prevents the modification of the return address
and therefor an extra trampoline is needed in make_fcontext(). This
should not matter on other OS implementing sysv ABI and the trampoline
should work there as well.
Close GH-13382.
Solaris/illumos systems have socket() in the socket library, Haiku has
it in network, Windows in ws2_32, and other systems in libc. This also
removes redundant and unused HAVE_SOCKET symbol.
The memmove() function is C99 standard function [1] and check was left for
the PCRE2 bundled library. It can be simplified by passing the compile
option instead of checking always available function on current systems.
External PCRE2 library on the system doesn't need this.
[1]: https://port70.net/~nsz/c/c99/n1256.html#7.21.2.2
The htonl() function is available in libc on current *nix systems. On
Solaris versions around 2.5.1 it was located in the socket library.
Haiku has it in libc and Windows in ws2_32, which is linked as part of
the common libraries. This removes the redundant HAVE_HTONL symbol.
This moves memfd_create (HAVE_MEMFD_CREATE) to configure.ac. Since
ext/pcre is always enabled and check can be done in this case for
ext/pcre and ext/opcache at once.
This prepends -lnetwork as needed (Haiku) whether linker sees the
setsockopt function and avoids defining redundant symbols, such as
HAVE_LIBNETWORK and HAVE_SETSOCKOPT.
For Solaris/illumos systems, in this case, the check can be done using
AC_SEARCH_LIBS, which avoids defining redundant symbols like HAVE_PGRAB
and HAVE_LIBPROC.
The nanosleep() is mostly found in libc, except on systems, such as
Solaris <= 10 or the discontinued OpenSolaris, it is in the rt library.
This checks if nanosleep() exists in the libc, then it checks if rt
library has nanosleep, prepends it to LIBS and defines the
HAVE_NANOSLEEP symbol with the template from the AC_CHECK_FUNCS.
On some systems (Haiku) the math library is part of the C library and it
doesn't need to be explicitly prepended to LIBS. The redundant HAVE_LIBM
symbol defined by the AC_CHECK_LIB has been removed.
AC_SEARCH_LIBS can be used to check for dlopen and if dl library needs
to be prepended to LIBS. The dlsym is available with the same scope as
dlopen (if dlopen is present, also dlsym is). The redundant HAVE_DLOPEN
and HAVE_DLSYM symbols have been removed.
The AC_CHECK_FUNCS checks whether the linker sees the function in the
usual libraries, in this case libc. This is a simple trick to also check
existence of belonging headers, since the code uses HAVE_PRCTL and
HAVE_PROCCTL to include headers and call functions.
This removes the redundant check that defines the HAVE_STDINT_H symbol,
which is used in the ext/date/lib and ext/fileinfo/libmagic but on both
places patches and other header files take care of this so it is always
included unconditionally in php-src.
Autoconf by default still automatically checks for stdint.h internally
in current versions, so for now the HAVE_STDINT_H symbol is still
defined in php_config.h and will be made redundant along the way.
This removes the deprecated malloc.h header Autoconf check on *nix
systems and its HAVE_MALLOC_H symbol. It can be replaced mostly with the
stdlib.h. The libgd usptream also doesn't include it anymore.
On Windows, it is still used for some memory allocation functions, but
can be replaced with stdlib.h in the future.
Instead of the project macro, the sockaddr_storage and sockaddr.sa_len
can be checked with the AC_CHECK_TYPES and AC_CHECK_MEMBERS by including
the sys/socket.h. Some systems (~1988) didn't include the sys/types.h in
the socket.h (obsolete on current systems).
These macros by default define the HAVE_STRUCT_SOCKADDR_STORAGE and
HAVE_STRUCT_SOCKADDR_SA_LEN.
The struct flock is defined in fcntl.h, if system has it. This removes
redundant PHP_STRUCT_FLOCK M4 macro in favor of the AC_CHECK_TYPES,
which by default defines symbol HAVE_STRUCT_FLOCK.
PHP_DEFINE was introduced with the PHP 5 build system
9d9d39a0de and then refactored via
350de12bc2.
This was once used to put defined constants into a single file to have
more fine-graned dependencies (atomic includes). Since no known PHP
extension is using this and it makes very little sense to use this, this
M4 macro can be removed in favor of the Autoconf native way using
AC_DEFINE and the usual included files php_config.h and config.h.
- Generated unused include directory removed
- Remove include dir from DEFS
- Remove also include dir from PDO checks