Nothing Special   »   [go: up one dir, main page]

Skip to content
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

Error when building TSRM in ARM64 #11188

Closed
AndrewKusov opened this issue May 4, 2023 · 2 comments
Closed

Error when building TSRM in ARM64 #11188

AndrewKusov opened this issue May 4, 2023 · 2 comments

Comments

@AndrewKusov
Copy link
AndrewKusov commented May 4, 2023

Description

When building in ARM64 with the --enable-zts flag, I get an error similar to the one described in this bug report - https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266175. Please make corrections for TSRM for this architecture, they are already available on the website

PHP Version

PHP 8.2.5

Operating System

No response

@iluuu1994
Copy link
Member
iluuu1994 commented May 7, 2023

@AndrewKusov Can you provide your ./configure flags and the full error message? We have an ARM build with --enable-zts so that alone seems not to be enough for reproducing the problem.

Edit: On, this is FreeBSD. We only have a x86 build here. Still, the full error would be good.

@nielsdos
Copy link
Member
nielsdos commented May 11, 2023

I can reproduce this in an AArch64 emulator running FreeBSD.

Full error:

--- libphp.la ---
ld: error: relocation R_AARCH64_TLSLE_ADD_TPREL_HI12 against _tsrm_ls_cache cannot be used with -shared
>>> defined in Zend/.libs/zend.o
>>> referenced by TSRM.c:788 (TSRM/TSRM.c:788)
>>>               TSRM/.libs/TSRM.o:(tsrm_get_ls_cache_tcb_offset)

ld: error: relocation R_AARCH64_TLSLE_ADD_TPREL_LO12_NC against _tsrm_ls_cache cannot be used with -shared
>>> defined in Zend/.libs/zend.o
>>> referenced by TSRM.c:788 (TSRM/TSRM.c:788)
>>>               TSRM/.libs/TSRM.o:(tsrm_get_ls_cache_tcb_offset)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [libphp.la] Error code 1

Used this configure line: ./configure --disable-all --enable-debug --enable-opcache --enable-zts --with-libxml --disable-phpdbg --enable-embed.

The proposed fix in the linked thread is not good however, it just disables the JIT and ifdefs the offending code.

Note: I have a dev setup where I can take a look at this soon-ish

@nielsdos nielsdos self-assigned this May 12, 2023
nielsdos added a commit to nielsdos/php-src that referenced this issue May 12, 2023
Although the issue mentioned FreeBSD, this is a broader problem that
might also apply on Linux: the current ARM64 code to load the TLS offset
assumes a setup without PIC.
If --with-pic is provided, or PHP is built as a shared object, the
existing code will not work. We have to call into the TLS descriptor
similarly as how the C compiler does it.
Although it looks like a lot of inline assembly, the compiler actually
optimizes this into only a few instructions on my emulator.
nielsdos added a commit to nielsdos/php-src that referenced this issue May 12, 2023
Although the issue mentioned FreeBSD, this is a broader problem that
might also apply on Linux: the current ARM64 code to load the TLS offset
assumes a setup without PIC.
If --with-pic is provided, or PHP is built as a shared object, the
existing code will not work. We have to call into the TLS descriptor
similarly as how the C compiler does it.
Although it looks like a lot of inline assembly, the compiler actually
optimizes this into only a few instructions on my emulator.
@nielsdos nielsdos linked a pull request May 12, 2023 that will close this issue
nielsdos added a commit to nielsdos/php-src that referenced this issue May 12, 2023
Although the issue mentioned FreeBSD, this is a broader problem that
might also apply on Linux: the current ARM64 code to load the TLS offset
assumes a setup with the default TLS model.
If --with-pic is provided, or PHP is built as a shared object, the
existing code will not work. We have to call into the TLS descriptor
similarly as how the C compiler does it.
This patch adds the code that handles the different TLS model cases.
Although it looks like a lot of inline assembly, the compiler actually
optimizes this into only a few instructions on my emulator.
nielsdos added a commit to nielsdos/php-src that referenced this issue May 12, 2023
Although the issue mentioned FreeBSD, this is a broader problem that
might also apply on Linux: the current ARM64 code to load the TLS offset
assumes a setup with the default TLS model.
If --with-pic is provided, or PHP is built as a shared object, the
existing code will not work. We have to call into the TLS descriptor
similarly as how the C compiler does it.
This patch adds the code that handles the different TLS model cases.
Although it looks like a lot of inline assembly, the compiler actually
optimizes this into only a few instructions on my emulator.
nielsdos added a commit to nielsdos/php-src that referenced this issue May 12, 2023
Although the issue mentioned FreeBSD, this is a broader problem:
the current ARM64 code to load the TLS offset assumes a setup with
the non-default TLS model.
We have to call into the TLS descriptor similar as how the C compiler does it.
Although it looks like a lot of inline assembly, the compiler actually
optimizes this into only a few instructions on my emulator.
nielsdos added a commit to nielsdos/php-src that referenced this issue May 12, 2023
Although the issue mentioned FreeBSD, this is a broader problem:
the current ARM64 code to load the TLS offset assumes a setup with
the non-default TLS model. This problem can also apply on some
configurations on other platforms.
For the default mode, we have to call into the TLS descriptor similar
as how the C compiler does it. Although it looks like a lot of
inline assembly, the compiler actually optimizes this into only
a few instructions on my emulator.
Similarly, this patch adds support for other TLS models too.
nielsdos added a commit to nielsdos/php-src that referenced this issue May 29, 2024
Although the issue mentioned FreeBSD, this is a broader problem:
the current ARM64 code to load the TLS offset assumes a setup with
the non-default TLS model. This problem can also apply on some
configurations on other platforms.
For the default mode, we have to call into the TLS descriptor similar
as how the C compiler does it. Although it looks like a lot of
inline assembly, the compiler actually optimizes this into only
a few instructions on my emulator.
Similarly, this patch adds support for other TLS models too.
nielsdos added a commit to nielsdos/php-src that referenced this issue May 30, 2024
Although the issue mentioned FreeBSD, this is a broader problem:
the current ARM64 code to load the TLS offset assumes a setup with
the non-default TLS model. This problem can also apply on some
configurations on other platforms.
nielsdos added a commit to nielsdos/php-src that referenced this issue May 31, 2024
Although the issue mentioned FreeBSD, this is a broader problem:
the current ARM64 code to load the TLS offset assumes a setup with
the non-default TLS model. This problem can also apply on some
configurations on other platforms.
nielsdos added a commit that referenced this issue Jun 3, 2024
* PHP-8.2:
  Fix GH-11188: Error when building TSRM in ARM64
nielsdos added a commit that referenced this issue Jun 3, 2024
* PHP-8.3:
  Fix GH-11188: Error when building TSRM in ARM64
nielsdos added a commit to nielsdos/php-src that referenced this issue Jun 3, 2024
nielsdos added a commit that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants