Commit Graph

578 Commits

Author SHA1 Message Date
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
Peter Kokot
6fed6d85db
Use AC_SUBST instead of PHP_SUBST_OLD where possible (#13993)
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
2024-04-18 22:17:27 +02:00
Ørjan Malde
ff76cb738b
rudimentary midipix port (#13896) 2024-04-18 08:19:44 +02:00
Arnaud Le Blanc
46b6ad6dae
Inline GDB scripts in the PHP binary (#13600)
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).
2024-04-16 15:10:01 +02:00
Eric Mann
67fc53e1be
PHP-8.3 is now for PHP 8.3.7-dev 2024-04-10 08:45:14 -07:00
Peter Kokot
de03a7c8f9
Remove unused os/signpost.h header check (#13920)
Removed via be275433d9.
2024-04-09 23:52:57 +02:00
qiangxuhui
0766ac6e35
loongarch64 support for fibers
Add loongarch64 assembly files from Boost, needed for fibers support,
and hook up loongarch64 fibers support during configure.

Close GH-13914
2024-04-08 18:59:02 +01:00
Peter Kokot
413f2cd427
Refactor root build directories (#13785)
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.
2024-03-27 16:20:03 +01:00
Eric Mann
9381129d1b
PHP-8.3 is now for PHP 8.3.6-dev 2024-03-26 09:08:14 -07:00
Pierrick Charron
7942268899
PHP-8.2 is now for PHP 8.2.19-dev 2024-03-26 08:49:44 -04:00
Adam Saponara
0c07b0d94f
Make --enable-embed libs respect --libdir
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
2024-03-23 07:46:31 +01:00
Peter Kokot
530e0d68eb
Create modules directory in a centralized location (#13411)
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).
2024-03-21 17:43:49 +01:00
David Carlier
839153069f Merge branch 'PHP-8.2' into PHP-8.3 2024-03-18 06:58:14 +00:00
David Carlier
868257a3de Fix GH-13727: macro generating invalid call test prototypes fixes.
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
2024-03-18 06:53:39 +00:00
Peter Kokot
c6f4c26e1b
Check major, minor and makedev with Autoconf's AC_HEADER_MAJOR (#13706)
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.
2024-03-15 21:18:05 +01:00
Peter Kokot
d2eb3e54ea
Check asm goto support with AC_LINK_IFELSE (#13716)
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.
2024-03-15 06:44:27 +01:00
Claudio Jeker
4bf4c24aa8 Implement fcontext handling for sparc64_sysv_elf.
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.
2024-03-12 11:06:18 +00:00
Peter Kokot
8595bead87
Use default Autoconf's AC_LANG_PROGRAM (#13565)
This adds default test program prologue and body of
`int main(void) { return 0; }` where possible.
2024-03-11 00:24:57 +01:00
Peter Kokot
a0b821b543
Check library containing socket() with AC_SEARCH_LIBS (#13642)
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.
2024-03-10 06:53:39 +01:00
Peter Kokot
2f6a210755
Use memmove() unconditionally in the code (#13647)
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
2024-03-09 20:30:08 +01:00
Peter Kokot
a46438e87f
Remove htonl() Autoconf check (#13627)
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.
2024-03-08 19:36:30 +01:00
Peter Kokot
7bca3c7f45
Check sys/sdt.h with AC_CHECK_HEADER (#13626)
When using DTrace, sys/sdt.h is included unconditionally, without the
HAVE_SYS_SDT_H symbol.
2024-03-08 19:35:44 +01:00
Peter Kokot
42a4e50513
Sync logical operators in shell scripting code (#13560)
This updates the obsolescent `-a` and `-o` binary primaries to `&&` and
`||`.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
2024-03-01 20:40:16 +01:00
Peter Kokot
7d0e2d8e4d
Add missing memfd_create Autoconf check for bundled pcre2lib (#13561)
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.
2024-03-01 17:17:28 +01:00
Peter Kokot
a48ed12ea9
Find and link network library as needed with AC_SEARCH_LIBS (#13553)
This prepends -lnetwork as needed (Haiku) whether linker sees the
setsockopt function and avoids defining redundant symbols, such as
HAVE_LIBNETWORK and HAVE_SETSOCKOPT.
2024-02-29 22:04:13 +01:00
Peter Kokot
154517eba9
Simplify openpty Autoconf check (#13494)
This removes redundant symbols HAVE_LIBUTIL and HAVE_LIBBSD.
2024-02-28 20:14:24 +01:00
Peter Kokot
acb677cbcf
Simplify Pgrab and proc library Autoconf check (#13488)
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.
2024-02-28 18:41:51 +01:00
Jakub Zelenka
47dca339a4
PHP-8.3 is now for PHP-8.3.5-dev 2024-02-28 11:46:49 +00:00
Sergey Panteleev
e1a8ebd61b
PHP-8.2 is now for PHP 8.2.18-dev 2024-02-27 17:26:44 +03:00
Peter Kokot
d024dd3abd
Simplify nanosleep Autoconf check (#13490)
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.
2024-02-25 18:28:33 +01:00
Jorg Sowa
9c4beac8d3 Remove inet_aton
This removes the deprecated inet_aton and its Windows implementation.
The inet_aton can be replaced with platform agnostic inet_pton.

Closes GH-13479
2024-02-23 23:16:43 +01:00
Peter Kokot
bd365149f2
Find and link math library as needed with AC_SEARCH_LIBS (#13481)
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.
2024-02-23 20:48:10 +01:00
Peter Kokot
e9f8defd34
Find and link dl library as needed with AC_SEARCH_LIBS (#13482)
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.
2024-02-23 20:44:06 +01:00