-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix GCC 12 compilation on riscv64 #11321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for working on this as the riscv64 arch is not exactly super spread (yet) |
I have a visionfive2 board bought explicitly for the purpose of improving RISC-V support for PHP, I'm currently working on a RISC-V port of PHP's JIT compiler :) |
@danog That's great! Just be aware, Dmitry is working on a new version of the JIT, with plans to completely replace the old JIT in PHP 9.0. The goal is to have a common frontend to avoid 1:1 compilation of PHP opcodes to each individual architecture. https://github.com/dstogov/ir I'm not sure how much sense it makes to add support for new architectures in the current JIT at this point. /cc @dstogov |
@danog implementing new JIT back-ends through https://github.com/dstogov/ir should be much easier. |
I saw, your IR framework is really neat! |
Drop autoconf goo added for gcc <= 12.2, which falls back to an __atomic_exchange_1 library call for atomic ops on bytes on riscv64. At least clang-13 doesn't need this, but the AC_CHECK_LIB() autoconf check is too naive to notice. Similar to AC_SEARCH_LIBS(), PHP_CHECK_FUNC() only calls PHP_ADD_LIBRARY() if an additional library is needed to resolve the looked up symbol.. Upstream original PR: php/php-src#11321 ok sthen@ (maintainer)
clang and newer gcc releases support byte-sized atomic accesses on riscv64 through inline builtins. In both cases the hard dependency on libatomic added by GH-11321 isn't useful. Stop using AC_CHECK_LIB() which is too naive to notice that libatomic isn't needed. Instead, PHP_CHECK_FUNC() will retry the check with -latomic if required. Closes GH-11790
Fixes "undefined reference to `__atomic_exchange_1'" errors when compiling on riscv64 with GCC 12.
Newer versions of GCC should inline these atomics (https://www.mail-archive.com/[email protected]/msg283700.html), this PR fixes compilations on slightly older versions of GCC, like the one distributed on Debian 12 (currently GCC 12.2).