-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Allow loading FFI bindings through ffi.preload directive #4842
Conversation
@dstogov thanks for your work Can you please clarify how to use it ? |
$ php -dffi.preload=ext/ffi/tests/300.h -r 'FFI::scope("TEST_300")->printf("Hello World from %s!\n", "PHP");' |
Just remove FFI::load() and add "ffi.preload" directive. |
OK, indeed it works this way. Could be nice to disallow opcache.preload... when FFI is used.... |
You probably mean FFI::load()? |
Hmm... no trying to understand an d avoid segfault ;) Looks like a simple call with a static property is enough to raise a segfault
So seems another issue (not FFI related)
So perhaps the reason for this segfault reported in #78713 (the static property is used as singleton) |
@remicollet the crash should be fixed by previous commit. Could you please recheck. |
@dstogov indeed, segfault with singleton is fixed. |
Looks like it works as expected
Without this PR, and only with the "Allocate" fix, I don't encounter any segfault, but "FFI::scope" fails (so FFI::load is always used) So the warning is indeed needed. Great work! |
Fix compilation on Windows: ext/opcache/ZendAccelerator.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 54e6fdf6cf..704e1c38d9 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -4590,9 +4590,11 @@ static int accel_finish_startup(void)
sapi_module.ub_write = preload_ub_write;
sapi_module.flush = preload_flush;
+#ifndef ZEND_WIN32
if (in_child) {
CG(compiler_options) |= ZEND_COMPILE_PRELOAD_IN_CHILD;
}
+#endif
CG(compiler_options) |= ZEND_COMPILE_PRELOAD;
CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY;
CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; |
@cmb69 thanks |
@dstogov, you're welcome! |
Merged into PHP-7.4 as 1417352 |
No description provided.