-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
How do we choose the zlib version to use? #61852
Comments
Tagging subscribers to this area: @dotnet/area-system-io-compression Issue DetailsI'm trying to understand how we decide which zlib library to consume, but there are a few things that confuse me. My questions are the following:
Below are the details explaining how I arrived to those questions. .NET consumes two zlib versions:
The code that chooses which libraries to load depending on the architecture is here: runtime/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt Lines 13 to 43 in 57bfe47
Both of the library folders contain a
The public p/invoke entrypoints are declared in runtime/src/libraries/Native/AnyOS/zlib/pal_zlib.h And they are implemented in runtime/src/libraries/Native/AnyOS/zlib/pal_zlib.c But in runtime/src/libraries/Native/AnyOS/zlib/pal_zlib.c Lines 8 to 14 in 57bfe47
The entry points for the DLL are indicated in this file, which imports them from runtime/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c Lines 28 to 36 in 57bfe47
|
Right, the AnyOS/Unix/Windows split does not really make sense. It would be best to get rid of it and have the library-specific directories directly in the native folder. This was discussed several times. Nobody volunteered to clean it up yet. |
@hoyosjs gave me the answers via chat. I'm translating them and will post them in a few moments. |
3 questions, 1 answer: The reason why the checked-in files are located in the Windows folder is because only Windows consumes those files (hence the The hardcoded file
Only Thanks @hoyosjs @jkotas do you feel strongly about moving the native libraries to the AnyOS folder? With what I wrote above, I don't feel like that's needed anymore, since only Windows consumes the zlib checked-in libraries. But if it's for correctness, I could open an issue and mark it up for grabs. |
If we are going to do any shuffle here, we should get rid of the AnyOS/Unix/Windows directory layer completely. Note that there are other non-senses in the current directory structure, for example |
We might! The zlib folks released zlib-ng, an ARM/ARM64 optimized variant of the zlib library. Same license as the other zlib libraries we already consume, so we can use it. I'm currently experimenting with this library and plan on collecting perf numbers. If it all looks good, I can take this opportunity to reshuffle the files as you suggest.
Noted! I'll keep it in mind. Thanks! |
Same for |
We should treat all shims the same way. I agree that src/native may be the best place for all shims. We are going to have mix of static and dynamic linking of the shims (e.g. we statically link most shims into the single-file coreclr flavor), and this mix is going to change over time. |
I couldn't find an issue for that discussion, but I did recall having that discussion, do you remember if we have a tracking issue to move shims to src/native? |
I am not able to find any tracking issue for it. |
Opened #61864 |
Thanks! |
I'm trying to understand how we decide which native zlib library to consume in our compression libraries, but there are a few things that confuse me.
My questions are the following:
CMakeLists.txt
file, located inside the Native Windows folder instead of the Native AnyOS folder? The Unix code also consumes these libraries.zlib.h
file excluded from **NATIVECOMPRESSION_SOURCES
inCMakeLists.txt
, when we choose based on architecture?pal_zlib.c
, are we hardcoding thezlib\zlib.h
file depending if_WIN32
is defined, instead of by architecture?#include <zlib.h>
coming from, and why is that used if_WIN32
is not defined?Below are the details explaining how I arrived to those questions.
.NET consumes two zlib versions:
The code that chooses which libraries to load depending on the architecture is here:
runtime/src/libraries/Native/Windows/System.IO.Compression.Native/CMakeLists.txt
Lines 13 to 43 in 57bfe47
Both of the library folders contain a
zlib.h
file, which according to the description, is the "interface of the library'. Notice that the zlib.h file is excluded from the CMakeLists.txt file.The public p/invoke entrypoints are declared in runtime/src/libraries/Native/AnyOS/zlib/pal_zlib.h
And they are implemented in runtime/src/libraries/Native/AnyOS/zlib/pal_zlib.c
But in
pal_zlib.c
file, you'll notice the#include
that loadszlib.h
hardcodes the one from madler/zlib when_WIN32
is not defined:runtime/src/libraries/Native/AnyOS/zlib/pal_zlib.c
Lines 8 to 14 in 57bfe47
The entry points for the DLL are indicated in this file, which imports them from
pal_zlib.h
:runtime/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c
Lines 28 to 36 in 57bfe47
The Unix code consumes the AnyOS
pal_zlib.c
file as well:runtime/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt
Line 13 in 57bfe47
runtime/src/libraries/Native/Unix/System.IO.Compression.Native/System.IO.Compression.Native_unixexports.src
Lines 15 to 23 in 57bfe47
The text was updated successfully, but these errors were encountered: