Commit Graph

610 Commits

Author SHA1 Message Date
Peter Kokot
6857c7c8d6
Autotools: Expand m4_normalize sooner (#15018)
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.)
2024-07-19 15:20:04 +02:00
Peter Kokot
694e04499a
Autotools: Sync LIBS and LDFLAGS handling (#14956)
- 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
2024-07-15 12:16:53 +02:00
Ilija Tovilo
20d8151b35
Add cachegrind support for php-cgi warmups (#14952)
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>
2024-07-14 19:53:16 +02:00
Ilija Tovilo
780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +02:00
Peter Kokot
d59691c02f
Autotools: Move php_shtool variable initialization to PHP_INIT_BUILD_SYSTEM (#14904)
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.
2024-07-10 21:15:02 +02:00
Peter Kokot
9e94d2b040
Autotools: Refactor builtin checks (#14835)
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.
2024-07-08 21:25:16 +02:00
Peter Kokot
745ae8ddd8
Autotools: Remove obsolete crypt link override due to OpenSSL (#14863)
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
2024-07-08 20:24:28 +02:00
Peter Kokot
7fda12218a
Autotools: Move Apache warning to SAPI's config.m4 (#14872)
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.
2024-07-08 17:17:33 +02:00
Peter Kokot
05b9345b08
Autotools: Remove unused DEBUG_CFLAGS variable (#12659)
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.
2024-07-08 17:05:57 +02:00
Peter Kokot
083493be57
Fix AS_VAR_* checks (#14868)
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.
2024-07-08 14:20:58 +02:00
Peter Kokot
1bdf9aa38d
Remove support for EOL Apache 2.0 and 2.2 in favor of 2.4+ (#14664)
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
2024-07-08 00:07:55 +02:00
Peter Kokot
80e0c0aaf4
Autotools: Refactor dmalloc check (#14726)
- AS_VAR_APPEND used for enabling Dmalloc check-funcs token
- CS synced
2024-07-07 23:35:50 +02:00
Peter Kokot
e9254494ff
Autotools: Simplify POSIX Threads check (#14855)
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.
2024-07-07 22:44:44 +02:00
Peter Kokot
17ef4b7ced
Autotools: Sync CS in phpize and configure.ac (#14838)
- 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
2024-07-06 13:35:14 +02:00
Peter Kokot
27879fb5d5
Fix GH-14798: Valgrind and address sanitizer are not compatible (#14826)
When configuring PHP with:

    ./configure --with-valgrind and --enable-address-sanitizer

configuration now errors now since these two are not compatible
configurations.
2024-07-05 12:03:21 +02:00
Peter Kokot
ae420538d2
Autotools: Refactor PHP_BROKEN_GCC_STRLEN_OPT (#14824)
- Synced CS
- Cache variable ac_cv_have_broken_gcc_strlen_opt renamed to
  php_cv_have_broken_gcc_strlen_opt
2024-07-05 10:37:49 +02:00
Peter Kokot
d7cd155e8d
Autotools: Refactor cache variables in configure.ac and ext/ldap (#14784)
- Cache variables ac_cv_ renamed on few places to php_cv_
- Over-quoted arguments reduced
- AS_VAR_IF and CS synced
2024-07-03 21:57:51 +02:00
Peter Kokot
a86163a33c
Autotools: Refactor getaddrinfo check (#14783)
- AS_VAR_IF and AS_CASE used
- CS synced
- Over-quoted arguments reduced
- Cache variable ac_cv_func_getaddrinfo renamed to
  php_cv_func_getaddrinfo
2024-07-03 21:54:13 +02:00
Peter Kokot
ec277ce7fe
Autotools: Refactor IPv6 check (#14782)
- 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
2024-07-03 14:51:50 +02:00
Peter Kokot
dc7b67ebc3
Autotools: Sync PHP_ADD_MAKEFILE_FRAGMENT (#14766)
- Macro help text updated for extensions and general usage
- Arguments quoted
- dnl removes redundant newlines in the generated configure script
2024-07-03 13:15:13 +02:00
Peter Kokot
7575905db8
Autotools: Refactor PEAR check (#14765)
- 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)
2024-07-02 12:38:09 +02:00
Peter Kokot
b9f8113a48
Autotools: Quote PHP_SUBST arguments in configure.ac (#14757) 2024-07-02 05:44:45 +02:00
Peter Kokot
9674a421b7
Autotools: Move openpty check to libraries section (#14737)
This is just a sync and alignment with Autoconf documentation style
order of checks in configure.ac ("Standard configure.ac Layout"):
https://www.gnu.org/software/autoconf/manual/autoconf-2.72/autoconf.html#Autoconf-Input-Layout
2024-07-02 05:41:13 +02:00
Peter Kokot
72326362d7
Sync PHP_SUBST_OLD (#14746)
- 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
2024-07-01 19:28:20 +02:00
Peter Kokot
ebad61de2d
Autotools: Quote AC_SUBST arguments (#14743) 2024-07-01 14:07:26 +02:00
Peter Kokot
9caad3745d
Autotools: Refactor Valgrind support (#14736)
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
2024-07-01 00:29:44 +02:00
Peter Kokot
b1c34a9163
Normalize AC_CHECK_HEADER* arguments (#14723)
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).
2024-06-29 19:49:12 +02:00
Peter Kokot
52ed06dc7d
Autotools: Move HAVE_DTRACE and PHP_DTRACE_OBJS to PHP_INIT_DTRACE (#14722)
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.
2024-06-29 19:12:08 +02:00
Peter Kokot
01b3c05007
Include Zend.m4 with m4_include (#14693)
Zend.m4 is now a collection of only macro definitions.
2024-06-28 22:50:22 +02:00
Peter Kokot
2041c133ac
Normalize AC_CHECK_FUNC* first argument (#14700)
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.
2024-06-28 22:40:24 +02:00
Peter Kokot
604dafff3a
Rename and refactor Zend.m4 macros (#14671)
- LIBZEND_* -> ZEND_*
- A single "public" initialization M4 macro ZEND_INIT that wraps Zend
  engine related configure step checks and initialization.
2024-06-26 22:57:01 +02:00
Peter Kokot
807273e263
Normalize Zend sources (#14676)
Follow-up of GH-14654
2024-06-26 22:18:46 +02:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* 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.
2024-06-26 00:26:43 +02:00
Peter Kokot
909d331d0a
Add _GNU_SOURCE definition unconditionally (#14651)
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.
2024-06-25 20:07:42 +02:00
Peter Kokot
0775d68322
Fix configure log message when cross-compiling (#14658)
This puts the configure log into its own lines and makes it readable:

    checking for gcc... gcc
    checking for native build C compiler... gcc
2024-06-25 18:58:53 +02:00
Peter Kokot
5db847e313
Fix --enable-re2c-cgoto check (#11928)
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.
2024-06-25 16:10:10 +02:00
Peter Kokot
f3feef8b93
Define default RE2C_FLAGS (#14615)
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.
2024-06-24 22:09:04 +02:00
Peter Kokot
c6dc3bd9f8
Remove obsolete enable_pear BC compatibility check (#14636)
This was added due to configure option rename from --enable-pear to
--with-pear:
2cf1b8d345
2024-06-23 21:39:52 +02:00
Peter Kokot
ca5952a98a
Refactor SHADOW_STACK_SYSCALL check (#14575)
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.
2024-06-15 17:00:56 +02:00
Peter Kokot
6a14730d20
Wrap aligning segments checks in AC_CACHE_CHECK (#14450)
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
2024-06-03 15:22:15 +02:00
Arnaud Le Blanc
182fee1447
Fix removal of optimization cflags in debug builds (#9647)
Discard known '-O' flags, including just '-O', but do not remove only '-O' in '-Ounknown'
2024-05-22 13:22:34 +02:00
Derick Rethans
412a3954b4
Merge branch 'PHP-8.3' 2024-05-20 15:51:19 +01:00
Derick Rethans
9c9f49a1f4
Merge branch 'PHP-8.2' into PHP-8.3 2024-05-20 15:49:46 +01:00
Derick Rethans
e5cb9d7df9
Force ffp-contract to off 2024-05-20 15:13:53 +01:00
Peter Kokot
bc09cd2bc8
Fix the aligned variable attribute check (#14211)
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.
2024-05-19 12:18:59 +02:00
Peter Kokot
52767343b2
Reduce unused variable warnings in config.log (#14264)
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.
2024-05-18 18:28:20 +02:00
Peter Kokot
4465e5082c
Use AC_SEARCH_LIBS for socketpair, gethostname and gethostbyaddr (#14116)
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.
2024-05-03 19:55:24 +02:00
Jakub Zelenka
bab75e1f5c
PHP 8.3 is now for PHP-8.3.8-dev 2024-04-23 19:27:29 +01:00
Sergey Panteleev
3b5321dffe
PHP-8.2 is now for PHP 8.2.20-dev 2024-04-23 17:22:54 +03:00
Peter Kokot
719237954b
Substitute PEAR_INSTALLDIR only when enabling PEAR (#13994)
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.
2024-04-18 23:05:46 +02:00