llvm-mingw icon indicating copy to clipboard operation
llvm-mingw copied to clipboard

LLVM MinGW does not include zlib headers and library

Open a740g opened this issue 2 years ago • 6 comments

This is simple. All MinGW GCC distributions I have tried includes zlib. It seems like LLVM MinGW does not. Although I could just include zlib or miniz as an additional project dependency, it would be nice if LLVM MinGW were a simple drop-in replacement and included zlib.

a740g avatar Mar 16 '23 17:03 a740g

Counterargument: A bundled zlib can easily get outdated, leading to missing critical security fixes.

I had a specific experience about this with Krita: We were updating our dependencies in response to a certain zlib CVE, but due to some configuration mishaps, Qt ended up linking to another zlib (I suspect it was the one that comes with the mingw-builds toolchain, which at the time was already quite outdated) instead of our updated ones. We almost didn't catch that -- I only found out because I happened to be trying local builds with llvm-mingw and the configuration failed.

alvinhochun avatar Mar 16 '23 18:03 alvinhochun

Ok. That's fair. In that case, we should at least list the libs that are not included in LLVM MinGW that are included in the GCC distributions (if such a list does not exist already). I have a feeling that zlib may not be the only one missing.

a740g avatar Mar 18 '23 17:03 a740g

This toolchain doesn't come with any preinstalled libraries, aside from libffi, which is used by python. You'll have to source everything yourself.

longnguyen2004 avatar Mar 19 '23 00:03 longnguyen2004

FWIW, I'm not entirely decided here...

In general, it wasn't my experience that mostly mingw distributions come with zlib bundled. But I had a look at mingw-builds (from https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/, nowadays at https://github.com/cristianadam/mingw-builds/releases), and I can see that indeed, zlib seems to be bundled there. Those toolchains seem to have a bunch of other libraries/toolkits bundled too, like tcl/tk, expat, etc, but they're sorted in a subdirectory opt, possibly only used as dependencies for some tools and not meant for others to use. Within the main x86_64-w64-mingw32/lib directory, I could only find a small number of libraries that weren't present in my toolchains - libcharset.a, libiconv.a and libz.a.

I also was about to point out that e.g. Debian/Ubuntu provided cross compilers don't come with any zlib bundled, but I did see that nowadays (since 2016 apparently, i.e. not since forever, but apparently for some time), there's a separate package available for them, with zlib for mingw targets. So I guess it can be considered available there too (but not automatically/totally bundled - I hadn't ever run into it, probably since I haven't known about it and installed it).

If searching for other similar Debian/Ubuntu packages, named -mingw-w64-dev, https://packages.ubuntu.com/search?keywords=mingw-w64-dev&searchon=names&suite=kinetic&section=all, I found a handful, which essentially seem to be libgcrypt and its dependencies, GNU Pth interface, win-iconv and zlib.

For more context, can you point out which toolchain distributions you've used, that had zlib as a default available library bundled with the toolchain?

Technically it would be quite easy to include zlib - it's not a very problematic library. If it were to be included, do you think it should be available in both shared+static form, or static only to avoid surprises for people who might end up linking it in automatically?

The libffi as @longnguyen2004 mentions isn't available installed in the general include/lib directory and isn't meant for others to use, it's only built as part of the python install for LLDB.

But overall I share @alvinhochun's sentiment here; the toolchain should generally provide the platform itself only, while the user is responsible for third party libraries built on top of it. In general, I don't think the toolchain should start bundling any commonly used utility libraries that the user may want to use. Zlib itself might be small and common enough to be tolerable, but I don't want this to slide further into bzip2, xz, libiconv, etc.

mstorsjo avatar Mar 20 '23 12:03 mstorsjo

For more context, can you point out which toolchain distributions you've used, that had zlib as a default available library bundled with the toolchain?

I primarily use MInGW distro by niXman and it includes zlib. However, I took out some time to carefully check some other distros and here is what I found.

Distro zlib included
https://nuwen.net/mingw.html yes
https://jmeubank.github.io/tdm-gcc/ no
https://github.com/skeeto/w64devkit no
https://github.com/niXman/mingw-builds-binaries yes
https://winlibs.com/ no
https://sourceforge.net/projects/mingw-w64/ yes
https://gcc-mcf.lhmouse.com/ yes

Technically it would be quite easy to include zlib - it's not a very problematic library. If it were to be included, do you think it should be available in both shared+static form, or static only to avoid surprises for people who might end up linking it in automatically?

Well, after reading what @alvinhochun wrote, I am convinced that toolchains should not include third party libraries. If you do want to include zlib, then just a static lib should be fine IMO. If you decide otherwise, that's fine too (probably better 😊).

a740g avatar Mar 22 '23 06:03 a740g

Well, after reading what @alvinhochun wrote, I am convinced that toolchains should not include third party libraries. If you do want to include zlib, then just a static lib should be fine IMO. If you decide otherwise, that's fine too (probably better 😊).

Thanks for the survey! With that in mind, that it's not a common thing that one in general can rely on being present, I think it's best for us to just stick to the current status quo of not including zlib here.

mstorsjo avatar Mar 22 '23 06:03 mstorsjo