This requirements bump should rarely affect anybody in practice. All
major distros already ship more recent ICU versions, and even for
Solaris 11, ICU 57.1 is available via OpenCSW. Note that ICU 57.1 has
been released on 2016-03-23[1].
[1] <https://icu.unicode.org/download/57>
Closes GH-16688.
Adding two exit early safeguards in the *nix configuration build script:
1) Given the initial cd into the build tree fails (the project root),
the `buildconf` script exits with non-zero status (failure).
2) Given the grep command does not exist or `configure.ac` AC_INIT [1]
expectations are unmet, the buildconf script exits non-zero.
Additionally quoting the pathname to cd into and the empty CD_PATH
parameter for portability, also for systems that are using a
non-portable pathname [2] for the build tree.
The initial CD safeguard has been applied to the `buildconf` and
four more scripts:
- build/genif.sh
- scripts/dev/credits
- scripts/dev/genfiles
- scripts/dev/makedist
Rationale:
Cd-ing into the project root should always prematurely exit w/ FAILURE
as a required precondition for its invocation has not been met. This
should never go unnoticed as it always requires user intervention.
Similar and more specifically to the PHP build on *nix systems, the
grep command is required early to obtain the `php_extra_version` from
configure.ac. Previously, if the grep command is missing (or failing
due to not matching the line with the AC_INIT macro [1]), the internal
dev parameter would always be zero (0) which can easily result in the
situation that the configure script is not being rebuilt. This is
cumbersome as the rebuild of a configure script is more likely required
with checked-out dev versions under change rather than an already
properly set-up build environment on a dedicated build or release
system. Missing the fact that either the grep utility is missing or
the expectation of having the AC_INIT macro in configure.ac is unmet
should never go unnoticed as it always requires user intervention.
[1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Initializing-configure.html
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271
Closes GH-16717.
A tentative return type is used to allow userland code that overrides a method
to not include a typehint without a fatal error; this is inapplicable to final
methods (including all methods of final classes), which cannot be overridden.
Remove the tentative return declarations, and update the build script to
complain about future additions.
Instead of allocating, using, and then releasing a zend_string for every
property name unconditionally, only do so when the minimum supported version of
PHP does not have that string in its known strings (ZEND_KNOWN_STRINGS). If the
string is already known, just use the known version directly. This is already
done for some non-generated class registrations, e.g. in
`zend_enum_register_props()`.
To match other capitalized strings like `ZEND_STR_UNKNOWN_CAPITALIZED` and
`ZEND_STR_ARRAY_CAPITALIZED`. Since this known string was only added in PHP
8.4, no backwards compatibility alias is needed.
The PHP_BUILD_THREAD_SAFE macro is a simple wrapper around setting the
enable_zts variable and can't be used in PHP extensions realistically.
The PHP_TEST_BUILD macro might produce warnings on certain compiler
configurations and default AC_* macros like AC_LINK_IFELSE,
AC_CHECK_LIB, or AC_CHECK_FUNC are better suited for such checks. Also,
a quick browse through the open-source PHP extensions doesn't find
usages of this macro except in imap extension where patch is was already
sent:
https://github.com/php/pecl-mail-imap/pull/11
PHP_DEF_HAVE is a wrapper around AC_DEFINE and using AC_DEFINE_UNQUOTED
and AS_TR_CPP are better suited for this task where also help text can
be passed. Usages in the open source PHP extensions have been checked and
patches sent where found.
The apxs -q HTTPD_VERSION variable is available since Apache 2.4.17.
This change obsoletes the PHP_AP_EXTRACT_VERSION macro and checks the
version in the config.m4 file directly. Version is checked against the
dotted format instead of the version number.
This enables adding multiple include paths. For example:
PHP_ADD_INCLUDE([
$abs_srcdir
$abs_builddir
$abs_srcdir/main
$abs_builddir/main
], [1])
The 2nd argument "prepend" is now validated at Autoconf compile time
instead of the configure time.
This wraps checks in AC_CACHE_CHECK and replaces the "uname -sr" command
with simpler $host_alias as it is already set by the config.guess script
properly.
When functions' or class methods' availability is based on some preprocessor
condition, the generated arginfo header files wrap the declarations in the
preprocessor `#if` conditional blocks, one per declaration, even if they are in
the same conditional block based on comments in the stub file. Instead of
having multiple conditional blocks one after the other with the same condition,
combine them into a single conditional block.
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
This is a follow up of 7edb9a07d7 that
provides passing compilation options to PHP_NEW_EXTENSION,
PHP_ADD_SOURCES, PHP_ADD_SOURCES_X, and PHP_SELECT_SAPI as a
blank-or-newline-separated argument.
This is a follow-up of previous backticks replacement commits. This
replaces backticks command substitutions in remaining ext config M4
files, phpize, and configure.ac with the recommended $(...).
Note that $(...) still does not work on some obsolete shells that ship
with Solaris 10, for example. Elsewhere they should work. However, for
these obsolete shells Autoconf also re-executes the shell script under
the supported shell so it can make them work regardless.
Additionally, few comments CS are also adjusted to not cause confusion
when searching for backticks usages and one indentation sync done.
As of Autoconf 2.72 the backticks in macro help texts are also replaced
with single quotes.
By using `m4_normalize(m4_expand([...]))`, the arguments can be split
into newlines without using backslashes and it makes working with lists
of files a bit easier.
Tested:
- variables inside the argument
- M4 macro expansions
- dnl comments
- any sequence of newlines, backslash-then-newline, multiple spaces,
tabs...
- quoted/unquoted arguments
This now works for PHP_NEW_EXTENSION, PHP_ADD_SOURCES, PHP_ADD_SOURCES_X,
and PHP_SELECT_SAPI. The m4_normalize() usage is left in the php-src
config.m4 files following the 0a0d2d0631
for PECL extensions until phpize will be available on all supported
versions (minimum PHP 8.4).
The m4_normalize(m4_expand([$1])) expands the given argument if it
contains M4 macros, and then trims the items together into a space
separated string in an intuitive way.
The m4_normalize(m4_expand([...])) simplifies working with a list of
header files. The m4_normalize() is at this point still used in the
php-src config.m4 files because of copy/paste probability to community
extensions where the arguments still need to be done in the old style to
support phpize in PHP-8.3 and earlier. For example:
PHP_INSTALL_HEADERS([ext/dom], m4_normalize([
dom_ce.h
namespace_compat.h
xml_common.h
xpath_callbacks.h
]))
When PHP 8.4 will be the minimum supported PHP version, the headers can
be installed without using m4_normalize() in PECL extensions. For
example:
PHP_INSTALL_HEADERS([ext/dom], [
dom_ce.h
namespace_compat.h
xml_common.h
xpath_callbacks.h
])
This is useful to reduce the memory usage of objects that don't actually
use the backing storage. Examples are XMLReader and DOM. When the
properties were added to the stubs, these objects became much much
bigger, which is a waste of memory.
Closes GH-11644.
Work towards GH-13988.
Currently, internal classes are registered with the following code:
INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;
This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.
The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
The xmlDictPtr was moved before the includes in libxml2 2.9.4 so the
<libxml/dict.h> can be included directly but for earlier versions the
<libxml/tree.h> needs to be included before. Since PHP requires libxml2
2.9.0 or later and this also fixes builds on Solaris 10.
As earlier 2.9.0-2.9.3 libxml2 versions also include several security
issues, this change bumps the required minimum libxml2 version to 2.9.4
On Windows, a check for minimum libxml2 version is also added.
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
This makes a bit simpler to use this macro by optionally passing the
required minimum PHP version. If version is not passed it falls back
to 7.4 as before. Minimum version also added to configure.ac.
This syncs the abs_srcdir and abs_builddir variables assignments between
the php-src build and phpize. The `&&` was picked over `;` as it is more
rigorous - the pwd command would fail if cd fails for some reason.
The "hacky" auto_cflags variable is otherwise set only for the Oracle
Developer Studio compiler (which is at this point also non-usable) and
perhaps might be removed in the future but this is for now moved to the
PHP_INIT_BUILD_SYSTEM for consistent settings between the php-src build
and phpize.
The PHP_INIT_BUILD_SYSTEM is now also called sooner in phpize to match
the php-src build.
The libtool bundled with PHP is outdated and deletes *.gcno files used by
gcov during the build process.
While this issue has already been resolved upstream [1], incorporating the
fix at this point may not be practical. Therefore, we attempt to apply a
fix to the current version.
This change will enable proper coverage output for third-party PHP
extensions.
[1]: https://github.com/autotools-mirror/libtool/blob/master/NEWS#L605
This uses AS_* macros and checks for an iconv implementation in a single
cache check block for easier configure log output and possible future
adjustments when iconv is built-in the C library (like on Alpine and
some other systems where it isn't recognized as such yet exactly).
This syncs few minor left-overs in "Autotools" related files:
- redundant middle newlines removed (in man pages the duplicate newlines
are also ignored and are not visible in the man page anyway)
- Minor mixed indentation synced
[skip ci]