[php-src] PR #16348: Fix GH-16168: php 8.1 and earlier crash immediately when compiled with Xcode 16 clang on macOS 15
| From: | nielsdos | Date: | Thu, 10 Oct 2024 20:48:36 +0000 |
| Subject: | [php-src] PR #16348: Fix GH-16168: php 8.1 and earlier crash immediately when compiled with Xcode 16 clang on macOS 15 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29138@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/16348
Author: nielsdos
The inline assembly uses labels with the prefix
.L. On Linux systems this is the local
label prefix. It appears that macOS uses L as a local prefix, which means that the
prefix used in the inline assembly is not local for macOS systems [1].
This causes the compiler to get confused and move part of the inline assembly into another function.
This is avoided on PHP 8.2 and up by the fact that it uses zend_never_inline NOIPA, but
nothing guarantees that compiler changes won't affect this as well.
To solve this issue, we instead use local labels. These will make the compiler pick the correct
prefix, preventing the issue.
Additionally, while here, we also change the computation of delta. It is undefined
behaviour to compute the pointer difference between two different objects. To circumvent this, we
cast first to uintptr_t.
This change is cleanly backportable to 8.1 for vendors to pick up.
[1] https://github.com/php/php-src/issues/16168#issuecomment-2404792553
This was tested by @ryandesign on their macOS machine with their setup and this patch works for them
on old versions too.