Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Conversation

danog
Copy link
Contributor

@danog danog commented May 25, 2023

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).

@devnexen devnexen closed this in 1dfa277 May 27, 2023
@devnexen
Copy link
Member

Thanks for working on this as the riscv64 arch is not exactly super spread (yet)

@danog
Copy link
Contributor Author

danog commented May 27, 2023

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 :)

@iluuu1994
Copy link
Member

@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

@dstogov
Copy link
Member

dstogov commented May 29, 2023

@danog implementing new JIT back-ends through https://github.com/dstogov/ir should be much easier.

@danog
Copy link
Contributor Author

danog commented May 29, 2023

I saw, your IR framework is really neat!
I'll contribute my riscv64 port over there then :)

bob-beck pushed a commit to openbsd/ports that referenced this pull request Jul 24, 2023
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)
petk pushed a commit that referenced this pull request Aug 28, 2023
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
@danog danog deleted the fix_riscv64 branch September 16, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants