Commit Graph

840 Commits

Author SHA1 Message Date
Arnaud Le Blanc
c21899a9f0
Merge branch 'PHP-8.3'
* PHP-8.3:
  Do not remove -O0 in the middle of a flag
  Fix removal of optimization cflags in debug builds (#9647)
2024-09-12 13:12:51 +02:00
Arnaud Le Blanc
be1bf3f35e
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Do not remove -O0 in the middle of a flag
  Fix removal of optimization cflags in debug builds (#9647)
2024-09-12 13:11:49 +02:00
Arnaud Le Blanc
c639614346
Do not remove -O0 in the middle of a flag
Fixes GH-15826
Closes GH-15828

Co-authored-by: Peter Kokot <petk@php.net>
2024-09-12 13:08:54 +02:00
DanielEScherzer
db545767e5
Rename ZEND_STR_DEPRECATED to ZEND_STR_DEPRECATED_CAPITALIZED (#15831)
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.
2024-09-10 22:45:23 +01:00
Peter Kokot
16e218a596
Autotools: Obsolete PHP_TEST_BUILD, PHP_BUILD_THREAD_SAFE, and PHP_DEF_HAVE (#15802)
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.
2024-09-08 21:09:48 +02:00
Peter Kokot
b97a60c9a3
Autotools: Check Apache version with apxs and HTTPD_VERSION variable (#15476)
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.
2024-09-08 20:13:48 +02:00
Peter Kokot
6d6bf0530a
Autotools: Enable adding a list of paths in PHP_ADD_INCLUDE (#15777)
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.
2024-09-08 06:57:31 +02:00
Peter Kokot
94ecc1fe7d
Autotools: Sync CS for PHP_PWRITE_TEST and PHP_PREAD_TEST (#15774)
- AS_* macros used
- Arguments quoted
- Cache variable ac_cv_pread renamed to php_cv_func_pread
- Cache variables ac_cv_pwrite renamed to php_cv_func_pwrite
2024-09-07 11:53:35 +02:00
Peter Kokot
e0e6d326e2
Autotools: Sync CS in PHP_PROG_AWK (#15772)
- AS_* macros used
2024-09-06 12:10:50 +02:00
Peter Kokot
418329226a
Autotools: Sync CS in php.m4 (#15771)
- AS_* macros used
2024-09-06 09:31:52 +02:00
Peter Kokot
bcbf7bea92
Autotools: Replace uname with host_alias for finding Solaris (#15770)
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.
2024-09-06 08:44:10 +02:00
Peter Kokot
aebe63dd0f
Autotools: Sync CS for PHP_RUNPATH_SWITCH (#15768)
- AS_VAR_IF macros used
- AC_CACHE_VAL and AC_MSG_CHECKING replaced with AC_CACHE_CHECK
- arguments quoted
2024-09-06 08:41:09 +02:00
Peter Kokot
035b0c50bc
Autotools: Sync CS in PHP_EVAL_LIBLINE (#15737)
- AS_* macros used
- arguments quoted
- redundant quotation of variable-variable simplified from [$]$2 to $$2
  (see Autoconf documentation)
2024-09-04 23:27:20 +02:00
DanielEScherzer
5dd0575698
Generated arginfo header files: combine preprocessor conditional blocks (#15736)
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.
2024-09-04 13:04:22 +02:00
DanielEScherzer
53cb89670c
Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
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.
2024-09-03 23:19:53 +02:00
Peter Kokot
1a126c540a
Autotools: Normalize flags arguments (#15671)
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.
2024-09-01 01:02:40 +02:00
Peter Kokot
75c797492b
Autotools: Replace backticks with $(...) in php.m4 (#15642)
This is a follow-up of GH-15639
2024-08-30 23:32:42 +02:00
Peter Kokot
1b757c8d3c
Autotools: Replace backticks command substitutions with $(...) (#15639)
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.
2024-08-30 00:40:49 +02:00
Peter Kokot
0a6019a7d6
Autotools: Use SED variable for sed command (#15641)
This syncs sed usages across the build system as SED variable is set to
a suitable sed program on the system.
2024-08-29 23:46:04 +02:00
Peter Kokot
7e1e450bb9
Autotools: Remove redundant double quotes (#15634) 2024-08-29 15:17:03 +02:00
Peter Kokot
7edb9a07d7
Autotools: Normalize 2nd arg in PHP_ADD_SOURCES_X (#15088)
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).
2024-08-29 02:40:18 +02:00
Peter Kokot
fbacc0f936
Autotools: Normalize PHP_ADD_BUILD_DIR 1st argument (#15612)
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.
2024-08-29 00:44:29 +02:00
Peter Kokot
0a0d2d0631
Autotools: Normalize PHP_INSTALL_HEADERS arguments (#15620)
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
    ])
2024-08-28 23:08:53 +02:00
Niels Dossche
f78d5cfcd2 Allow ZEND_ACC_VIRTUAL to be used to not have property backing storage without resorting to hooks
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.
2024-08-26 21:17:49 +02:00
Máté Kocsis
8d12f666ae
Fix registration of internal readonly child classes (#15459)
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.
2024-08-24 12:36:54 +02:00
Peter Kokot
dc8f18af0b
Fix GH-15534: Bump minimum libxml2 version to 2.9.4 (#15536)
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>
2024-08-23 23:14:38 +02:00
Peter Kokot
c79e723725
Autotools: Check re2c version with AS_VERSION_COMPARE (#15465)
This simplifies the version check a bit.
2024-08-22 17:39:03 +02:00
Peter Kokot
1b3c204033
Autotools: Add min-version argument to PHP_PROG_PHP macro (#15477)
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.
2024-08-22 17:30:08 +02:00
Peter Kokot
4e193b4113
Autotools: Move abs_srcdir and abs_builddir to init macro (#15537)
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.
2024-08-22 16:26:48 +02:00
Peter Kokot
40217b2ea4
Autotools: Move auto_cflags marker to PHP_INIT_BUILD_SYSTEM (#15487)
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.
2024-08-19 22:29:20 +02:00
Peter Kokot
dffe25bd19
Autotools: Move AWK finder to PHP_INIT_BUILD_SYSTEM (#15478)
This calls the PHP_PROG_AWK from a single place for php-src build and
phpize.
2024-08-18 13:30:03 +02:00
Go Kudo
d6afe05380
libtool: Don't remove gcov *.gcno files (#15441)
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
2024-08-16 18:18:25 +02:00
Peter Kokot
8853cf3ae9
Autotools: Add note about PHP_ADD_EXTENSION_DEP usage
Until the AWK regex is implemented better, this macro must be called on
its own line with unquoted arguments.

[skip ci]
2024-08-15 16:40:23 +02:00
Gina Peter Bnayard
d100caa476 [skip ci] Add NEWS/UPGRADING + wording amendment for GH-13483 2024-08-14 13:52:19 +02:00
Gina Peter Banyard
a79c70f574
[RFC] Convert exit (and die) from language constructs to functions (#13483)
RFC: https://wiki.php.net/rfc/exit-as-function
2024-08-14 12:44:12 +01:00
Peter Kokot
540b9f5bc7
Autotools: Wrap long texts with m4_text_wrap (#15368)
The m4_text_wrap macro wraps the text into a single space separated
string which is wrapped to not exceed the line lenght of 79 characters
by default.
2024-08-13 10:33:17 +02:00
Peter Kokot
6cb6cc6f74
Autotools: Refactor iconv implementation checks (#15357)
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).
2024-08-12 14:43:24 +02:00
Peter Kokot
9fcc1bca8a
Remove redundant middle newlines in "Autotools" related files
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]
2024-08-12 13:18:32 +02:00
Peter Kokot
36f6a20a6b
Autotools: Quote AC_CHECK_PROG* macro arguments
[skip ci]
2024-08-09 10:27:04 +02:00
Peter Kokot
84e1920c12
Autotools: Add phpized configure log and help separators (#15251)
- This quotes all PHP_CONFIGURE_PART arguments
- When configuring and building extensions with phpize, this makes the
  './configure --help' and './configure' log output a bit more readable
  as it separates the extension configuration, Libtool configuration and
  the rest of the Autoconf and phpize configuration options.
- The ./configure output separators bold tags are moved to the
  PHP_INIT_BUILD_SYSTEM macro to be available also in phpized extensions
- The obsolete ticks `...` converted to the recommended $(...); Autoconf
  configure re-executes itself in shells where the $(...) still wouldn't
  work ok. For example, the default, initial, non-updated shell on
  Solaris 10.
- Empty new lines in help separators synced (Autoconf default separators
  don't include additional empty newline after the separator title);
  so the PHP_HELP_SEPARATOR additional empty line is also removed
  (see './configure --help' output)
2024-08-06 22:15:22 +02:00
Peter Kokot
dcdcb3cbfe
Autotools: Replace AC_MSG_ERROR with AC_MSG_FAILURE (#15209)
This replaces the AC_MSG_ERROR with AC_MSG_FAILURE, where appropriate.

The AC_MSG_ERROR outputs given message and exits the configure step. The
AC_MSG_FAILURE does the same but also automatically outputs additional
message "See 'config.log' for more details." which might help directing
the user where to look further.

The AC_MSG_ERROR is used for errors where current test step isn't logged
in the config.log and wouldn't make sense, and AC_MSG_FAILURE is mostly
used in cases of library checks, compilation tests, headers checked with
AC_CHECK_HEADER* and similar tests that are also logged in the
config.log.

AC_MSG_ERROR([Sanity check failed.]) output:

```
configure: error: Sanity check failed.
```

AC_MSG_FAILURE([Sanity check failed.]) output:

```
configure: error: in '/path/to/php-src':
configure: error: Sanity check failed.
See 'config.log' for more details
```
2024-08-04 07:36:37 +02:00
Peter Kokot
4f07cdc584
Replace PHP_OUTPUT with AC_CONFIG_FILES (#15186)
This is a follow-up of GH-15177
(c96f08aa70)
and GH-15185
(9467ffb43c)

The PHP_OUTPUT macro was introduced in the very early phase of the build
system due to AC_OUTPUT handling issues in the old Autoconf versions
before the AC_CONFIG_FILES, AC_CONFIG_COMMANDS etc were introduced with
the AC_OUTPUT signature without arguments. The PHP_OUTPUT was also
helping Makefile.in back then being properly generated based on whether
all files were generated or only some (when using the obsolete
CONFIG_FILES=... ./config.status invocation instead of the new
./config.status --file=...). Another issue is that PHP_OUTPUT can't be
used by extensions when using phpize.

This replaces the PHP_OUTPUT invocations with default AC_CONFIG_FILES.

The obsolete "REDO_ALL" feature at the config.status invocation is also
removed with a simpler unconditional generation.

In phar extension the "ext/phar" is replaced with $ext_dir variable to
be able to use phpize.
2024-08-03 21:52:14 +02:00
Peter Kokot
e02fa5f825
Autotools: Update config.guess to 2024-07-27 and config.sub to 2024-05-27 (#15190)
```
wget -O build/config.guess https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
wget -O build/config.sub https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
```
2024-08-03 01:31:34 +02:00
Peter Kokot
079f82a8ec
Sync CPP macros in ext/iconv (#15191)
This syncs and adds help texts for CPP macros defined when iconv
extension is configured.
2024-08-02 00:49:18 +02:00
Peter Kokot
1ca3230966
Autotools: Update php.m4 CPP macros help texts (#15188)
- COMPILE_DL_<extension>
- COOKIE_SEEKER_USES_OFF64_T
- HAVE_BROKEN_GETCWD
- HAVE_LIBEXPAT
- HAVE_PREAD
- HAVE_PWRITE
- MISSING_ASCTIME_R_DECL
- MISSING_CTIME_R_DECL
- MISSING_GMTIME_R_DECL
- MISSING_LOCALTIME_R_DECL
- MISSING_STRTOK_R_DECL
- PHP_PREAD_64
- PHP_PWRITE_64
- SIZEOF_<type>
- HAVE_<type>
2024-08-01 10:08:28 +02:00
Peter Kokot
c96f08aa70
Autotools: Normalize PHP_OUTPUT arguments (#15177)
The m4_normalize([$1]) normalizes items into a single-space-separated
list of files to append them to the global PHP_OUTPUT_FILES variable
that is processed by AC_CONFIG_FILES. Redundant newlines are also
removed in the generated configure script.

PHP extensions using phpize can't use this macro so it's safe to change
this.
2024-08-01 00:14:56 +02:00
Peter Kokot
49a08d5ca3
Autotools: Move HAVE_DTRACE to configure.ac (#15160)
Following 32210ce967 and
9ea290b72b, this moves the HAVE_DTRACE
preprocessor macro definition back to configure.ac so that
PHP_INIT_DTRACE Autoconf macro can be used in extensions without
redefinition interference.
2024-07-30 07:47:11 +02:00
Peter Kokot
9ea290b72b
Sync HAVE_ICONV preprocessor macro usage (#15148)
HAVE_ICONV marks that PHP extension 'iconv' is available, and not only
that iconv library or its functions/headers are available.
2024-07-29 10:12:57 +02:00
Peter Kokot
2b97c84d4c
Autotools: Quote PHP_CHECK_LIBRARY arguments (#15136)
This syncs the quotes across the PHP_CHECK_LIBRARY macro arguments.
2024-07-28 18:39:14 +02:00
Peter Kokot
ae9b9ead7b
Autotools: Sync PHP_EXT_* M4 macros (#15134)
PHP_EXT_DIR, PHP_EXT_BUILDDIR, and PHP_EXT_SRCDIR macros don't accept
the argument since 82b73fd1e3.
2024-07-28 10:11:01 +02:00