Skip to content

[libjpeg-turbo] Patch vcpkg dependencies for 3.2.0 - #52891

Open
tartanpaint wants to merge 39 commits into
microsoft:masterfrom
tartanpaint:libjpeg-turbo-3.2.0-dependencies-patch
Open

[libjpeg-turbo] Patch vcpkg dependencies for 3.2.0#52891
tartanpaint wants to merge 39 commits into
microsoft:masterfrom
tartanpaint:libjpeg-turbo-3.2.0-dependencies-patch

Conversation

@tartanpaint

@tartanpaint tartanpaint commented Jul 14, 2026

Copy link
Copy Markdown
Contributor
  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version, or no changes were necessary.
  • Any fixed CI baseline and CI feature baseline entries are removed from that file, or no entries needed to be changed.
  • All patch files in the port are applied and succeed.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Exactly one version is added in each modified versions file.

The port file update will use the zlib and libspng dependencies introduced with libjpeg-turbo 3.2.0 from vcpkg rather than building additional copies of these from the libjpeg-turbo source tree.
The libjpeg-turbo patch files have been generated directly from commits in the upstream project repository and may be removed with a port update to a future version of libjpeg-turbo. Related libjpeg-turbo issue: libjpeg-turbo/libjpeg-turbo#901

@tartanpaint
tartanpaint marked this pull request as draft July 14, 2026 21:56
@BillyONeal

Copy link
Copy Markdown
Member

The static versions are all likely failing due to this problem GPT 5.6 Sol found:

The PR switches static turbojpeg to external libspng/zlib dependencies, but the installed libturbojpeg.pc still publishes only -lturbojpeg. Because upstream already provides pkg-config metadata, vcpkg review checks that integration when present (review guide). Static pkg-config consumers therefore miss the new dependencies introduced by the port changes (vcpkg.json, portfile.cmake); the upstream template has no Requires.private or Libs.private entry for those libraries (libturbojpeg.pc.in).

Fix: update the packaging/patch so pkg-config --static --libs libturbojpeg emits complete static link metadata for the vcpkg build. Since libspng does not currently provide a pkg-config file in vcpkg, Requires.private: spng alone is not enough unless that integration is added; otherwise use appropriate Libs.private entries for the vcpkg dependency chain and verify a static pkg-config consumer links.

You might also want to fix this other bit it found while you are here but that's not blocking:

The manifest still declares only BSD-3-Clause, while upstream documents IJG licensing for the libjpeg API and inherited code in addition to BSD-3-Clause for TurboJPEG (upstream license). vcpkg expects license metadata to match the installed package and upstream terms (manifest license docs. This mismatch predates the PR.

Comment on lines +6 to +7
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.1)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these CMAKE_MINIMUM_REQUIRED changes are not necessary in a vcpkg patch. vcpkg uses CMake > 4 and does set(ENV{CMAKE_POLICY_VERSION_MINIMUM} 3.5)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These CMake changes are part of the upstream PR used to generate the patch file: OpenKinect/libfreenect2#1209


IF(LIBFREENECT2_WITH_VT_SUPPORT)
- FIND_PACKAGE(TurboJPEG)
+ find_package(libjpeg-turbo CONFIG)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might do

Suggested change
+ find_package(libjpeg-turbo CONFIG)
+ find_package(TurboJPEG NAMES libjpeg-turbo)

and get the original TurboJPEG_FOUND. And then reduce patching in other spots.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've regenerated the find_libjpegturbo.patch file to instead modify the cmake_modules/FindTurboJPEG.cmake file, leaving the main CMakeLists.txt file for libfreenect2 unmodified. Hopefully this is acceptable.

Comment on lines +37 to +40
+ find_dependency(PkgConfig)
+ if(PkgConfig_FOUND)
+ pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET)
+ endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using imported targets from pkgconfig is complicated for reverse dependencies with MSVC. In other ports we use the variables (and in particular <Prefix>_LINK_LIBRARIES) to get resolved libs instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These patches are generated from upstream libjpeg-turbo commits which will be included in the next libjpeg-turbo release. The patches may therefore be removed from the portfile when an update is available for the next version of libjpeg-turbo.
I've included comments in the portfile referencing the upstream commits used for the patch files.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not true in general. If we see something bogus we can fix bogus and submit the fix for bogus upstream. I agree with Kai Pastor (@dg0yt) and think this is incorrect. Zlib has conventions for how it is found in CMake, and libspng publishes CMake configs: https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/CMakeLists.txt#L65-L81

We should stay entirely in the CMake configs namespace if at all possible and it appears possible here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, this is confusing because it's patches on patches. Kai Pastor (@dg0yt) I think your comment is resolved by 0002+0003 in this series.

+ if(PkgConfig_FOUND)
+ pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET)
+ endif()
+ else()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean

Suggested change
+ else()
+ endif()
+ if(WITH_SYSTEM_ZLIB)

(one extra line)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also is from the upstream libjpeg-turbo commits used to generate the patch file. The intention would be that these patches can be removed in a future release while maintining the same functionality. The specific commits used for the libjpeg-turbo patches are now listed in comments in the portfile.

@tartanpaint
tartanpaint marked this pull request as ready for review August 20, 2026 06:49

@BillyONeal Billy O'Neal (BillyONeal) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pkgconfig fix for libspng is not quite right because they make libspng_static.pc for static targets. I'm trying to prepare a fix for upstream. But for now posting this stuff about the freenect2 changes because that's separable.

Comment thread ports/libfreenect2/portfile.cmake Outdated
Comment on lines +38 to +41
# force use of OpenCL 1.2
#string(APPEND VCPKG_CXX_FLAGS " -DCL_TARGET_OPENCL_VERSION=120")
#string(APPEND VCPKG_C_FLAGS " -DCL_TARGET_OPENCL_VERSION=120")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not check in commented out code unless we are documenting specific instructions on how one is to create an overlay. Also given the changes to vcpkg_cmake_configure below it seems likely that these are wrong.

Also GPT 5.6 Sol observes that both of these are dead / disconnected.

Comment on lines +37 to +40
+ find_dependency(PkgConfig)
+ if(PkgConfig_FOUND)
+ pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET)
+ endif()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not true in general. If we see something bogus we can fix bogus and submit the fix for bogus upstream. I agree with Kai Pastor (@dg0yt) and think this is incorrect. Zlib has conventions for how it is found in CMake, and libspng publishes CMake configs: https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/CMakeLists.txt#L65-L81

We should stay entirely in the CMake configs namespace if at all possible and it appears possible here.

Comment thread ports/libfreenect2/vcpkg.json Outdated
"port-version": 2,
"port-version": 3,
"description": "Open source drivers for the Kinect for Windows v2 device",
"homepage": "https://github.com/OpenKinect/libfreenect2",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repo appears dead for the last 6 years. Are you making this change just because it is needed to do the libjpeg-turbo fix or is this something you're actually trying to use? If the former, we should consider deindexing this thing rather than extensive patches. If the latter, do you have evidence of signs of life upstream?

Comment on lines +37 to +40
+ find_dependency(PkgConfig)
+ if(PkgConfig_FOUND)
+ pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET)
+ endif()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, this is confusing because it's patches on patches. Kai Pastor (@dg0yt) I think your comment is resolved by 0002+0003 in this series.

@BillyONeal

Billy O'Neal (BillyONeal) commented Aug 21, 2026

Copy link
Copy Markdown
Member

:sigh: The rabbit hole deepens. The vcpkg libspng port has confused pkgconfig bindings between static and dynamic. However, upstream is not consistent about it.

https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/CMakeLists.txt#L103-L107

installs libspng.pc and libspng_static.pc, but

https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/meson.build#L82-L87

installs spng.pc. This seems to be the one libjpeg-turbo is looking to be compatible with.

https://packages.debian.org/sid/amd64/libspng-dev/filelist Looks like Debian is using the meson build, given that they install /usr/lib/x86_64-linux-gnu/pkgconfig/spng.pc.

Billy O'Neal (BillyONeal) added a commit to BillyONeal/libspng that referenced this pull request Aug 21, 2026
In vcpkg we want to make sure that CMake and pkg-config customers get an experience that works, including transitively. In reviewing microsoft/vcpkg#52891 we discovered that the transitive libjpeg-turbo -> libspng .pc link is broken. In trying to fix that I ran into a transitive problem here.

https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/CMakeLists.txt#L103-L107

installs `libspng.pc` and `libspng_static.pc`, but

https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/meson.build#L82-L87

installs `spng.pc`. This seems to be the one `libjpeg-turbo` is looking to be compatible with.

https://packages.debian.org/sid/amd64/libspng-dev/filelist Looks like Debian is using the meson build, given that they install `/usr/lib/x86_64-linux-gnu/pkgconfig/spng.pc`.

Also, meson detects whether the .pc should link with `libm` by probing for existence of the library:

https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/meson.build#L42

while CMake just assumes "Windows gets no libm, everyone else does". This change changes everything to match meson.

The problems discussed here and some of the suggested outcomes are from GPT 5.6 Sol.
Billy O'Neal (BillyONeal) added a commit to BillyONeal/vcpkg that referenced this pull request Aug 21, 2026
Related: microsoft#52891
Related: randy408/libspng#286

This changes libspng to install pkg-config on all platforms matching that installed by Debian.

Also fix the declared licenses to match the SPDX expression. Their README says:

>## License
>
>Code is licensed under the BSD 2-clause "Simplified" License.
>
>The project contains optimizations and test images from libpng, these are licensed under the
[PNG Reference Library License version 2](http://www.libpng.org/pub/png/src/libpng-LICENSE.txt).

but they don't have a copy of the license. The content under that license is incorporated into the .c so we have to install the whole thing.
@BillyONeal

Copy link
Copy Markdown
Member

I was going to throw up my hands and be like "well Windows pkgconfig is hopeless but at least we can make *nix work"; unfortunately that still runs into the problem that vcpkg's installed libspng.pc will not match up with what libjpeg-turbo wants. tartanpaint Unfortunately I think this means we need #53510 or something like it first, will keep you posted.

@BillyONeal Billy O'Neal (BillyONeal) added the depends:different-pr This PR or Issue depends on a PR which has been filed label Aug 21, 2026
@BillyONeal

Copy link
Copy Markdown
Member

(Alternately I suppose we could patch libjpeg-turbo to use the names vcpkg installs but given that we already have a submitted PR fixing libspng so that libjpeg-turbo does the right thing it's probably best to wait for that)

Thanks for your submission and sorry for the stream of consciousness :)

@tartanpaint

Copy link
Copy Markdown
Contributor Author

(Alternately I suppose we could patch libjpeg-turbo to use the names vcpkg installs but given that we already have a submitted PR fixing libspng so that libjpeg-turbo does the right thing it's probably best to wait for that)

Thanks for your submission and sorry for the stream of consciousness :)

Billy O'Neal (@BillyONeal), thanks for taking a look at this - I hadn't realised what a can of worms I was opening when I started this....
The libfreenect2 changes simply came about due to me trying to resolve CI failures to get the PR mergable. I agree that the repo does appear dead with no commits for about 6 years and I do not use it myself. If a delist of the libfreenect2 library is desirable in this case I would not lament it.

I'm happy to clean this PR up once the libspng PR is merged and a decision is made on libfreenect2. I can produce a PR to delist libfreenect2 if that's helpful.

@tartanpaint

Copy link
Copy Markdown
Contributor Author

Billy O'Neal (@BillyONeal) Kai Pastor (@dg0yt) - thanks for your continued assistance on this one.
Are you able to confirm that the libjpeg-turbo patches included from the libjpeg-turbo repo are acceptable, or are there additional upstream changes that we should look to have incorporated?
Thanks!

@tartanpaint

Copy link
Copy Markdown
Contributor Author

(Alternately I suppose we could patch libjpeg-turbo to use the names vcpkg installs but given that we already have a submitted PR fixing libspng so that libjpeg-turbo does the right thing it's probably best to wait for that)
Thanks for your submission and sorry for the stream of consciousness :)

Billy O'Neal (Billy O'Neal (@BillyONeal)), thanks for taking a look at this - I hadn't realised what a can of worms I was opening when I started this.... The libfreenect2 changes simply came about due to me trying to resolve CI failures to get the PR mergable. I agree that the repo does appear dead with no commits for about 6 years and I do not use it myself. If a delist of the libfreenect2 library is desirable in this case I would not lament it.

I'm happy to clean this PR up once the libspng PR is merged and a decision is made on libfreenect2. I can produce a PR to delist libfreenect2 if that's helpful.

PR to deindex libfreenect2: #53516

@dg0yt

Copy link
Copy Markdown
Contributor

I don't have time for details before sunday.
Is pkgconfig for transitive spng really avoided now?
Is it still "patches on patches"?

@tartanpaint

Copy link
Copy Markdown
Contributor Author

I don't have time for details before sunday. Is pkgconfig for transitive spng really avoided now? Is it still "patches on patches"?

Kai Pastor (@dg0yt) There is a pending PR that Billy O'Neal (@BillyONeal) prepared for the libspng issue: #53510

I think that the "patches on patches" referred to is the series of 3 commits that I generated patch files for from the upstream libjpeg-turbo repo. These are still in place. It was my intention that these will then be removed when the next version of libjpeg-turbo is added to vcpkg as that version will already contain these commits.

@BillyONeal

Billy O'Neal (BillyONeal) commented Aug 22, 2026

Copy link
Copy Markdown
Member

I think that the "patches on patches" referred to is the series of 3 commits that I generated patch files for from the upstream libjpeg-turbo repo. These are still in place. It was my intention that these will then be removed when the next version of libjpeg-turbo is added to vcpkg as that version will already contain these commits.

Probably would be less confusing to prepare one patch and just comment that it is composed of the particular commits, e.g.

git apply A
git apply B
git apply C
git diff --cached --output out.diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

depends:different-pr This PR or Issue depends on a PR which has been filed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants