Skip to content

php-zlib-for-getimagesize.patch #4681

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

Open
wants to merge 2 commits into
base: PHP-8.0
Choose a base branch
from

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Sep 4, 2019

Make getimagesize() work for compressed .swf without static zlib extension.

In PLD LInux php-common was already linked with -lz.

This is long standing bug why (some) distros have to compile extensions like filter or zlib static:

As the missing symbol comes from libz not from ext-zlib, and -lz is present by default, the ifdef can just be removed.

Import PLD Linux patch:


Changes:

  • apply php-zlib-for-getimagesize.patch
  • add --with-zlib for library, --enable-zlib for extension

@glensc
Copy link
Contributor Author

glensc commented Sep 4, 2019

Tested on OSX:

./buildconf --force
export LDFLAGS=-L/usr/local/opt/bison/lib
export PATH="/usr/local/opt/bison/bin:$PATH"
export PATH="/usr/local/opt/ccache/libexec:$PATH"

prefix=/usr/local/etc/php/7.4
./configure \
	--with-config-file-path=$prefix \
	--with-config-file-scan-dir=$prefix/conf.d \
	--disable-all \
	--with-zlib \
	--config-cache
make
./sapi/cli/php -n -r 'var_dump(IMAGETYPE_SWC);'
int(13)

@glensc glensc marked this pull request as ready for review September 4, 2019 20:59
@glensc
Copy link
Contributor Author

glensc commented Sep 4, 2019

Tested on Linux:

./buildconf --force
export PATH="/usr/libexec/ccache:$PATH"

prefix=/usr/local/etc/php/7.4
./configure \
    --with-config-file-path=$prefix \
    --with-config-file-scan-dir=$prefix/conf.d \
    --disable-all \
    --with-zlib \
    --config-cache
make
./sapi/cli/php -r 'var_dump(IMAGETYPE_SWC);'
int(13)

@nikic
Copy link
Member

nikic commented Sep 4, 2019

@glensc Aren't you testing a statically built zlib extension in both cases there?

@glensc
Copy link
Contributor Author

glensc commented Sep 4, 2019

@nikic thanks, I was thinking there's something missing!

@@ -11,7 +11,7 @@
     --with-config-file-path=$prefix \
     --with-config-file-scan-dir=$prefix/conf.d \
     --disable-all \
-    --with-zlib \
+    --with-zlib=shared \
     --config-cache
 make
 ./sapi/cli/php --ini

but can't put the PR back to WIP it seems...

@nikic
Copy link
Member

nikic commented Sep 4, 2019

It's not obvious to me that this will work correctly in all cases, unless there is something that guarantees that -lz will be included.

PHP_EVAL_LIBLINE($ZLIB_LIBS, ZLIB_SHARED_LIBADD)
only adds the lib to ZLIB_SHARED_LIBADD, not the LIBS of the main executable.

Possibly the better way to go about this is to include a separate PKG_CHECK_MODULES for zlib in the ext/standard config.m4, so zlib availability here is checked independently of the zlib PHP extension.

@glensc

This comment was marked as resolved.

@glensc
Copy link
Contributor Author

glensc commented Sep 4, 2019

@nikic I think the -lz should be made independent of ext-zlib, as you said. In my distro somewhy the binary is already linked with -lz, did not find obvious patch that changed that behavior.

@glensc
Copy link
Contributor Author

glensc commented Sep 4, 2019

also, as I understood, there was some cleanup of --with and --enable, so it should be:

  • --with-zlib ... enable -lz finding and link with SAPI
  • --enable-zlib ... enable ext-zlib

right?

@glensc
Copy link
Contributor Author

glensc commented Sep 4, 2019

These should be also cleaned up (moved to standard) then:

  --with-zlib-dir[=DIR]   PDO_MySQL: Set the path to libz install prefix
  --with-zlib-dir[=DIR]   mysqlnd: Set the path to libz install prefix

Altho these should be just removed:

========================================
13. Migration to pkg-config
========================================

A number of extensions have been migrated to exclusively use pkg-config for the
detection of library dependencies. Generally, this means that instead of using
--with-foo-dir=DIR or similar only --with-foo is used. Custom library paths can
be specified either by adding additional directories to PKG_CONFIG_PATH or by
explicitly specifying compilation options through FOO_CFLAGS and FOO_LIBS.
...

  . --with-zlib-dir has been removed. zlib is required.

@glensc
Copy link
Contributor Author

glensc commented Sep 4, 2019

  • fd57df0 add --with-zlib for library, --enable-zlib for extension

This can be used for testing, but some cleanups are needed... especially as PHP_ARG_WITH(zlib) and PHP_ARG_ENABLE(zlib)create$PHP_ZLIB` variable...

$ ldd sapi/cli/php|grep libz
        libz.so.1 => /lib64/libz.so.1 (0x00007f285c7dd000)
$ ./sapi/cli/php -r 'var_dump(IMAGETYPE_SWC);'
int(13)

@nikic
Copy link
Member

nikic commented Sep 5, 2019

also, as I understood, there was some cleanup of --with and --enable, so it should be:

* `--with-zlib` ... enable `-lz` finding and link with SAPI

* `--enable-zlib` ... enable `ext-zlib`

right?

Not quite. Both --with and --enable generally refer to the extension. The former is used if it has an external dependency and the latter if it doesn't.

@nikic
Copy link
Member

nikic commented Sep 5, 2019

Dropped one of the --with-zlib-dirs in a2c21e1, because it was unused ... though mysqlnd generally has the same problem of checking for HAVE_ZLIB, even though this should be independent of the ext.

@glensc
Copy link
Contributor Author

glensc commented Sep 5, 2019

but HAVE_ZLIB is for <zlib.h>? no?

can you give direction to how to proceed here? I see it should be:

  • --with-zlib ... enable -lz finding and link with SAPI => HAVE_ZLIB
  • --enable-zlib[=shared|yes|no] ... enable ext-zlib => PHP_ZLIB

but due technical reasons PHP_ARG_WITH and PHP_ARG_ENABLE both create PHP_ZLIB, is there (easy) workaround to that?

@krakjoe
Copy link
Member

krakjoe commented Sep 30, 2019

@nikic I won't assign this to you, but since you have some cursory familiarity with this patch, could you give it a fresh read please and do words about it ...

@ramsey
Copy link
Member

ramsey commented May 31, 2022

What's the status of this PR? It looks like it's still waiting for review?

If this is a bug, should it target the PHP-8.0 branch instead of master?

@glensc glensc changed the base branch from master to PHP-8.0 May 31, 2022 23:11
glensc added 2 commits June 1, 2022 02:12
make getimagesize() work for compressed .swf without static zlib
extension.

php-common was already linked with -lz
@glensc glensc force-pushed the php-zlib-for-getimagesize.patch branch from fe2db8a to d95070f Compare May 31, 2022 23:12
@glensc
Copy link
Contributor Author

glensc commented May 31, 2022

Rebased for PHP-8.0 (3a8912f ).

@glensc
Copy link
Contributor Author

glensc commented Sep 28, 2022

Looks like my rebasing has still no interest in this...

@andypost
Copy link
Contributor

andypost commented Apr 9, 2024

It still valid, zlib hard to make shared

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.

6 participants