[php-src] PR #20121: Fix JIT TLS on MacOS 15
| From: | arnaud-lb | Date: | Fri, 10 Oct 2025 10:21:48 +0000 |
| Subject: | [php-src] PR #20121: Fix JIT TLS on MacOS 15 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33556@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20121
Author: arnaud-lb
Since approximately MacOS 15, the dynamic loader changes the format of the TLV thunk, breaking our
resolution code.
Here we use the new format when we detect the new loader.
This is not a regression of the new TLS resolution code. This targets 8.5, but this needs to be
backported to 8.3.
Some background: https://github.com/apple-oss-distributions/dyld/blob/9307719dd8dc9b385daa412b03cfceb897b2b398/libdyld/ThreadLocalVariables.h#L46.
Since MacOS 15, the dynamic loaders patches the data emitted by the compiler, so that its format
changes from
```
struct Thunk {
void *func;
size_t module;
size_t offset;
}
```
to
```
struct Thunk_v2 {
void *func;
uint32_t module;
uint32_t offset;
// other fields
}
```
which has the same size, but not the same layout.
Possible alternative fixes:
* Disable JIT+TLS on MacOS (it's already disabled on JIT+TLS+Apple Silicon: https://github.com/php/php-src/pull/13396).
* Update JIT so it uses the slower fallback on MacOS: https://github.com/php/php-src/blob/02e38fe22e01c059a185ca8ca09b7bbdb43e4490/ext/opcache/jit/zend_jit_ir.c#L519
* Update JIT and IR so it calls
thunk->func(thunk), which has more ABI garantees
that the current method, but will be slower
cc @shivammathur