Commit Graph

581 Commits

Author SHA1 Message Date
dixyes
e4c23fa16b Add haiku shared objects support in libtool 2021-08-27 16:44:10 +02:00
Derick Rethans
802316301d Merge branch 'PHP-7.4' into PHP-8.0 2021-08-25 16:00:14 +01:00
Derick Rethans
3677db6386 Backport speling fix
This change was originall only done for 'master'. Xdebug bundles this file as
it requires it, but PHP 7.2/7.3 don't have it bundled. By doing "phpize" with
master, it updates the file introducing a local diff. By fixing it in older
versions, that problem goes away.
2021-08-25 15:58:28 +01:00
Peter Cowburn
36e88a0066
Use &Properties; entity in xpointer for inherited properties in class synopses (#7400)
This changes ClassInfo::createIncludeElement() such that it takes the $query
argument as-is for the xpointer attribute value. Special characters, like
" and &, are used as-is so be careful not to break the resulting XML.
2021-08-25 12:14:03 +02:00
Máté Kocsis
4a7a414735
Fix callable and iterable handling 2021-08-25 10:37:43 +02:00
Máté Kocsis
d0897b3602
Clean up function map production slightly
There's no need to iterate over $fileInfos again while generating the class map
2021-08-24 19:30:00 +02:00
Máté Kocsis
e35a7fe919
Fix function map production 2021-08-24 18:45:31 +02:00
Máté Kocsis
2141bee69d
Add more specific array type hints 2021-08-24 18:40:36 +02:00
Máté Kocsis
b1822899fc
Add support for generating optimizer function info from stubs (#7367) 2021-08-24 16:35:33 +02:00
Máté Kocsis
076f2899ba
Add support for replacing class synopses based on stubs (#7340) 2021-08-13 15:03:31 +02:00
Máté Kocsis
ac17b3646d
Add support for generating classynopses from stubs
Closes GH-7310
2021-08-02 17:56:22 +02:00
Kamil Tekiela
cd0cd3d31e
Fix typos (#7327) 2021-08-01 18:03:30 +01:00
Máté Kocsis
fc56de113c
Add support for generating readonly properties via stubs (#7297) 2021-07-22 11:09:10 +02:00
Máté Kocsis
23b1c4a982
Migrate to PHP-Parser 4.12.0 and regenerate some arginfos 2021-07-22 09:40:16 +02:00
Nikita Popov
814a932734 Add ZEND_ACC_NOT_SERIALIZABLE flag
This prevents serialization and unserialization of a class and its
children in a way that does not depend on the zend_class_serialize_deny
and zend_class_unserialize_deny handlers that will be going away
in PHP 9 together with the Serializable interface.

In stubs, `@not-serializable` can be used to set this flag.

This patch only uses the new flag for a handful of Zend classes,
converting the remainder is left for later.

Closes GH-7249.
Fixes bug #81111.
2021-07-19 15:59:11 +02:00
Máté Kocsis
553574165a
Add support for the never type in gen_stub.php 2021-07-14 15:21:15 +02:00
Máté Kocsis
0192fd20cc
Merge branch 'PHP-8.0' 2021-07-12 10:32:07 +02:00
Máté Kocsis
80e5ad5a29
Various ext/spl stub fixes
Closes GH-7215
2021-07-12 10:27:05 +02:00
Tyson Andre
e748dcacad
Allow build/gen_stub.php to process multiple CLI file args (#7179)
E.g. `build/gen_stub.php *.stub.php` will generate `*_arginfo.h`
from multiple files.

Previously, gen_stub.php would silently ignore files after the first file.

Invoking gen_stub.php with no arguments will continue to process the entire
directory.
2021-06-20 15:14:01 -04:00
Nikita Popov
be92a87371 Fix PHP_ADD_EXTENSION_DEP without indentation
Adjust FS in order_by_dep.awk to only each whitespace around (,)
rather than any whitespace. Thus a leading indent does not result
in a separate element.
2021-06-10 11:48:25 +02:00
haosun01
657b00d7c0 Hybrid use of registers
1. one **hybrid** solution of register usage
After the discussion with Dmitry, we may want to propose one hybrid
solution of register usage.

1) Following the x86 implementation, we define REG0/1/2 to be the
scratch registers. Clever tricks are utilized in x86 implementation for
better register allocation. Note that we define REG0/1/2 as x8/9/10. One
reason is that R0 and FCARG1 should be distinguished.

2) Temporary registers are also reserved(i.e. they are excluded from the
candidates of register allocator), and they would be used due to the
different addressing modes in AArch64.

2. update the 'make clean' target.

3. remove the unnecessary AArch64 related macros in zend_jit_internal.h.

[ci skip]

Change-Id: I627157b88b2344530d705751eb7f73a223ed83e5
CustomizedGitHooks: yes
2021-05-18 15:32:23 +03:00
Hao Sun
0de9494464 Initial support of JIT/arm64
SUMMARY

We implemented a prototype of PHP JIT/arm64. Briefly speaking,

1. build system
Changes to the build system are made so that PHP JIT can be successfully
built and run on ARM-based machine.
Major change lies in file zend_jit_arm64.dasc, where the handler for
each opcode is generated into machine code. Note that this file is just
copied from zend_jit_x86.dasc and the *unimplemented* parts are
substitued with 'brk' instruction for future work.

2. registers
AArch64 registers are defined in file zend_jit_arm64.h. From our
perspectives, the register usage is quite different from the x86
implementation due to the different ABI, number of registers and
addressing modes.
We had many confusions on this part, and will discuss it in details in
the final section.

3. opcodes
Several opcodes are partially supported, including INIT_FCALL, DO_UCALL,
DO_ICALL, RETURN, ADD, PRE_INC, JMP, QM_ASSIGN, etc. Hence, simple use
scenarios such as user function call, loops, addition with integer and
floating point numbers can be supported.
18 micro test cases are added under 'ext/opcache/tests/jit/arm64/'. Note
that majority of these test cases are design for functional JIT, and
cases 'hot_func_*.phpt' and 'loop_002.phpt' can trigger tracing JIT.

4. test
Our local test environment is an ARM-based server with Ubuntu 20.04 and
GCC-10. Note that both HYBRID and CALL VM modes are supported. We
suggest running the JIT test cases using the following command. Out of
all 130 test cases, 66 cases can be passed currently.
```
  $ make test TESTS='-d opcache.jit=1203 ext/opcache/tests/jit/'
```

DETAILS

1. I-cache flush
Instruction cache must be flushed for the JIT-ed code on AArch64. See
macro JIT_CACHE_FLUSH in file 'zend_jit_internal.h'.

2. Disassembler
Add initialization and jump target parse operations for AArch64 backed.
See the updates in file 'zend_jit_disasm.c'.

3. redzone
Enable redzone for AArch64. See the update in zend_vm_opcodes.h.
Redzone is designated to prevent 'vm_stack_data' from being optimized
out by compilers. It's worth noting that this 16-byte redzone might be
reused as temporary use(treated as extra stack space) for HYBRID mode.

4. stack space reservation
The definitions of HYBRID_SPAD, SPAD and NR_SPAD are a bit tricky for
x86/64.
In AArch64, HYBRID_SPAD and SPAD are both defined as 16. These 16 bytes
are pre-allocated for tempoerary usage along the exuection of JIT-ed
code. Take line 4185 in file zend_jit_arm64.dasc as an example. NR_SPAD
is defined as 48, out of which 32 bytes to save FP/IP/LR registers.
Note that we choose to always reserve HYBRID_SPAD bytes in HYBRID mode,
no matter whether redzone is used or not, for the sake of safety.

5. stack alignment
In AArch64 the stack pointer should be 16-byte aligned. Since shadow
stack is used for JIT, it's easy to guarantee the stack alignment, via
simply moving SP with an offset like 16 or a multiple of 16. That's why
NR_SPAD is defined as 48 and we use 32 of them to save FP/IP/LR
registers which only occupies 24 bytes.

6. global registers
x27 and x28 are reserved as global registers. See the updates in file
zend_jit_vm_helpers.c

7. function prologue for CALL mode
Two callee-saved registers x27 and x28 should saved in function
zend_jit_prologue() in file zend_jit_arm64.dasc. Besides the LR, i.e.
x30, should also be saved since runtime C helper functions(such as
zend_jit_find_func_helper) might be invoked along the execution of
JIT-ed code.

8. regset
Minor changes are done to regset operations particularly for AArch64.
See the updates in file zend_jit_internal.h.

REGISTER USAGE

In this section, we will first talk about our understanding on register
usage and then demonstrate our design.

1. Register usage for HYBRID/CALL modes
Registers are used similarly between HYBRID mode and CALL mode.

One difference is how FP and IP are saved. In HYBRID mode, they are
assigned to global registers, while in CALL mode they are saved/restored
on the VM stack explicitly in prologue/epilogue.

The other difference is that LR register should also be saved/restored
in CALL mode since JIT-ed code are invoked as normal functions.

2. Register usage for functional/tracing JIT
The way registers are used differs a lot between functional JIT and
tracing JIT.

For functional JIT, runtime C code (e.g. helper functions) would be
invoked along the execution of JIT-ed code. As the operands for *most*
opcodes are accessed via the stack slot, i.e. FP + offset. Hence there
is no need to save/restore local(caller-saved) registers before/after
invoking runtime C code.
Exception lies in Phi node and registers might be allocated for these
nodes. Currently I don't fully understand the reason, why registers are
allocated for Phi functions, because I suppose for different versions of
SSA variables at the Phi function, their postions on the stack slot
should be identical(in other words, access via the stack slot is enough
and there is no need to allocate registers).

For tracing JIT, runtime information are recorded for traces(before the
JIT compilation), and the data types and control flows are concrete as
well. Hence it's would be faster to conduct operations and computations
via registers rather than stack slots(as functional JIT does) for these
collected hot paths. Besides, runtime C code can be invoked for tracing
JIT, however this only happends for deoptimization and all registers are
saved to stack in advance.

3. Candidates for register allocator
1) opcode candidates
Function zend_jit_opline_supports_reg() determines the candidate opcodes
which can use CPU registers.

2) register candidates
Registers in set "ZEND_REGSET_FP + ZEND_REGSET_GP - ZEND_REGSET_FIXED -
ZEND_REGSET_PRESERVED" are available for register allocator.
Note that registers from ZEND_REGSET_FIXED are reserved for special
purpose, such as the stack pointer, and they are excluded from register
allocation process.
Note that registers from ZEND_REGSET_PRESERVED are callee-saved based on
the ABI and it's safe to not use them either.

4. Temporary registers
Temporary registers are needed by some opcodes to save intermediate
computation results.

1) Functions zend_jit_get_def_scratch_regset() and
zend_jit_get_scratch_regset() return which registers might be clobbered
by some opcodes. Hence register allocator would spill these scratch
registers if necessary when encountering these opcodes.

2) Macro ZEND_REGSET_LOW_PRIORITY denotes a set of registers which would
be allocated with low priority, and these registers can be used as
temporary usage to avoid conflicts to its best.

5. Compared to the x86 implementation, in JIT/arm64
1) Called-saved FP registers are included into ZEND_REGSET_PRESERVED for
AArch64.

2) We follow the logic of function zend_jit_opline_supports_reg().

3) We reserve 4 GPRs and 2 FPRs out from register allocator and use them
as temporary registers in particular. Note that these 6 registers are
included in set ZEND_REGSET_FIXED.
Since they are reserved, may-clobbered registers can be removed for most
opcodes except for function calls. Besides, low-priority registers are
defined as empty since all candidate registers are of the same priority.
See the updates in function zend_jit_get_scratch_regset() and macro
ZEND_REGSET_LOW_PRIORITY.

6. Why we reserve registers for temporary usage?
1) Addressing mode in AArch64 needs more temporary registers.
The addressing mode is different from x86 and tempory registers might be
*always* needed for most opcodes. For instance, an immediate must be
first moved into one register before storing into memory in AArch64,
whereas in x86 this immediate can be stored directly.

2) There are more registers in AArch64.
Compared to the solution in JIT/x86(that is, temporary registers are
reserved on demand, i.e. different registers for different opcodes under
different conditions), our solution seems a coarse-granularity and
brute-force solution, and the execution performance might be downgraded
to some extent since the number of candidate registers used for
allocation becomes less.
We suppose the performance loss might be acceptable since there are more
registers in AArch64.

3) Based on my understanding, scratch registers defined in x86 are
excluded from candidates for register allocator with *low possibility*,
and it can still allocate these registers. Special handling should be
conducted, such as checking 'reg != ZREG_R0'.
Hence, as we see it, it's simpler to reserve some temporary registers
exclusively. See the updates in function zend_jit_math_long_long() for
instance. TMP1 can be used directly without checking.

Co-Developed-by: Nick Gasson <Nick.Gasson@arm.com>
2021-05-18 15:32:23 +03:00
Máté Kocsis
532c60cb92
Add support for tentative return types of internal methods
RFC: https://wiki.php.net/rfc/internal_method_return_types

Closses GH-6971
2021-05-14 15:55:25 +02:00
Nikita Popov
37173460b0
Update config.guess (#6886)
In particular, this pulls in support for Apple M1 detection.
2021-04-20 10:47:47 +02:00
Dmitry Stogov
f1ad9199ef Better support for cross-compilation 2021-04-16 17:28:54 +03:00
Nikita Popov
e35f9dfecc Don't check executability
As $(PHP) is not an absolute path, test -x doesn't do anything
meaningful. Rely on the autoconf check.
2021-03-16 14:36:10 +01:00
Nikita Popov
fa9e2b31b8 Check for php program in autoconf
Use the detected PHP (minimum 7.1) to run gen_stubs, and other
code generation scripts in the future.
2021-03-16 12:30:56 +01:00
Nikita Popov
bbb86ba7e2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove generated zend_jit_x86.c on `make clean`
2021-02-17 09:45:31 +01:00
Dylan T
408272b8d9 Remove generated zend_jit_x86.c on make clean
Not removing this causes build failure when reconfiguring and rebuilding after a `make clean`, e.g. enabling/disabling ZTS.

This makes https://bugs.php.net/bug.php?id=80561 more bearable. Ideally it would be rebuilt automatically on configuration change if necessary, but I have no idea how to implement this.

Closes GH-6702.
2021-02-17 09:45:12 +01:00
Máté Kocsis
803779e84b
Add support for generating properties with union type of multiple classes
Closes GH-6701
2021-02-16 15:50:13 +01:00
Máté Kocsis
cad66533f0
Generate class entries from stubs for ldap, libxml, mbstring and mysqli
Closes GH-6684
2021-02-16 14:46:19 +01:00
Máté Kocsis
bf0f6aaf18
Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Florian Sowade
c4d508c2bc Add dependency tracking for header files
This ensures all .c files which include a header file directly or
indirectly are rebuilt whenever the header file is changed.

Closes GH-6693.
2021-02-16 10:50:03 +01:00
Máté Kocsis
99b08ac281
Implicitly enable function entry generation when class entry generation is enabled
Closes GH-6675
2021-02-09 13:37:24 +01:00
Tyson Andre
5e06dad411 Properly render 2+ namespaces functions in build/gen_stub.php
Affects ZEND_NS_FE

Add test cases of the global function

Backported to php 8.0 from GH-6664
2021-02-06 14:17:14 -05:00
Tyson Andre
b4c6d5f799 Properly render 2+ namespaces functions in build/gen_stub.php
Affects both INIT_NS_CLASS_ENTRY and ZEND_NS_FE

Add test cases of the global function and namespaced values

Closes GH-6664
2021-02-06 14:09:25 -05:00
Máté Kocsis
1954e59758
Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
Nikita Popov
a9efcb1561 gen_stub: Also verify implementation-alias
This makes --verify also check @implementation-alias. Failures are
ignored using @no-verify instead. Some mistakes have been made that
would have been caught by this...

Closes GH-6615.
2021-01-19 09:48:33 +01:00
Nikita Popov
f0d6151918 gen_stub: Don't use $aliasMap during verification
Some functions have multiple aliases, while the $aliasMap can
only record one.

Methodsynopsis generation probably shouldn't use it either, but
at least that case seems to only be interested in whether there
is an alias at all.
2021-01-18 16:04:14 +01:00
Nikita Popov
496e4741a3 gen_stub: Compare phpdoc return type in --verify 2021-01-18 14:41:53 +01:00
Nikita Popov
85bfa2243a gen_stub: Allow additional text after @return
In case the stub file also contains documentation.
2021-01-18 13:13:32 +01:00
Nikita Popov
43d5cef448 gen_stub: Automatically add function name to exceptions
This makes sure that it's present even on exceptions from deeper
down the stack, where we can't add it manually.
2021-01-18 13:13:32 +01:00
Nikita Popov
45a4d07dd0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add support for union types for internal functions
2021-01-12 10:15:13 +01:00
Nikita Popov
973138f39d Add support for union types for internal functions
This closes the last hole in the supported types for internal
function arginfo types. It's now possible to represent unions of
multiple classes. This is done by storing them as TypeA|TypeB and
PHP will then convert this into an appropriate union type list.

Closes GH-6581.
2021-01-12 10:14:41 +01:00
Máté Kocsis
dc4d8400b4
Merge branch 'PHP-8.0' 2020-12-30 18:28:33 +01:00
Máté Kocsis
446ad04524
Fix refentry attribute replacing 2020-12-30 18:26:24 +01:00
Máté Kocsis
74e39ce06c
Merge branch 'PHP-8.0' 2020-12-28 14:46:00 +01:00
Máté Kocsis
9cec093b7f
Add support for generating methodsynopses from stubs
Closes GH-6367
2020-12-28 14:44:43 +01:00
Peter Kokot
d386ed1e6b Backport fix for bug #78750
Cherry-picks
fe2afef36f
and
86e2b7bb70.
2020-12-03 10:07:09 +01:00
Nikita Popov
08006e8337 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80402: Don't strip -lpthread
2020-11-26 11:56:07 +01:00
Nikita Popov
6132389d1c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80402: Don't strip -lpthread
2020-11-26 11:56:00 +01:00
Nikita Popov
ea372e7463 Fix bug #80402: Don't strip -lpthread
The current behavior has been introduced 20 years ago in
f9e375f493 as part of a larger change.
It's not clear to me why special treatement of -lpthread is necessary
here.
2020-11-26 11:54:20 +01:00
Nikita Popov
14eabd9523 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80393
2020-11-24 15:27:50 +01:00
Nikita Popov
ae6e56fb98 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80393
2020-11-24 15:27:43 +01:00
Nikita Popov
d016434ad3 Fixed bug #80393
Handle macos versions that don't start with 10.* in libtool.

Patch by kir dot morozov at gmail dot com.
2020-11-24 15:26:40 +01:00
Nikita Popov
b6a93c38bf Merge branch 'PHP-8.0'
* PHP-8.0:
  Use true/false instead of TRUE/FALSE in intl
2020-11-09 14:44:46 +01:00
Nikita Popov
975735c027 Use true/false instead of TRUE/FALSE in intl
And drop the U_DEFINE_TRUE_AND_FALSE flag.
2020-11-09 14:44:11 +01:00
Nikita Popov
5143b4d8aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80310: Support for icu4c 68.1.
2020-11-09 14:35:48 +01:00
Nikita Popov
4cd393453a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80310: Support for icu4c 68.1.
2020-11-09 14:35:40 +01:00
Nikita Popov
96b725122d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #80310: Support for icu4c 68.1.
2020-11-09 14:34:24 +01:00
Nikita Popov
e1cbfb38f6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix another implicit function declaration in configure
2020-11-03 10:39:33 +01:00
Nikita Popov
53c417d81c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix another implicit function declaration in configure
2020-11-03 10:39:26 +01:00
Nikita Popov
4e68c53a21 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix another implicit function declaration in configure
2020-11-03 10:39:13 +01:00
Nikita Popov
00ba784a2c Fix another implicit function declaration in configure
As mentioned on bug #80171. This one is in libtool.m4, might get
lost on libtool updates.
2020-11-03 10:38:16 +01:00
Jakub Zelenka
c3a6debc08 Bump minimal OpenSSL version to 1.0.2 2020-11-01 20:10:37 +00:00
Nikita Popov
1c868b186e Fix parameter stats generation
[ci skip]
2020-10-26 09:05:25 +01:00
Máté Kocsis
47bbfe1fc0
Require stubs to declare return types for magic methods when possible
Closes GH-6376
2020-10-23 16:33:16 +02:00
Máté Kocsis
d6264b0966
Verify parameter names of function aliases
Closes GH-6335
2020-10-16 10:56:33 +02:00
Nikita Popov
c96d884d91 Avoid namespaced class symbol clashes in gen_stub
Add the namespace prefix (using underscores) to both the arginfo
name and the method declaration name.
2020-10-07 12:13:52 +02:00
Nikita Popov
9c710b1d11 Support "static" type in gen_stub 2020-10-07 11:34:14 +02:00
Nikita Popov
47ef51cb45 Add @generate-legacy-arginfo tag 2020-10-05 16:33:54 +02:00
Remi Collet
dba6715598 Improve gen_stub.php - drop --legacy option, generate file is exists - add --help option - add debug "Saved ..." message 2020-10-05 15:41:08 +02:00
Nikita Popov
d3cf597328 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix -Wimplicit-function-declaration in configure
2020-10-05 10:48:04 +02:00
Nikita Popov
9ad5381a2f Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix -Wimplicit-function-declaration in configure
2020-10-05 10:46:46 +02:00
Nikita Popov
dfa6d1c22e Support specifying linkage for generate-function-entries
The linkage can be specified as the argument to the
@generate-function-entries tag. Test this on zend_test.
2020-10-02 17:21:16 +02:00
Nikita Popov
924ac2b98a Add partial namespace support to gen_stub 2020-10-02 17:08:50 +02:00
Nikita Popov
2e32a09541 Add gen_stub --legacy flag
This flag generates an arginfo file that discards all type and
default value information. As such, it is compatible with old
(and very old) PHP versions.

Intended for use by extensions to generate one arginfo file for
PHP 8 and one for older versions.
2020-10-02 15:14:02 +02:00
George Peter Banyard
07a2f30417 Extensions should have the final say on their compiler flags
Currently compiler flags passed by extensions using the standard
``PHP_NEW_EXTENSION`` and ``PHP_ADD_SOURCES`` m4 macros are prepended
before the ones defined by ``Zend/Zend.m4``.

This was not really an issue before as ``Zend.m4`` only included
``-Wall`` but since the addition of ``-Wextra`` various issue about
disabling flags have been brought up.

A preliminary attempt was done in commit 5c1cf7669b
but this turns out to be more or less irrelevant.

The root issue is that  ``PHP_NEW_EXTENSION`` and ``PHP_ADD_SOURCES`` call the
``PHP_ADD_SOURCES_X`` macro and pass their flags as the 3rd argument which prepends
the flags. There exists a 6th argument for this macro which appends them but from a
cursory look at https://heap.space/search?full=PHP_ADD_SOURCES_X&project=php-src
this is not used. Moreover, the comment describing this macro explicitly informs
that this macro should not be used directly.

As such we drop the 6th argument of ``PHP_ADD_SOURCES_X`` and move the `special-flags`
argument to be appended instead of prepended.

Closes GH-6204
2020-09-28 13:18:47 +01:00
Nikita Popov
9428e161a8 Add option to print parameter name stats to gen_stub 2020-09-24 15:16:29 +02:00
Máté Kocsis
64af12d13b
Add support for @implementation-alias in stubs
Closes GH-6170
2020-09-21 10:08:45 +02:00
Nikita Popov
93745a242f Only check linking in PHP_TEST_BUILD
Given that this executes a random function with zero parameters,
actually executing the code doesn't make sense.

This should fix the imap + asan build.
2020-09-20 10:24:54 +02:00
Dmitry Stogov
aae50328e2 decbin/decoct/dechex optimization. 2020-09-08 10:34:29 +03:00
Levi Morrison
94fd52dd09 Add Z_PARAM_ITERABLE and co 2020-09-03 07:03:12 -06:00
Tyson Andre
e056e2dae9 Check for duplicate names in gen_stub.php
With named arguments in php 8.0, it's important that php's modules
or PECL extensions using gen_stub.php don't generate functions
with duplicate names.

Warn if a parameter name is repeated,
even if the last occurrence is a variadic parameter

Closes GH-6035
2020-08-24 09:31:46 -04:00
Máté Kocsis
118406a31c
Remove custom hacks from gen_stub.php after PHP-Parser upgrade 2020-08-23 21:17:05 +02:00
Tyson Andre
4bba59d491 Update PHP-Parser from 4.3.0 to 4.9.0
PHP-Parser 4.3.0 failed to recognize that the `match` keyword could be
used as a class constant name.
4.9.0 also adds support for keywords in namespaced names.
See https://github.com/nikic/PHP-Parser/releases

So forcing regeneration of spl_iterators.stub.php failed.

PECL extensions using gen_stub.php would also be affected
by the same issue.

```
ext/spl/spl_iterators.stub.php
    public function __construct(Iterator $iterator, string $regex,
    int $mode = self::MATCH, int $flags = 0, int $preg_flags = 0) {}
```

Testing: I successfully regenerated stubs by setting forceRegeneration to true
and running `touch **/*.stub.php; make`.
The stubs did not change, as expected.

Closes GH-6036
2020-08-23 11:51:57 -04:00
Máté Kocsis
a10f8876ef
Check missing parameter types in stubs
[skip ci] Closes GH-5627
2020-08-13 15:17:31 +02:00
Nikita Popov
b480e6841e Recognize gnu-libiconv location on alpine 2020-08-12 15:32:11 +02:00
David Carlier
6ca6e9f891 Fix crypt_r detection under BSD system
For BSD systems, crypt.h does not exist, instead we need to
include unistd.h.

Closes GH-5971.
2020-08-12 15:09:21 +02:00
Nikita Popov
05478e985e Fix m4 quotation
We should not try to expand AX_CHECK_COMPILE_FLAG inside the
error message...
2020-08-08 10:38:51 +02:00
Nikita Popov
2d359749a4 Remove giconv support
The best information I was able to find about this is this mail
from 2009 which indicates that giconv is an old FreeBSD iconv
implementation that has long since been superseded by libiconv.

https://lists.samba.org/archive/samba-technical/2009-June/065177.html
2020-08-07 17:03:41 +02:00
Nikita Popov
65592840f0 Remove more leftovers of PHP_DEFINE handling 2020-08-07 17:03:41 +02:00
Nikita Popov
e6f7784210 Don't use PHP_DEFINE in iconv
iconv is the only consumer of this custom define mechanism that
puts every define into a single file. Use the standard mechanism
instead.
2020-08-07 14:29:04 +02:00
Nikita Popov
4cc4f9c00a Use standard types in fopencookie test
Instead of internal __size_t / __off64_t types use ssize_t and off64_t.
This makes it work on musl as well.
2020-08-05 10:39:37 +02:00
Nikita Popov
b0d139456a Use standard types in fopencookie test
Instead of internal __size_t / __off64_t types use ssize_t and off64_t.
This makes it work on musl as well.
2020-08-05 09:45:51 +02:00
Nikita Popov
442cf83b5c Add compatibility define for PHP_CHECK_GCC_ARG
This defines the m4 macro, but makes it always error.
2020-08-04 16:11:58 +02:00
Dik Takken
691a09f291 Bump libxml version requirement 2.7.6 => 2.9.0
Since libxml version 2.9.0 external entity loading is disabled by default.
Bumping the version requirement means that XML processing in PHP is no
longer vulnerable to XXE processing attacks by default.
2020-08-03 21:51:10 +02:00
Nikita Popov
e2f39f84e2 Remove PHP_CHECK_GCC_ARG()
In favor of AX_CHECK_COMPILE_FLAG(), which we bundle since at least
PHP 7.

Closes GH-5904.
2020-07-29 15:07:53 +02:00
Nikita Popov
ae8dea0b10 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79895: support = in PHP_CHECK_GCC_ARG m4 macro
2020-07-29 12:39:58 +02:00
Nikita Popov
678f5b6068 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79895: support = in PHP_CHECK_GCC_ARG m4 macro
2020-07-29 12:39:30 +02:00
Nikita Popov
1f8a93abaa Support class+mask union for internal argument 2020-07-24 16:40:14 +02:00
Nikita Popov
93594862f4 Remove no longer needed stdint compatibility defines
Closes GH-5886.
2020-07-23 13:00:04 +02:00
Nikita Popov
86e2b7bb70 Fixed bug #79841 2020-07-13 09:41:05 +02:00
Máté Kocsis
d8dfb21b51
Add support for forcing regeneration of arginfo files
Closes GH-5795
2020-07-02 14:54:52 +02:00
Nikita Popov
1ed5a63c86 Check that "tokenizer" extension is available in gen_stub.php 2020-07-02 10:37:14 +02:00
Dmitry Stogov
46e38a1927 Fixed bug #79737 (Building embed as static fails during install step). 2020-06-29 11:14:20 +03:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
Alex Dowad
7e2147be23 Clean up some unused code (and fix some comments) in build scripts
- Fix typo in build/php.m4

- Nothing uses HAVE_INTTYPES_H; so remove check for header file

- Nothing defines ZEND_ACCONFIG_H_NO_C_PROTOS; so remove #ifndef

- `format_money` was removed in 2019, so <monetary.h> no longer needed

- Nothing uses HAVE_NETDB_H; so remove check for header file

- Nothing checks HAVE_TERMIOS_H; so remove check for header file

    (This was actually added when Wez Furlong was adding the original implementation of
    PTY support in `proc_open`, since replaced.)

- Nothing checks HAVE_SYS_AUXV_H; so remove check for header file

- PHP_BUILD_DATE variable is not used for anything, so remove it

    This variable was added to the Makefile, but from there, was not used for anything.
    The comments suggest it was intended to allow 'reproducible builds'. Presumably,
    this means that if a bug is found in a PHP binary somewhere, one could look at the
    Makefile which it was built from, see the date, and then could check the same
    code version out from source control. But... there can easily be multiple commits
    to the repo in the same day. Also, what makes us think that the Makefile which a
    binary was built from will be easily available?

    Besides, ext/standard/info.c already embeds the build date and time in each binary...
    but it does it using `__DATE__` and `__TIME__` (see `php_print_info`).

- Nothing checks HAVE_FINITE; so don't check for function

- Grammar fix to comment in build/php.m4

- Nothing sets $php_ldflags_add_usr_lib variable in configure, so remove conditional

    This was added in 2002, when Rasmus was having difficulty building PHP on some
    host and needed to have /usr/lib in the rpath. It was never documented and
    probably has never been used by anyone else.
2020-06-19 22:04:52 +02:00
Peter Kokot
fe2afef36f Fix #78750: configure assumes yacc and re2c work
Closes GH-5681
2020-06-09 00:46:12 +02:00
Christoph M. Becker
4fa3687e56 Unbundle ext/xmlrpc
According to <https://wiki.php.net/rfc/unbundle_xmlprc> we unbundle
ext/xmlrpc.
2020-05-29 16:47:44 +02:00
Máté Kocsis
b3718430de
Annotate internal functions with the mixed type
Closes GH-5618
2020-05-25 17:30:57 +02:00
Bob Weinand
4bc1cf2928 Remove generated zend_jit_x86.c upon make distclean 2020-05-14 16:59:54 +02:00
Nikita Popov
ae5ca5459f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix lcov genhtml: ERROR: cannot read [file]
  Properly detect CRC32 APIs on aarch64 from configure
2020-05-14 09:39:03 +02:00
Gerard Roche
ae1d4a820a Fix lcov genhtml: ERROR: cannot read [file]
lcov is emitting several errors for generated regex files that have no code
coverage data. The fix is to add the files to the lcov exlusion list.

This is not an issue for CI because it uses gcovr to generate code coverage.

The errors:

    Processing ext/date/lib/parse_date.gcda
    geninfo: WARNING: could not open /home/code/vendor/php/php-src/parse_date.re
    geninfo: WARNING: could not open /home/code/vendor/php/php-src/<stdout>
    geninfo: WARNING: some exclusion markers may be ignored
    Processing ext/date/lib/parse_tz.gcda
    Processing ext/date/lib/tm2unixtime.gcda
    Processing ext/date/lib/parse_iso_intervals.gcda
    geninfo: WARNING: could not open /home/code/vendor/php/php-src/<stdout>
    geninfo: WARNING: could not open /home/code/vendor/php/php-src/parse_iso_intervals.re
    geninfo: WARNING: some exclusion markers may be ignored
    ...
    genhtml: ERROR: cannot read /home/code/vendor/php/php-src/parse_date.re
    Processing file /home/code/vendor/php/php-src/parse_date.re
    make: *** [Makefile:443: lcov-html] Error 2

Closes GH-5568.
2020-05-14 09:38:27 +02:00
Nikita Popov
5dc9418a97 Reapply "Remove configure checks for supported instruction sets"
I reverted this previously for 7.4 because of bug #78769. Relanding
it now for master, because I still believe that this change is
right, and if it causes complications, those indicate a bug elsewhere.

---

These were checking whether the instruction set is supported by
the host CPU, however they were only used to condition on whether
this instruction set is targeted at all. It would still use dynamic
dispatch (e.g. based on ifunc resolvers) to select the actual
implementation. Whether the target is guaranteed to support the
instruction set without dispatch is determined based on pre-defined
macros like __SSE2__.

This removes the configure-time builtin cpu checks to remove
confusion. Additionally this allows targeting an architecture that
is newer than the host architecture.
2020-05-11 12:22:28 +02:00
Nikita Popov
89b4a46d56 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix default sendmail path when not found during build
2020-05-11 10:46:07 +02:00
Nikita Popov
d050d74477 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix default sendmail path when not found during build
2020-05-11 10:46:00 +02:00
Remi Collet
c3d6a0ac02 manage ZEND_DEP_FALIAS in gen_stub 2020-04-29 14:37:06 +02:00
Christoph M. Becker
38ecfe0245 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79532: sizeof off_t can be wrong
2020-04-29 10:43:35 +02:00
Christoph M. Becker
67f9b0b754 Fix #79532: sizeof off_t can be wrong
We have to actually determine the proper `SIZEOF_OFF_T`.
Interestingly, it is `4` on Windows x64.

We also have to prevent the redefinition in pg_config.h.  The clean
solution would likely be to not include pg_config.h at all, but that's
out of scope for BC reasons for now.
2020-04-29 10:40:59 +02:00
Dmitry Stogov
5fe723c92d Fix libtool to provide a simple way to generate only "shared" object files or libraries.
- Support for "-shared" option is taken from libtool-2.0 that is already at lease 15 years old.
- Change PHP build system to use "-shared" instead of "--tag=disable-static".
2020-04-27 23:31:54 +03:00
George Peter Banyard
f91f72607b Drop unnecessary stdint and inttypes header checks
These are always available as of C99.

Closes GH-5323

Co-authored-by: "Christoph M. Becker" <cmbecker69@gmx.de>
2020-04-22 20:18:19 +02:00
Nikita Popov
fa4bdf1cda Make gen_stub parallelism safe
If PHP-Parser is not yet installed, make sure we don't try to
install it N times in parallel.
2020-04-21 10:20:51 +02:00
Nikita Popov
661c0ac7f3 Remove support for EBCDIC
Closes GH-5390.
2020-04-20 16:39:39 +02:00
Nikita Popov
110e6e4f95 Make gen_stub.php compatible with PHP 7.1 again
Not worth bumping requirements over this...
2020-04-14 17:55:27 +02:00
Máté Kocsis
dfd0acf0d7
Generate method entries for ext/dom
Closes GH-5374
2020-04-13 00:13:11 +02:00
Tyson Andre
047d814704 Fix an undefined class error running gen_stub in php8
For whatever reason, php 8 would not have loaded the subsequent classes when
running `php build/gen_stub.php path/to/filename.php`.
I assume it didn't load the classes immediately because there's a possibility
the code before it would throw.
(Probably because __toString was added recently and prevents early binding)

Also, fix a typo

Closes GH-5369
2020-04-11 17:17:28 -04:00
Máté Kocsis
3fe49d81f8
Generate method entries from stubs for a couple of extensions
Closes GH-5368
2020-04-11 13:28:53 +02:00
Máté Kocsis
1d05771a70
Add support for generating method entries from stubs
Closes GH-5363
2020-04-11 09:15:14 +02:00
Máté Kocsis
3709e74b5e
Store default parameter values of internal functions in arg info
Closes GH-5353. From now on, PHP will have reflection information
about default values of parameters of internal functions.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-04-08 18:37:51 +02:00
Máté Kocsis
d5bbb28f7d
Move variable declaration closer to its usage 2020-04-05 00:03:08 +02:00
Máté Kocsis
610815c0ce
Improve gen_stub.php
Closes GH-5350
Add support for generating deprecated function entries, as well as forward declaration
of function aliases.
2020-04-04 23:52:33 +02:00
Máté Kocsis
a43bc33fb2
Annotate function aliases in stubs 2020-04-04 13:03:16 +02:00
Nikita Popov
2bcc4ab8f4 Verify that all stubs have a return type 2020-04-03 17:59:30 +02:00
Nikita Popov
d2c92d7fd3 Stubs: Store information per-class
We'll need this if we want to generate method entries.
2020-04-03 16:20:47 +02:00
Nikita Popov
51bc6233b2 Generate function entries from stubs
If @generate-function-entries is specified in the stub file,
also generate function entries for the extension.

Currently limited to free functions only.
2020-04-03 15:41:41 +02:00
Remi Collet
75b01c797e add some output when generating arginfo 2020-04-03 10:48:20 +02:00
Remi Collet
e11d3b1690 Move gen_stub.php to build directory and install it so phpize can take care of it, and thus extension can use it as it is already in Makefile 2020-04-03 10:48:20 +02:00
Anatol Belski
66c85c3f2f Update bundled config.guess and config.sub 2020-02-15 13:43:31 +01:00
Xinchen Hui
9c5fb54c97 Improved the check
makefile.global is also used while building shared extension
2020-02-13 15:59:21 +08:00
Xinchen Hui
9e5650265c Fixed build (Only PHP above 7.1 could run the gen_stub.php) 2020-02-12 14:22:01 +08:00
Anatol Belski
538c088a82 Merge branch 'PHP-7.4'
* PHP-7.4:
  Update bundled stdxx check macros
2020-02-08 10:18:08 +01:00
Anatol Belski
34bab6c9fc Update bundled stdxx check macros 2020-02-08 10:13:46 +01:00
Akim Demaille
2127a37b83
Bison: enable all the warnings and fix them
First, fix 5547d36120: the definition of
YFLAGS was not passed into the Makefile: AC_SUBST does not suffice, we
need PHP_SUBST_OLD.  While at it, allow to pass variable and value at
the same time.

Then pass -Wall to bison, rather than only -Wempty-rules.

Use %precedence where associativity is useless.

Remove useless %precedence.
GH-5138
2020-02-01 14:21:21 +01:00
Akim Demaille
37d0f7d3b3
Use "%empty" in the parsers, instead of comments
The annotation %empty is properly enforced: warnings when it's
missing, and errors when it's inappropriate.  Support for %empty was
introduced in Bison 3.0.

Pass -Wempty-rule to Bison.

Closes GH-5134
2020-01-31 09:52:40 +01:00
Nikita Popov
5947437d47 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #79112: IMAP can't find OpenSSL during configure
2020-01-20 09:59:40 +01:00
Nikita Popov
74380465ec Fix bug #79112: IMAP can't find OpenSSL during configure
Remove the check of PHP_OPENSSL inside SETUP_OPENSSL. It's the
responsibility of the caller to determine whether they want to
enable openssl or not. This makes SSL detection in IMAP work,
which uses a different option.

Additionally also clarify that --with-openssl-dir cannot actually
be used to specify an OpenSSL directory -- these options just
serve as a way to enable OpenSSL in extensions without also
enabling the OpenSSL extension. They need to be renamed to
something clearer in master.

Closes GH-5091.
2020-01-20 09:59:27 +01:00
Nikita Popov
b509d67554 Merge branch 'PHP-7.4'
* PHP-7.4:
  Revert "Remove configure checks for supported instruction sets"
2019-11-04 11:34:02 +01:00
Nikita Popov
451314111b Revert "Remove configure checks for supported instruction sets"
This reverts commit edccf32f7f.

This was reported to cause issues for as yet unknown reasons in
bug #78769. As this was intended as code cleanup, revert this from
7.4 at least. May reapply it to master later.
2019-11-04 11:32:46 +01:00
Nikita Popov
1517bc4426 Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove configure checks for supported instruction sets
2019-10-31 11:34:15 +01:00