Skip to content

Linux FFI Extension #535

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
KingBes opened this issue Sep 5, 2024 · 6 comments · Fixed by #629
Closed

Linux FFI Extension #535

KingBes opened this issue Sep 5, 2024 · 6 comments · Fixed by #629
Labels
question Further information is requested

Comments

@KingBes
Copy link

KingBes commented Sep 5, 2024

Because of the limitations of the Linux system, it is possible to successfully compile the ffi extension, but it cannot be used to load other so extensions. The prerequisite for Linux to load so extensions is non-static compilation, but dynamic compilation conflicts with the purpose of this project.

This means that the composer package that requires ffi extension is not available, is there any alternative method?

@crazywhalecc crazywhalecc added the question Further information is requested label Sep 6, 2024
@crazywhalecc
Copy link
Owner

See: #376 (comment)

@henderkes
Copy link
Collaborator

We shoulld reopen this now, I think. @crazywhalecc

@crazywhalecc crazywhalecc reopened this Mar 11, 2025
@crazywhalecc
Copy link
Owner

crazywhalecc commented Mar 13, 2025

Currently using bin/spc-gnu-docker build --libc=glibc ffi --build-cli is available. No pain, no extra patches. We don't need to reopen this issue, as it's available after glibc mode supported. But we do need to update the documentation, and I'll do that later.

@henderkes
Copy link
Collaborator

I didn't know we already had FFI as an extension. That makes sense.

@KingBes
Copy link
Author

KingBes commented Mar 19, 2025

However, there are some issues with pure static linking of musl-libc binaries on Linux:
The dl() function in PHP cannot be used to load dynamic libraries and external PHP extensions.
The FFI extension in PHP cannot be used.
In some extreme cases, performance issues may occur. See musl-libc performance issues.

那么可以更换兼容 dl() 函数加载动态链接库和外部 PHP 扩展的编译器吗?比如:gcc 什么的。这样的话比较灵活一些。

@henderkes
Copy link
Collaborator

However, there are some issues with pure static linking of musl-libc binaries on Linux:
The dl() function in PHP cannot be used to load dynamic libraries and external PHP extensions.
The FFI extension in PHP cannot be used.
In some extreme cases, performance issues may occur. See musl-libc performance issues.

那么可以更换兼容 dl() 函数加载动态链接库和外部 PHP 扩展的编译器吗?比如:gcc 什么的。这样的话比较灵活一些。

#624

Sorry, I don't speak Chinese, but yes, dynamic loading of extensions works as long as they are compiled with the buildroot/bin/php-config and buildroot/bin/phpize.

FFI with dl() works too, if you enable it in php.ini.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants