Skip to content
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

zlib: fix lib name in CMakeLists directly instead of fragile renaming #10771

Merged
merged 7 commits into from
May 18, 2022

Conversation

SpaceIm
Copy link
Contributor

@SpaceIm SpaceIm commented May 12, 2022

closes #10770

I don't know whether it was a good idea in the first place to rename zlibstatic on Windows, and remove d postfix for debug build type, but now it's done directly in CMakeLists with simple criteria (zlib for Windows, z for other platforms).


  • I've read the guidelines for contributing.
  • I've followed the PEP8 style guides for Python code in the recipes.
  • I've used the latest Conan client version.
  • I've tried at least one configuration locally with the conan-center hook activated.

@ghost
Copy link

ghost commented May 12, 2022

I detected other pull requests that are modifying zlib/all recipe:

This message is automatically generated by https://github.com/ericLemanissier/conan-center-conflicting-prs so don't hesitate to report issues/improvements there.

@conan-center-bot

This comment has been minimized.

uilianries
uilianries previously approved these changes May 13, 2022
@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 13, 2022

Well, it may generate a different dll name for MinGW (it should be zlib1.dll).
I'll push a slightly better patch to match zlib names for MinGW:
https://github.com/madler/zlib/blob/v1.2.12/win32/Makefile.gcc#L28-L30
https://packages.msys2.org/package/mingw-w64-x86_64-zlib

No change for msvc, but like MinGW, build files are not consistent upstream (less discrepancy after our patch, only import lib differs):
https://github.com/madler/zlib/blob/v1.2.12/win32/Makefile.msc#L16-L18

see madler/zlib#652

@SpaceIm SpaceIm marked this pull request as draft May 13, 2022 09:11
@SpaceIm SpaceIm marked this pull request as ready for review May 13, 2022 09:25
madebr
madebr previously approved these changes May 13, 2022
@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 13, 2022

Do you think we should honor import lib name from https://github.com/madler/zlib/blob/v1.2.12/win32/Makefile.msc#L16-L18 for Visual Studio (zdll.lib), or it's too dangerous for downstream recipes with fragile build files?

@madebr
Copy link
Contributor

madebr commented May 13, 2022

Linux systems would just provide both by providing a symbolic link.

FindZLIB.cmake looks for all names, but higher priority to z: https://github.com/Kitware/CMake/blob/e00e67cb924495aab72bfc60dec0451a6566d8a2/Modules/FindZLIB.cmake#L80

I've not tested building packages with a shared zlib dependency, but can assume most autotools libraries will happily use z.lib instead of zdll.lib.
I think the risk is minimum.

If some dependency breaks, we can fix that dependency only by e.g. a patch or copying z.lib to zdll.lib.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 13, 2022

Linux systems would just provide both by providing a symbolic link.

It's always libz.a and libz.so on *Nix systems.

FindZLIB.cmake looks for all names, but higher priority to z: https://github.com/Kitware/CMake/blob/e00e67cb924495aab72bfc60dec0451a6566d8a2/Modules/FindZLIB.cmake#L80

I'm not afraid by FindZLIB, it tests all flavors, even weird ones.

I've not tested building packages with a shared zlib dependency, but can assume most autotools libraries will happily use z.lib instead of zdll.lib.

It would be zdll.lib instead of zlib.lib (for cl like compilers only). I've written a summary of all flavors for Windows in upstream repo: madler/zlib#652

@madebr
Copy link
Contributor

madebr commented May 13, 2022

It would be zdll.lib instead of zlib.lib (for cl like compilers only).

I think we have 2 major possible issues:

IOW, there will always be risks.
We should accept that there simply does not exist a correct library name.
To make our lives easier, perhaps add a user environment variable which dependencie can use to create a correctly named library. (perhaps not needed because it is always in libs)
An alternative could be to just provide alll: zdll.lib, z.lib and zlib.dll.
But that's perhaps wasteful.
Otoh, if all are the same compression should be able to minimize the overhead :P

@SSE4
Copy link
Contributor

SSE4 commented May 13, 2022

@madebr what about non-autotools projects? e.g. ffmpeg: https://github.com/FFmpeg/FFmpeg/blob/master/configure#L4585

@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 13, 2022

For ffmpeg, I guess something like https://github.com/FFmpeg/FFmpeg/blob/710dce131fdb6c1ebec1f26a7a4173d82d828330/configure#L4585 should be patched dynamically like we do already for several handwritten Makefiles hardcoding a specific flavor of their dependencies.

@madebr
Copy link
Contributor

madebr commented May 13, 2022

@madebr what about non-autotools projects? e.g. ffmpeg: https://github.com/FFmpeg/FFmpeg/blob/master/configure#L4585

Same as for vcxproj: pray we don't need to do deep surgery.

@conan-center-bot
Copy link
Collaborator

All green in build 5 (9e152ff157af266bc54b7f98ceefebbc4a97c6cc):

  • zlib/1.2.12@:
    All packages built successfully! (All logs)

  • zlib/1.2.11@:
    All packages built successfully! (All logs)

@conan-center-bot conan-center-bot merged commit 9cec7d9 into conan-io:master May 18, 2022
@SpaceIm SpaceIm deleted the fix/zlib-libname branch May 18, 2022 12:06
@Chnossos
Copy link
Contributor

Removing the d from zlib1.dll in Debug mode broke all compiled binaries like lupdate.exe from the qt package.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 19, 2022

You have to recompile msvc debug binaries which have a dependency to zlib shared.

@AndreyMlashkin
Copy link
Contributor

There is a conan flag --build outdated --build cascade for this

@p-groarke
Copy link

@SpaceIm The debug postfix shouldn't have been removed. It shouldn't be up to package maintainers to choose the output of the build. zlib uses a postfix, and thus, the conan package should too.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Sep 6, 2023

zlib doesn't have a consistent naming convention for windows, and doesn't add a postfix in 2 build files among the 3 available for Visual Studio. For simplicity and to be able to fix original issue related to this PR, we follow Makefile.msvc convention of upstream project instead of conventions in its CMakeLists. See madler/zlib#652

Nobody should assume a specific zlib file name on Windows, it can be any of these names depending on which build file has been used: zlib.lib, zdll.lib, zlibstat.lib, zlibwapi.lib, zlibstatic.lib, zlibstaticd.lib, zlibd.lib

@p-groarke
Copy link

p-groarke commented Sep 6, 2023

@SpaceIm
From https://www.zlib.net/fossils/zlib-1.2.13.tar.gz CMakeList :
Screenshot (21)

(sorry for image, they don't have a github apparently).

In the context of conan consuming conan producing conan, I think it doesn't really matter. But I'm guessing we aren't alone in a "conan adoption" state where conan must live side-by-side our (horrible) legacy systems. It must integrate and "play ball" with other systems for the time being, until conan conquers the world ;)

We can agree to disagree, but I strongly believe this was a mistake. Though maybe I don't understand the true motivation behind the change, it's breaking a lot of our builds.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Sep 6, 2023

As I said, there is no convention in zlib repo, so you can't assume that a package manager would have used upstream CMakeList to build zlib. Upstream Makefile.msvc or MSBuild files produce different file names.

Anyway, this PR didn't remove d postfix, it was already removed before as a post process during packaging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[package] zlib/1.2.12: wrong library name in cpp_info.libs on non-Unix/Windows
8 participants