Repository navigation
Upgrade bundled third-party libraries (zlib, libpng, libjpeg, libtiff, FreeType) - #222
Open
FabienMathieu wants to merge 10 commits into
Open
FabienMathieu wants to merge 10 commits into
FabienMathieu wants to merge 10 commits into
Conversation
added 10 commits
October 29, 2026 17:03
…cludes - Call cmake_minimum_required(VERSION 3.5...3.31) before project() so CMake 4 configures without -DCMAKE_POLICY_VERSION_MINIMUM. - Remove the bundled ParseArguments.cmake: it overrode the built-in cmake_parse_arguments and broke modules such as CheckTypeSize. - Add cmake/ThirdParty.cmake with platform checks and a VL_THIRDPARTY_TARGET() helper for the bundled libraries. - Remove include_directories() in vlCore/plugins that pointed to a non-existent path.
Vendor only the library sources, headers, LICENSE, README and ChangeLog from the official release (SHA-256 checked against zlib.net). Upstream no longer treats modern macOS as classic Mac OS (fdopen defined as NULL), and HAVE_UNISTD_H/HAVE_STDARG_H now come from configure checks.
- Vendor the library sources/headers plus the upstream prebuilt pnglibconf.h (SHA-256 checked against the SourceForge release). - Build without SIMD filter code on all architectures so no per-architecture sources are needed. - ioPNG: png_check_sig() was removed, use png_sig_cmp(). Re-enable setjmp error recovery, which libpng 1.6 requires (otherwise it aborts on corrupt files). The setjmp calls live in helpers that hold no C++ objects with destructors, so longjmp is well-defined. Errors while saving now return false instead of aborting.
- Vendor the library sources/headers into src/external/libjpeg (SHA-256 checked against the Homebrew formula for jpegsrc.v9f). - Source list follows upstream makefile.vc (adds arithmetic coding, drops the 6b progressive/reduced IDCT files merged into others). - A single VL-owned jconfig.h (from upstream jconfig.vc) is used on all platforms so libjpeg, libtiff and ioJPG.cpp agree on 'boolean'. The old VL edits to jmorecfg.h are no longer needed: libjpeg 9 handles the Windows INT32 clash itself. - ioJPG: always request RGB output for colour images so libjpeg 9's BG_RGB/BG_YCC colour spaces are converted instead of tripping a check.
- Vendor only the upstream libtiff/ subdirectory (GPG signature verified). Without the top-level VERSION file in an include directory, <version> is no longer shadowed on case-insensitive file systems (macOS, Windows). - Generate tif_config.h/tiffconf.h from the upstream .cmake.in templates with platform checks, instead of the hard-coded 3.8.2 headers (which e.g. assumed 32-bit long and never included unistd.h). - Use tif_win32.c on Windows and tif_unix.c elsewhere, as upstream does. - Link TIFF against ZLib and JPG to get their include paths. - ioTIFF: use the 4.x callback signatures (tmsize_t, 64-bit toff_t) without truncating casts, and uint32_t/uint16_t instead of the deprecated libtiff typedefs.
- Vendor include/, the src/ modules in upstream's default build, and the licence files (GPG signature verified). - Source list follows upstream BASE_SRCS (adds sdf, svg, hvf, bzip2 stub; drops ftxf86, ftlcdfil, gxvalid and otvalid, which were never registered in ftmodule.h). Uses the portable ANSI ftsystem.c on every platform. - Drop base/ftmac.c and the AppKit link on macOS: it only provides the deprecated Carbon font APIs, and VL loads fonts from memory. - Stock ftoption.h: no new external dependencies. The internal zlib copy used for .gz fonts no longer has the classic Mac OS issues. No VL source changes needed: Font.cpp's FT_ERRORDEF table still works with FreeType 2.15's fterrors.h.
ioJPG installed an error_exit handler that longjmp'd to a jmp_buf whose setjmp() was disabled (#if 0), so any corrupt or truncated JPEG segfaulted. saveJPG used the default handler, which calls exit(). Both paths now run libjpeg inside helpers that set up setjmp() and hold no C++ objects, mirroring ioPNG, and return NULL/false on error. ioPNG's error callback now longjmps itself, so libpng doesn't print each error a second time. Verified with truncated and corrupted PNG, JPEG and TIFF files.
Builds Debug/Release, shared/static with GCC and Clang on Linux, Apple Clang on macOS and MSVC on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The libraries bundled in
src/external/were 10 to 28 years old, and VL no longer built with current toolchains. On recent macOS SDKs the old zlib, libpng and FreeType took classic Mac OS code paths, and libtiff'sVERSIONfile shadowed the C++<version>header. This PR replaces each library with its current upstream release, without patching any vendored code.All downloads were verified. zlib and libpng match their published SHA-256 checksums, libtiff and FreeType have valid GPG signatures, and libjpeg matches the SHA-256 recorded by Homebrew.
Changes
cmake_minimum_required(VERSION 3.5...3.31)lets CMake 4 configure without extra flags.cmake/ParseArguments.cmake, which overrode a built-in command and broke CMake's own modules.cmake/ThirdParty.cmakeholds the platform checks and shared target settings: PIC, MSVC defines, and warnings off for third-party code.ioPNG.cppusespng_sig_cmpand propersetjmp/png_longjmperror handling, since libpng 1.6 aborts if the error handler returns.jconfig.his shared by libjpon every platform, so they agree onboolean`.ioTIFF.cppis ported to the 4.x off_t,uint32_t/uint16_t`.tif_win32.cis used onWindows.
ftmac.cand the AppKit link; VL loads fonts from memory.exit(). Both now return an error. Corrupt PNGs are handVL_TRAPuses__builtin_trap()on non-x86 targets, which fixes arm64 builds.Debug/Release and shared/static.
src/external/README.mdlists the bundled versions and the upgrade procedure.Testing
bundled code.
Notes
libglu1-mesa-devecule uses GLU.(int)casts, becauseFT_Bitmap::rows/widthare now unsigned.