@@ -243,23 +243,10 @@ private static function init(): void
243243 if (!ini_get ('ffi.enable ' )) {
244244 throw new Exception ("ffi.enable not set to 'true' " );
245245 }
246- if (version_compare (PHP_VERSION , '8.3 ' , '>= ' ) &&
247- ini_get ('zend.max_allowed_stack_size ' ) != '-1 ' ) {
248- throw new Exception ("zend.max_allowed_stack_size not set to '-1' " );
249- }
250246
251- // Use "libvips.so" on Termux, otherwise use the standard versioned library
252- $ vips_libname = getenv ('PREFIX ' ) === '/data/data/com.termux/files/usr '
253- ? "libvips.so "
254- : self ::libraryName ("libvips " , 42 );
255-
256- if (PHP_OS_FAMILY === "Windows " ) {
257- $ glib_libname = self ::libraryName ("libglib-2.0 " , 0 );
258- $ gobject_libname = self ::libraryName ("libgobject-2.0 " , 0 );
259- } else {
260- $ glib_libname = $ vips_libname ;
261- $ gobject_libname = $ vips_libname ;
262- }
247+ $ vips_libname = self ::libraryName ("libvips " , 42 );
248+ $ glib_libname = self ::libraryName ("libglib-2.0 " , 0 );
249+ $ gobject_libname = self ::libraryName ("libgobject-2.0 " , 0 );
263250
264251 Utils::debugLog ("init " , ["library " => $ vips_libname ]);
265252
@@ -779,21 +766,24 @@ private static function init(): void
779766 }
780767
781768 Utils::debugLog ("init " , ["binding ... " ]);
782- self ::$ glib = self ::libraryLoad (
783- $ libraryPaths ,
784- $ glib_libname ,
785- $ glib_decls
786- );
787- self ::$ gobject = self ::libraryLoad (
788- $ libraryPaths ,
789- $ gobject_libname ,
790- $ gobject_decls
791- );
792- self ::$ vips = self ::libraryLoad (
793- $ libraryPaths ,
794- $ vips_libname ,
795- $ vips_decls
796- );
769+
770+ /**
771+ * We can sometimes get dependent libraries from libvips -- either the platform
772+ * will open dependencies for us automatically, or the libvips binary has been
773+ * built to includes all main dependencies (common on Windows, can happen
774+ * elsewhere).
775+ *
776+ * We must get GLib functions from libvips if we can, since it will be the
777+ * one that libvips itself is using, and they will share runtime types.
778+ */
779+ self ::$ glib =
780+ self ::libraryLoad ($ libraryPaths , $ vips_libname , $ glib_decls ) ??
781+ self ::libraryLoad ($ libraryPaths , $ glib_libname , $ glib_decls );
782+ self ::$ gobject =
783+ self ::libraryLoad ($ libraryPaths , $ vips_libname , $ gobject_decls ) ??
784+ self ::libraryLoad ($ libraryPaths , $ gobject_libname , $ gobject_decls );
785+
786+ self ::$ vips = self ::libraryLoad ($ libraryPaths , $ vips_libname , $ vips_decls );
797787
798788 # Useful for debugging
799789 # self::$vips->vips_leak_set(1);
0 commit comments