Skip to content

PHP 8.5.0: preserve_none check fails on macOS (undefined symbol fun as macOS uses _fun) #20546

Closed

Description

@cho-m

Description

While preparing PHP 8.5.0 release in Homebrew (Homebrew/homebrew-core#255299), I noticed that the new TAILCALL VM feature wasn't getting enabled on macOS.

From config.log, the error is

configure:81621: checking for preserve_none calling convention
configure:81715: clang -o conftest -g -O2 -ffp-contract=off -fvisibility=hidden -DNDEBUG  -D_GNU_SOURCE  -Wl,-rpath,/opt/homebrew/Cellar/openssl@3/3.6.0/lib -L/opt/homebrew/Cellar/openssl@3/3.6.0/lib -Wl,-rpath,/opt/homebrew/Cellar/pcre2/10.47/lib -L/opt/homebrew/Cellar/pcre2/10.47/lib -Wl,-rpath,/opt/homebrew/opt/sqlite/lib -L/opt/homebrew/opt/sqlite/lib -Wl,-rpath,/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/lib -Wl,-rpath,/opt/homebrew/Cellar/curl/8.17.0/lib -L/opt/homebrew/Cellar/curl/8.17.0/lib -Wl,-rpath,/opt/homebrew/Cellar/gd/2.3.3_6/lib -L/opt/homebrew/Cellar/gd/2.3.3_6/lib -Wl,-rpath,/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/gettext/lib -Wl,-rpath,/opt/homebrew/opt/gmp/lib -L/opt/homebrew/opt/gmp/lib -Wl,-rpath,/opt/homebrew/opt/openldap/lib -L/opt/homebrew/opt/openldap/lib -Wl,-rpath,/opt/homebrew/Cellar/oniguruma/6.9.10/lib -L/opt/homebrew/Cellar/oniguruma/6.9.10/lib -Wl,-rpath,/opt/homebrew/Cellar/unixodbc/2.3.14/lib -L/opt/homebrew/Cellar/unixodbc/2.3.14/lib -Wl,-rpath,/opt/homebrew/opt/freetds/lib -L/opt/homebrew/opt/freetds/lib -Wl,-rpath,/opt/homebrew/opt/libpq/lib -L/opt/homebrew/opt/libpq/lib -Wl,-rpath,/opt/homebrew/Cellar/net-snmp/5.9.4/lib -L/opt/homebrew/Cellar/net-snmp/5.9.4/lib -Wl,-rpath,/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/openssl@3/lib -Wl,-rpath,/opt/homebrew/Cellar/libsodium/1.0.20/lib -L/opt/homebrew/Cellar/libsodium/1.0.20/lib -Wl,-rpath,/opt/homebrew/Cellar/argon2/20190702_1/lib -L/opt/homebrew/Cellar/argon2/20190702_1/lib -Wl,-rpath,/opt/homebrew/opt/tidy-html5/lib -L/opt/homebrew/opt/tidy-html5/lib -Wl,-rpath,/opt/homebrew/Cellar/libzip/1.11.4/lib -L/opt/homebrew/Cellar/libzip/1.11.4/lib conftest.c  >&5
Undefined symbols for architecture arm64:
  "fun", referenced from:
      _test in conftest-4b4b9c.o
      _main in conftest-4b4b9c.o

This can also be reproduced by just trying to manually compile - https://github.com/php/php-src/blob/php-8.5.0/Zend/Zend.m4#L479

The issue is due to macOS symbol being _fun not fun, e.g.

❯ clang -c test.c && nm -gU test.o | grep fun
0000000000000000 T _fun

"bl fun\n"

Also, minor issue but there is a typo (preverve) which I noticed when trying to override the cache variable

[php_cv_preverve_none],

PHP Version

PHP 8.5.0 (cli) (built: Nov 18 2025 08:02:20) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.5.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0, Copyright (c), by Zend Technologies

Operating System

macOS 26

Activity

  1. devnexen commented on Nov 22, 2025

    @devnexen
    Member

    Nice report. The following little changes fix it for me (I know mac intel are no longer a thing but just in case..)

    diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
    index 1e1853167cf..33009e9909f 100644
    --- a/Zend/Zend.m4
    +++ b/Zend/Zend.m4
    @@ -474,7 +474,7 @@ dnl expectations.
     dnl
     AC_DEFUN([ZEND_CHECK_PRESERVE_NONE], [dnl
       AC_CACHE_CHECK([for preserve_none calling convention],
    -   [php_cv_preverve_none],
    +   [php_cv_preserve_none],
        [AC_RUN_IFELSE([AC_LANG_SOURCE([[
     #include <stdio.h>
     #include <stdint.h>
    @@ -504,7 +504,11 @@ uintptr_t __attribute__((preserve_none)) test(void) {
                    "movq %2, %%r13\n"
                    "xorq %3, %%r13\n"
                    "xorq %%rax, %%rax\n"
    +#if defined(__APPLE__)
    +               "call _fun\n"
    +#else
                    "call fun\n"
    +#endif
                    : "=a" (ret)
                    : "r" (const1), "r" (const2), "r" (key)
                    : "r12", "r13"
    @@ -515,7 +519,11 @@ uintptr_t __attribute__((preserve_none)) test(void) {
                    "eor    x20, %1, %3\n"
                    "eor    x21, %2, %3\n"
                    "eor    x0, x0, x0\n"
    +#if defined(__APPLE__)
    +               "bl     _fun\n"
    +#else
                    "bl     fun\n"
    +#endif
                    "mov    %0, x0\n"
                    : "=r" (ret)
                    : "r" (const1), "r" (const2), "r" (key)
  2. added a commit that references this issue on Nov 22, 2025
    8130dee
  3. added 2 commits that reference this issue on Nov 22, 2025
    56dd321
    1787765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions