Skip to content

[liblzma] Update to version 5.6.2.#39024

Merged
BillyONeal merged 5 commits intomicrosoft:masterfrom
teo-tsirpanis:liblzma-update
Jun 18, 2024
Merged

[liblzma] Update to version 5.6.2.#39024
BillyONeal merged 5 commits intomicrosoft:masterfrom
teo-tsirpanis:liblzma-update

Conversation

@teo-tsirpanis
Copy link
Copy Markdown
Contributor

@teo-tsirpanis teo-tsirpanis commented May 29, 2024

  • 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.
  • Any fixed CI baseline entries are removed from that file.
  • Any patches that are no longer applied are deleted from the port's directory.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is added to each modified port's versions file.

This PR updates liblzma to the just-released version 5.6.2. I first copied the reverted port for 5.6.0, and updated versions.

I also enabled the tools feature on Windows; the tools seem to run fine there.

Validated by building the tools and successfully running them with `--help`.
@LilyWangLL LilyWangLL added the category:port-update The issue is with a library, which is requesting update new revision label May 30, 2024
@LilyWangLL
Copy link
Copy Markdown
Contributor

LilyWangLL commented May 30, 2024

Feature tools passed with following triplets:

x86-windows
x64-windows
x64-windows-static

Usage test passed on x64-windows.

LilyWangLL
LilyWangLL previously approved these changes May 31, 2024
@LilyWangLL LilyWangLL added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label May 31, 2024
@Larhzu
Copy link
Copy Markdown

Larhzu commented Jun 3, 2024

I happened to learn that vcpkg applies patches which I don't remember anyone submitting upstream (to me). I would like to know if the patches in vcpkg are still doing what they originally did and if something should be changed upstream.

  1. Is add_support_ios.patch good even after the upstream commit Don't build bundles on Apple OSes from 2020? The patch in vcpkg was added for 5.2.5 and the upstream commit was backported to 5.2.6 and included in 5.4.0. Is the upstream commit wrong and bundles should be enabled? I'm not familiar with building on Apple OSes so I'm relying on information from others.

  2. I guess that fix_config_include.patch was a workaround to the bug that was fixed in Fix building of resource files when config.h isn't used in 2020 and backported to 5.2.6 and included in 5.4.0. In 5.6.2 the directory windows/vs2019 doesn't even exist anymore as the VS project files have been removed.

  3. I guess that win_output_name.patch is an alternative to the upstream fix Fix the import library filename that was included in 5.4.5 (and now 5.2.13 too). If the current upstream code isn't correct then it likely should be fixed.

  4. I'm a bit lost here but vcpkg-cmake-wrapper.cmake seems to force add Threads::Threads dependency for liblzma. With MinGW-w64 it can find pthreads but liblzma on Windows uses native Windows threads by default. CMakeLists.txt explicitly avoids Threads::Threads in this case so that pthreads library won't get uselessly linked in with MinGW-w64.

  5. portfile.cmake installs liblzma.pc. However, that was added to upstream CMakeLists.txt in Generate and install liblzma.pc if not using MSVC and included in 5.4.5. As the commit says, it's not enabled with Visual Studio. Should it be? portfile.cmake handles debug in the prefix specially though, and I have no idea if upstream should care about that. In any case, there seems to be some overlap with liblzma.pc handling at the moment.

@Neumann-A
Copy link
Copy Markdown
Contributor

to 5: portfile.cmake installs liblzma.pc. However, that was added to upstream CMakeLists.txt in Generate and install liblzma.pc if not using MSVC and included in 5.4.5. As the commit says, it's not enabled with Visual Studio. Should it be?

Instead of making it platform dependent make an option for it and default that option dependening on platform. This way vcpkg does not need patching for it. vcpkg can use pc files on all platforms especially for meson and autotools based projects. vcpkg probably could build liblzma using autotools using msvc and thus generate the pc files automatically but CMake is simply the preferred build system within vcpkg.

to 2: windows/vs2019 doesn't even exist anymore as the VS project files have been removed.

If that is the case the patch can be removed.

to 4:

set(THREADS_PREFER_PTHREAD_FLAG TRUE) should probably be guarded and not be applied for WIN32
Linking Threads::Threads is logically mandatory if threads are used.

to 3:

Probably just a case of many ways to get the same output name using cmake. Needs testing if the patch can be removed. (but it probably can be removed)

Larhzu added a commit to tukaani-project/xz that referenced this pull request Jun 3, 2024
I had misunderstood that it wouldn't be useful with MSVC.
vcpkg had been installing liblzma.pc with custom rules since 2020,
years before liblzma.pc support was added to CMakeLists.txt.

See:
https://github.com/microsoft/vcpkg/blob/eb895b95aac6fd7485373702f29f508c42a180a0/ports/liblzma/portfile.cmake
microsoft/vcpkg#39024 (comment)
@Larhzu
Copy link
Copy Markdown

Larhzu commented Jun 3, 2024

The only platform where the liblzma.pc isn't currently installed is MSVC. So I'll just omit that exception then. There (hopefully) should be no need to complicate it with options. I have committed this now.

I don't know if Autotools + MSVC works in XZ Utils; it's possible that something tiny is lacking at the XZ Utils side. I don't remember if anyone has ever tested it. CMake support was added initially to get rid of VS project files. Only later CMake support was expanded to non-MSVC use cases.


THREADS_PREFER_PTHREAD_FLAG TRUE is not about Windows. It's about how pthread support is detected. Leaving it FALSE is legacy; it should always be TRUE so that -pthread is checked before -lpthread and such linker flags. In any case find_package(Threads REQUIRED) will find both threading methods with MinGW-w64, setting these:

CMAKE_USE_WIN32_THREADS_INIT=1
CMAKE_USE_PTHREADS_INIT=1
Threads_FOUND=TRUE

As far as I know, Windows needs nothing to enable threading support, thus Thread::Threads does nothing useful if one knows that pthreads won't be used anyway. But I see now that it might not hurt either if no pthread functions are called as the linker may omit the libwinpthread-1.dll dependency then. There might be fine details that I don't understand well enough right now. Maybe the forcing of Threads::Threads dependency matters if using CMake's own FindLibLZMA module and linking against static liblzma that uses pthreads (not Windows threads).

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Jun 3, 2024

The name patching and the pc file belong together: It makes the lib universally available via -llzma (as in the pc file) while maintaining the DLL name. MSVC, MinGW, unix.
Background: There was a time when GDAL was built with nmake for MSVC and autotools otherwise. And all the link libraries even for static linkage and nmake could be discovered via pkg-config [--msvc-syntax].

@Larhzu
Copy link
Copy Markdown

Larhzu commented Jun 3, 2024

Before the linked fix one got liblzma.dll and libliblzma.dll.a with MinGW-w64 which was a mismatched pair. The updated patch in this PR retains the IMPORT_PREFIX "" from the linked fix while adding OUTPUT_NAME lzma which messes up the naming with MinGW-w64 compared to if both IMPORT_PREFIX and PREFIX were removed.

If the intent is to get

  • liblzma.dll + lzma.lib with MSVC and
  • liblzma.dll + liblzma.dll.a with MinGW-w64,

then I see how it relates to pkg-config --msvc-syntax --libs liblzma.

So something needs to be fixed somewhere but I need to sleep now. ;-)

Larhzu added a commit to tukaani-project/xz that referenced this pull request Jun 4, 2024
This is a mess because liblzma DLL outside Cygwin and MSYS2
is liblzma.dll instead of lzma.dll to avoid a conflict with
lzma.dll from LZMA SDK.

On Cygwin the name was "liblzma-5.dll" while "cyglzma-5.dll"
would have been correct (and match what Libtool produces).
MSYS2 likely was broken too as it uses the "msys-" prefix.

This change has no effect with MinGW-w64 because with that
the "lib" prefix was correct already.

With MSVC builds this is a small breaking change that requires developers
to adjust the library name when linking against liblzma. The liblzma.dll
name is kept as is but the import library and static library are now
lzma.lib instead of liblzma.lib. This is helpful when using pkgconf
because "pkgconf --msvc-syntax --libs liblzma" outputs "lzma.lib"
(it's converted from "-llzma" in liblzma.pc). It would be easy to
keep the liblzma.lib naming but the pkgconf compatibility seems worth
it in the long run. The lzma.lib name is compatible with MinGW-w64
too as -llzma will find also lzma.lib.

vcpkg had been patching CMakeLists.txt this way since 2022 but I
learned this only recently. The reasoning for the patch makes sense,
and while this is a small breaking change with MSVC, it seems like
a decent compromise as it keeps the DLL name the same.

2022 patch in vcpkg: https://github.com/microsoft/vcpkg/blob/0707a17ecf1466d64cf1a3c1ee18c8ff02aadb2d/ports/liblzma/win_output_name.patch
See the discussion: microsoft/vcpkg#39024

Thanks to Vincent Torri for confirming the naming issue on Cygwin.
@Larhzu
Copy link
Copy Markdown

Larhzu commented Jun 5, 2024

I understand a few details better and made a few commits upstream. Here are updates to my earlier five questions and also two new ones:

  1. I now think that add_support_ios.patch never made any sense other than forcing the build to succeed for users that only wanted liblzma. From Apple's docs: "Static libraries, dynamic libraries, shell scripts, and UNIX command line tools do not use the bundle structure." Thus, the commit from 2020 is correct. The bug reporter had confirmed to me via email that the commit fixed the build on iOS. So add_support_ios.patch should be removed as it nowadays does nothing.

  2. fix_config_include.patch clearly can be removed.

  3. The equivalent of win_output_name.patch (without IMPORT_PREFIX "") is now in upstream repository. It fixed naming bugs on Cygwin and MSYS2 too, that is, my old method was fundamentally wrong. Note that win_output_name.patch in this PR is currently buggy because it has IMPORT_PREFIX "" (it must have been a merge conflict when the patch was updated but it still wasn't noticed).

  4. My Threads::Threads question likely needs no changes anywhere.

  5. liblzma.pc is now installed even when building with MSVC. The generated liblzma.pc now uses paths that are relative to ${prefix}. I have no idea if it helps in portfile.cmake though, that is, if it was now possible to rely on upstream CMakeLists.txt to install liblzma.pc correctly.

  6. Since XZ Utils 5.6.0, CMakeLists.txt installs xzgrep and other POSIX shell scripts if(UNIX). These scripts rely on the xz tool. I suppose build-tools.patch should cover the scripts too as installing the scripts without the xz tool makes no sense.

  7. Excluding the POSIX shell scripts, the command line tools can be built on Windows even with MSVC. This is a new feature since 5.6.0. vcpkg.json still has "supports": "!windows, mingw". I wonder if that was forgotten to be changed (perhaps the info in the NEWS file wasn't noticed) or if it is intentional because the MSVC build of the command line tools link in GNU getopt_long which is under the GNU LGPLv2.1 (not needed with MinGW-w64).

I would be nice to know if the upstream changes are OK from vcpkg's point of view. The changes will be in the next stable release if there are no complaints. Thanks!

The Autotools-based build has options to disable individual command line tools but the CMake-based build doesn't. Perhaps such options should be added upstream so that build-tools.patch wouldn't be needed here (and perhaps elsewhere) but I didn't do it now. It is possible to build only liblzma by building and installing only the specific CMake components but I understand that it might not be so convenient.

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Jun 5, 2024

(Community feedback)

  1. I now think that add_support_ios.patch never made any sense other than forcing the build to succeed for users that only wanted liblzma. From Apple's docs: "Static libraries, dynamic libraries, shell scripts, and UNIX command line tools do not use the bundle structure." Thus, the commit from 2020 is correct. The bug reporter had confirmed to me via email that the commit fixed the build on iOS. So add_support_ios.patch should be removed as it nowadays does nothing.

vcpkg doesn't want bundles, so the patch indicated a problem IMO. But I don't use iOS...

  1. The equivalent of win_output_name.patch (without IMPORT_PREFIX "") is now in upstream repository. It fixed naming bugs on Cygwin and MSYS2 too, that is, my old method was fundamentally wrong. Note that win_output_name.patch in this PR is currently buggy because it has IMPORT_PREFIX "" (it must have been a merge conflict when the patch was updated but it still wasn't noticed).

❤️
This was always a candidate for upstreaming but i was hesitating.

  1. liblzma.pc is now installed even when building with MSVC. The generated liblzma.pc now uses paths that are relative to ${prefix}. I have no idea if it helps in portfile.cmake though, that is, if it was now possible to rely on upstream CMakeLists.txt to install liblzma.pc correctly.

🚀

  1. Since XZ Utils 5.6.0, CMakeLists.txt installs xzgrep and other POSIX shell scripts if(UNIX). These scripts rely on the xz tool. I suppose build-tools.patch should cover the scripts too as installing the scripts without the xz tool makes no sense.

👍
And probably not very useful for windows w/o mingw.

  1. Excluding the POSIX shell scripts, the command line tools can be built on Windows even with MSVC. This is a new feature since 5.6.0. vcpkg.json still has "supports": "!windows, mingw". I wonder if that was forgotten to be changed (perhaps the info in the NEWS file wasn't noticed) or if it is intentional because the MSVC build of the command line tools link in GNU getopt_long which is under the GNU LGPLv2.1 (not needed with MinGW-w64).

getopt_long going into executables shouldn't be a barrier, in particular for an optional feature. It is also used by other ports. (And there is a port getopt-win32, but don't ask me about it is security and maintenance.)

The Autotools-based build has options to disable individual command line tools but the CMake-based build doesn't. Perhaps such options should be added upstream so that build-tools.patch wouldn't be needed here (and perhaps elsewhere) but I didn't do it now. It is possible to build only liblzma by building and installing only the specific CMake components but I understand that it might not be so convenient.

For vcpkg, a single switch for tools would be enough for this port.


It is fine to make a draft PR for a vcpkg CI run with a pre-release commit, to check if any further tweaks would be needed. That PR can be switched to the release when it is available.

@BillyONeal
Copy link
Copy Markdown
Member

3. I guess that win_output_name.patch is an alternative to the upstream fix Fix the import library filename that was included in 5.4.5 (and now 5.2.13 too). If the current upstream code isn't correct then it likely should be fixed.

As long as the name of the generated binaries matches between versions removing the patch seems OK to me.

portfile.cmake installs liblzma.pc. However, that was added to upstream CMakeLists.txt in Generate and install liblzma.pc if not using MSVC and included in 5.4.5. As the commit says, it's not enabled with Visual Studio. Should it be?

I think it should. Deciding to provide .pc files is a build system concern unrelated to what compiler or host one is on. It's true that pkg-config is much less a defacto standard on Windows but that doesn't make .pcs harmful.

That said, the port still works with the patches as described here; is it OK if we take this version that built successfully and removing patches if necessary can be done in a followup?

@BillyONeal BillyONeal removed the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label Jun 10, 2024
@teo-tsirpanis
Copy link
Copy Markdown
Contributor Author

So if I understand correctly, we can remove all patches except build-tools.patch? If yes, I can update the PR.

@BillyONeal
Copy link
Copy Markdown
Member

So if I understand correctly, we can remove all patches except build-tools.patch? If yes, I can update the PR.

It looks like most of them can go away, yes. But we don't want to block contributors submitting good-faith updates on doing every cleanup thing, if that makes sense. If you want to remove them I think that would be nice though :)

@BillyONeal BillyONeal marked this pull request as ready for review June 12, 2024 00:56
@BillyONeal BillyONeal marked this pull request as draft June 12, 2024 00:56
@BillyONeal
Copy link
Copy Markdown
Member

BillyONeal commented Jun 13, 2024

Note: @Larhzu is a primary maintainer of liblzma so we want to make sure they are happy.

@BillyONeal BillyONeal added info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. and removed requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. labels Jun 13, 2024
@teo-tsirpanis
Copy link
Copy Markdown
Contributor Author

Yes I know. I updated the patches, hope it's right now.

@teo-tsirpanis teo-tsirpanis marked this pull request as ready for review June 13, 2024 22:04
@Neustradamus
Copy link
Copy Markdown

@BillyONeal: Of course. It is important to specify that I have contacted @Larhzu about the backdoor which has been discovered by @anarazel (a Microsoft dev), my update request of the "bad version", and about this new PR too.

@BillyONeal
Copy link
Copy Markdown
Member

Yeah sorry, I was noting it for other vcpkg maintainers :) . Often we would be like 'Well taking the version update is more important than these improvements' I wanted to underline that we shouldn't do that this time.

Copy link
Copy Markdown
Contributor

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

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

packages/liblzma_x64-mingw-dynamic/bin/liblzma.dll
packages/liblzma_x64-mingw-dynamic/lib/liblzma.dll.a

LGTM.

@Larhzu
Copy link
Copy Markdown

Larhzu commented Jun 14, 2024

@teo-tsirpanis:

I updated the patches, hope it's right now.

Thanks! Things look good to me now.

In case you handle the next release:

  • Be prepared to omit the win_output_name.patch.

  • Possibly check how liblzma.pc installation works with upstream CMakeLists.txt with MSVC. If it works then perhaps the liblzma.pc code in portfile.cmake can be cleaned up. However, such a cleanup isn't mandatory because the portfile would just overwrite what CMakeLists.txt installs. So skipping the cleanup won't create new bugs.

If anything feels uncertain, feel free to ping me, although it's possible that I cannot help much with MSVC-specific issues.

@BillyONeal:

Often we would be like 'Well taking the version update is more important than these improvements' I wanted to underline that we shouldn't do that this time.

I spotted two new bugs that, once known, were very simple to fix. There was a chance that some vcpkg users could have hit those issues and even reported them to vcpkg. Then time would be wasted in figuring out what's wrong and getting them fixed. My understanding is that the whole point of PR reviews is to catch this kind of errors before they get merged.

I agree that cleaning up the unneeded harmless patches isn't so essential. However, cleaning them up makes it easier to review the packaging as a whole and increases the probability that real issues are spotted in PR reviews. It took a while for me to notice the two actual problems because the unneeded patches added to the amount of things to review.

In any case it's not about making me happy. It's irrelevant who spotted the problems; they are worth fixing no matter who reports them. I know it can feel tedious for contributors but unfortunately packaging isn't just about bumping a version number if patches are being applied. Getting things fixed at upstream will make packager's job easier in the long run as fewer patches will be needed.

@dg0yt:

Thanks for the explanations! I may look at BUILD_TOOLS-like feature in the future. The option naming in CMakeLists.txt is quite messy at the moment and I perhaps might wish to clean up those too. So these changes could perhaps be combined. We'll see.

@Larhzu
Copy link
Copy Markdown

Larhzu commented Jun 14, 2024

Slightly off-topic but it's relevant to vcpkg: There are three ways to find liblzma in CMake:

  1. The builtin FindLibLZMA module. This doesn't know that LZMA_API_STATIC is needed on Windows when linking against static liblzma. (vcpkg patches it into lzma.h but that's a vcpkg-specific thing.) This also doesn't know that -pthread might be needed when linking against static liblzma on some platforms.

  2. liblzma-config.cmake as installed by CMakeLists.txt handles the the above issues. However, other build systems like Autotools don't install the *.cmake files. So one can rely on the *.cmake files only if one knows that liblzma was built with CMake (like in vcpkg but not elsewhere).

  3. If pkg-config is used with all toolchains that also use CMake, then pkg_check_modules should always work, right? liblzma.pc sets -DLZMA_API_STATIC and pthread options for static linking so in this sense it shouldn't be worse than (2).

The (1) and (2) are mentioned in vcpkg's usage file. That's great at the moment. :-)

Should (3) be the only recommended method by upstream and vcpkg some day in the future? It feels tempting to deprecate (2) because one cannot rely on its availability in a generic case. And (1) is a bit incomplete and I'm not sure how easy it is to improve it. (Perhaps it could use pkg-config if pkg-config is available?)

If (2) is valuable, I don't mind keeping it supported as the code already exists in CMakeLists.txt. The current state just might look a bit ambiguous to other developers.

@Neumann-A
Copy link
Copy Markdown
Contributor

Should (3) be the only recommended method by upstream and vcpkg some day in the future?

Nope even though pc files are great they don't correctly support multi config in cmake. vcpkg could fix that for itself however fixing upstream cmake is nearly impossible.

It feels tempting to deprecate (2) because one cannot rely on its availability in a generic case

Don't do that. Upstream CMake wants to deprecate the internal find modules in favor for provided -config.cmake files. So if you look at upstream cmake modules they now have a find_package(whatever CONFIG) call.

it shouldn't be worse than (2).

Multi-Config support would be missing. The LZMA_API_STATIC for vcpkg needs to be baked into one of the headers any way since some consumers like msbuild doesn't know cmake nor pc files. (and there is probably the wild Makefile which also does not use pkg-config and hardcodes every linked library)

@Larhzu
Copy link
Copy Markdown

Larhzu commented Jun 14, 2024

That's valuable information. I will keep (2) in CMake. :-)

It's understandable to want to deprecate the internal modules in upsream CMake. In case of liblzma, most installations don't have the *.cmake files though because Autotools has been used. So relying on *.cmake files from liblzma is not an option at the moment.

(CMake support in XZ Utils was initially added for Windows use. CMake support has gotten close to feature parity with Autotools only in 2024 and it still needs some polishing.)

So if you look at upstream cmake modules they now have a find_package(whatever CONFIG) call.

I looked at CMake source:

grep -rl 'find_package(.* CONFIG' Modules
grep -rl 'pkg_check_modules(.* QUIET' Modules

The first one finds four files. So if my search pattern is good enough, only a few modules use find_package(whatever CONFIG).

The second command finds 14 files. For example, FindEXPAT.cmake uses pkg_check_modules(PC_EXPAT QUIET expat). On the other hand, my system has expat's *.cmake files installed as well.

Now I think that if I change anything, it could be adding *.cmake files from other build systems somehow. Multi-Config isn't relevant in that case, I suppose. Maybe a simple wrapper that calls pkg_check_modules could work. However, somehow I suspect that it can go wrong in more ways than I can imagine. So I won't do anything around the *.cmake files unless someone suggests something. :-)

The LZMA_API_STATIC for vcpkg needs to be baked into one of the headers any way since some consumers like msbuild doesn't know cmake nor pc files.

It's fine to do that in vcpkg. I just feel it's not ideal as an upstream solution. One could build both static and shared libs and wish to share the same headers. There likely is no perfect solution.

Thanks!

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Jun 14, 2024

In reply to #39024 (comment):

  1. CMake's Find modules

Old school. They are unaware of actual package configuration, which is in particular a problem for static linkage.
However, vcpkg has a proprietary hook to mitigate the problem: vcpkg-cmake-wrapper.cmake. That's why FindLZMA.cmake works even for static triplets.

  1. Exported CMake config

Modern CMake. CMake based projects can save everything which is known at build time. And CMake offers an advanced package search procedure when looking for the package later.

Note that you don't need CMake to create CMake config package. You could do it as well from the autotools build. It is just some CMake code setting up variables and targets, and implementing version checks.

  1. pkg-config

As stated, "Multi-Config support would be missing."
And CMake's FindPkgConfig.cmake has some limitationsbugs which haven't been fixed over years.


So ideally you would add CMake config to the autotools build if you want a consistent experience.

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Jun 14, 2024

In reply to #39024 (comment):

grep -rl 'find_package(.* CONFIG' Modules

Ideally XZ Utils would implement a LibLZMA config with a LibLZMA::LibLZMA imported target. Then the config mode could gradually replace the module mode in user projects (maybe using CMAKE_FIND_PACKAGE_PREFER_CONFIG), and the find module could try to delegate to config mode like it does for CURL today.

grep -rl 'pkg_check_modules(.* QUIET' Modules

Well, most of these uses are only to determine the installation prefix. They ignore the actual flags and libs. Including the actual link library name etc. One of my favorite anti-patterns.

One could build both static and shared libs and wish to share the same headers.

Really not the vcpkg pattern with its triplets - and with the MSVC world: same extension for static lib and import lib; different decorations when including headers.

Autotools projects usually cares less about MSVC and typically build both types of libs.
CMake projects which try to do mirror this behavior are another item in my favorite anti-patterns.

@Larhzu
Copy link
Copy Markdown

Larhzu commented Jun 14, 2024

Note that you don't need CMake to create CMake config package. You could do it as well from the autotools build. It is just some CMake code setting up variables and targets, and implementing version checks.

liblzma-targets.cmake doesn't look like a trivial file to recreate unless one just copies it as is. The other files are simpler.

This could be something to study some day but I don't plan to focus on it in the near future.

Ideally XZ Utils would implement a LibLZMA config with a LibLZMA::LibLZMA imported target.

I believe it already does provide compatibility with that spelling variation. It's just that in many cases the config files aren't present (Autotools build) and thus other packages cannot rely on them.

To make things more complicated, there's a fairly strong wish from people to see Meson support. At the same time I have gotten wishes to keep Autotools support because ./configure && make is easier than CMake or Meson for bootstrapping and cyclic dependency reasons.

Thanks!

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Jun 15, 2024

To make things more complicated, there's a fairly strong wish from people to see Meson support.

Meson. I expected that. The next system which you may love and hate at the same time.
I don't see it supporting multi-config soon.
And it starts to vendor dependency lookup similar to the old FindFoo cmake modules. I don't see that they could avoid the same shortcomings - in particular for static configurations.

@talregev
Copy link
Copy Markdown
Contributor

I think the ci was stuck

@BillyONeal BillyONeal merged commit 9e80334 into microsoft:master Jun 18, 2024
@BillyONeal
Copy link
Copy Markdown
Member

Thank you very much for the update!

@teo-tsirpanis teo-tsirpanis deleted the liblzma-update branch June 18, 2024 19:58
Larhzu added a commit to tukaani-project/xz that referenced this pull request Sep 6, 2024
I had misunderstood that it wouldn't be useful with MSVC.
vcpkg had been installing liblzma.pc with custom rules since 2020,
years before liblzma.pc support was added to CMakeLists.txt.

See:
https://github.com/microsoft/vcpkg/blob/eb895b95aac6fd7485373702f29f508c42a180a0/ports/liblzma/portfile.cmake
microsoft/vcpkg#39024 (comment)
(cherry picked from commit afa938e)
Larhzu added a commit to tukaani-project/xz that referenced this pull request Sep 6, 2024
This is a mess because liblzma DLL outside Cygwin and MSYS2
is liblzma.dll instead of lzma.dll to avoid a conflict with
lzma.dll from LZMA SDK.

On Cygwin the name was "liblzma-5.dll" while "cyglzma-5.dll"
would have been correct (and match what Libtool produces).
MSYS2 likely was broken too as it uses the "msys-" prefix.

This change has no effect with MinGW-w64 because with that
the "lib" prefix was correct already.

With MSVC builds this is a small breaking change that requires developers
to adjust the library name when linking against liblzma. The liblzma.dll
name is kept as is but the import library and static library are now
lzma.lib instead of liblzma.lib. This is helpful when using pkgconf
because "pkgconf --msvc-syntax --libs liblzma" outputs "lzma.lib"
(it's converted from "-llzma" in liblzma.pc). It would be easy to
keep the liblzma.lib naming but the pkgconf compatibility seems worth
it in the long run. The lzma.lib name is compatible with MinGW-w64
too as -llzma will find also lzma.lib.

vcpkg had been patching CMakeLists.txt this way since 2022 but I
learned this only recently. The reasoning for the patch makes sense,
and while this is a small breaking change with MSVC, it seems like
a decent compromise as it keeps the DLL name the same.

2022 patch in vcpkg: https://github.com/microsoft/vcpkg/blob/0707a17ecf1466d64cf1a3c1ee18c8ff02aadb2d/ports/liblzma/win_output_name.patch
See the discussion: microsoft/vcpkg#39024

Thanks to Vincent Torri for confirming the naming issue on Cygwin.

(cherry picked from commit e0d6d05)
@Neustradamus
Copy link
Copy Markdown

It has been updated to 5.6.3 by @c8ef:

@Neustradamus Neustradamus mentioned this pull request Oct 27, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:port-update The issue is with a library, which is requesting update new revision info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants