pnggroup / libpng

LIBPNG: Portable Network Graphics support, official libpng repository
http://libpng.sf.net
Other
1.24k stars 606 forks source link

libpng: APIs that are currently used #542

Open jbowler opened 7 months ago

jbowler commented 7 months ago

libpng-ng will, with any luck, be able to remove or at least deprecate a range of APIs. As a first step I have built libpng16 with as many APIs as possible removed. This was achieved using a new configuration file, contrib/conftest/basic.dfa and a gentoo build of all the packages I have which depend directly on libpng (36 packages). The configuration was built up from pretty much everything disabled until I had a complete build of everything.

The result of this unfortunately still contains a large proportion of the 'read' APIs; the only read API which isn't used anywhere in those 36 packages is the "simplified" API. This probably reflects the fact that most of the packages have been around in one form or another form many years, probably dating back to libpng 1.4 or earlier.

On the other hand the 'write' code did seem to have fewer requirements despite being far simpler than the read side.

jbowler commented 7 months ago

This is the generated 'pnglibconf.h' from the 'basic' configuration. It can be compared directly with an installed pnglibconf.h (e.g. /usr/include/pnglibconf.h) to see what I was able to disalbe. pnglibconf.h.TXT

jbowler commented 7 months ago

Here is the actual result in terms of changed DLL sizes:

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

Section | Type | Full | Basic | Change -- | -- | -- | -- | -- .symtab | SYMTAB | 15192 | 12144 | 80% .rodata | PROGBITS | 18460 | 12020 | 65% .text | PROGBITS | 210915 | 132028 | 63% .got.plt | PROGBITS | 1152 | 832 | 72% .plt.got | PROGBITS | 16 | 8 | 50% .rela.dyn | RELA | 216 | 192 | 89% .rela.plt | RELA | 3384 | 2424 | 72% .got | PROGBITS | 48 | 40 | 83% .strtab | STRTAB | 11873 | 9295 | 78% .dynstr | STRTAB | 5397 | 4367 | 81% .dynsym | DYNSYM | 6984 | 5664 | 81% .plt | PROGBITS | 2272 | 1632 | 72% TOTAL |   | 275909 | 180646 | 65%

It's difficult to know how accurate this is; a 63% or so reduction in .text and .rodata seems like a substantial reduction, however some major functionality has clearly been lost (the simplified API) and some features have certainly been removed (quantization for example). The simplified API can easily be moved to a separate library/DLL; it was designed to be free-standing and it currently only uses one "backdoor".

jbowler commented 7 months ago

The new configuration plus fixes in some of the test files so that 'make check' (cmake 'make test') pass is in https://github.com/pnggroup/libpng/pull/543

jbowler commented 6 months ago

This is the full list of known reverse dependencies by package and version in gentoo. It's probably fairly authoritative for mainstream pacakges:

https://packages.gentoo.org/packages/media-libs/libpng/reverse-dependencies

thesamesam commented 6 months ago

If desired, on our end, we could arrange for a tinderbox build against a patched libpng (not exposed to users) if you're happy to then triage and investigate any bugs.

ctruta commented 6 months ago

Thank you very much @thesamesam, this is very good to know. My current plan is to release the upcoming libpng-1.6.43, hopefully in not too many days from now, and then to fork a new branch and experiment with removals of long-deprecated features.

Ping you later 😉

ctruta commented 6 months ago

Umm, actually, on a second thought...

If you could please email me at @ctruta (at gmail), I can prepare a patch to be applied to the tip-of-tree, and send it to you @thesamesam and/or submit it to the tinderbox build -- with the understanding that I have no understanding how this works.

I'm a Linux Mint kind of guy. My idea of being "adventurous" was to distro-hop from Linux Mint to LMDE. Having said that, I cannot fail to recognize Gentoo for being the first Linux distro to package and ship OptiPNG 😄