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

Please fix 1.2.12 compile #631

Closed
Spatzendame opened this issue Apr 7, 2022 · 16 comments
Closed

Please fix 1.2.12 compile #631

Spatzendame opened this issue Apr 7, 2022 · 16 comments

Comments

@Spatzendame
Copy link

Hi Mr. Adler,

I can't build zlibwapi.dll from your new version 1.2.12 because of errors during the compiling process using Visual Studio v17 2022. The previous version 1.2.11 worked.
I see many people have this problem. Can you please make a new release?

Thank you so much.

@topwizprogramming
Copy link

I have the same problem in VS 2012 and VS 2019. First attempt fails due to missing bat file that is listed as a pre-build event. After removing the bat file, it gives a large number of errors. I have attached the output from VS 2012.

compile_errors.txt

@tbeu
Copy link
Contributor

tbeu commented Apr 9, 2022

@topwizprogramming See #624 and #620 for the proposed fixes.

@Spatzendame
Copy link
Author

I want a native fix and not workaround solutions.

@ied206
Copy link

ied206 commented Apr 12, 2022

Summary

contrib/masmx86 and contrib/masmx64 was removed in 1.2.12 release.
It is most likely due to #274, which was a bug that x86 assembly optimization broke the library.
However, MSVC project files under contrib/vstudio were not updated for this change.

Details

inffas8664.c issue

contrib/masmx64 contained optimized version of inffast.c, inffas8664.c.
On x64 build, this source is always referred to even if you build with the ReleaseWithoutAsm configuration.
It is not present on 1.2.11, so every x64 build fails.

<ClCompile Include="..\..\masmx64\inffas8664.c">
  <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">true</ExcludedFromBuild>
  <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
  <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Itanium'">true</ExcludedFromBuild>
  <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">true</ExcludedFromBuild>
  <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">true</ExcludedFromBuild>
  <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>

Assembly optimization issue

First attempt fails due to missing bat file that is listed as a pre-build event

If built with Release config, zlib MSVC projects try to run masm in contrib/masmx86 or contrib/masmx64 directory.

<PreBuildEvent>
  <Command>cd ..\..\contrib\masmx64
bld_ml64.bat</Command>
</PreBuildEvent>

These directories were deleted in 1.2.12, thus the build fails.

Workaround

  1. Remove <ClCompile Include="..\..\masmx64\inffas8664.c"> lines from contrib/vstudio/vc14/zlibvc.vcxproj.
  2. Use ReleaseWithoutAsm config instead of Release.

Building for x86 platforms requires a little code patch, though.

@ied206
Copy link

ied206 commented Apr 12, 2022

x86 build error

I also noticed if I build on MSVC 2022 for x86 platform, MSVC generates errors on these functions:

C2708 - crc32_combine & crc32_combine_gen

MSVC 2022 is not allowing implicit z_off_t to z_off64_t casting on x86 builds.
Insert explicit casting to fix this error.

uLong ZEXPORT crc32_combine_gen(len2)
    z_off_t len2;
{
    // return crc32_combine_gen64(len2);
    return crc32_combine_gen64((z_off64_t)len2);
}

C2373 - crc32_combine_op

crc32_combine_op is declared with ZEXPORT on zlib.h, but not on crc32.c.

// from zlib.h
ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
// from crc32.c
uLong crc32_combine_op(crc1, crc2, op)

Insert ZEXPORT to crc32.c to fix this error.
stdcall and cdecl difference are no longer relevant on the non-x86 platforms, so this error does not appear on x64 or arm64 build.

@Spatzendame
Copy link
Author

Thank you with the crc32.c edits I was able to compile zlibwapi.dll and zlib.dll without errors in RleaseWithoutAsm mode.

@topwizprogramming
Copy link

I applied the above changes in VS 2019 and I am getting one error on Win32 compile:
crc32.c(1089,27): error C2708: 'crc32_combine64': actual parameters length in bytes differs from previous call or reference
crc32.c(1072): message : see declaration of 'crc32_combine64'

@topwizprogramming
Copy link

I have Visual Studio 2012, 2017, 2019, and 2022 so once the code is fixed, I can upload solution/project files for them. I've removed Itanium from them.

@Spatzendame
Copy link
Author

Here is fixed master. I have applied all the mentioned workarounds for Win32 ReleaseWithoutAsm build mode.

https://www.mediafire.com/file/jy55bqeh5kosjly/zlib-master.zip/file

@topwizprogramming
Copy link

I created solutions/projects for Visual Studio 2017, 2019, and 2022.

I removed the Itanium platform. I also changed the Runtime Library option to /MT so that the runtime will be built-in.

https://www.topwizprogramming.com/temp/vstudio.zip

@wangdasong888
Copy link

Here is fixed master. I have applied all the mentioned workarounds for Win32 ReleaseWithoutAsm build mode.

https://www.mediafire.com/file/jy55bqeh5kosjly/zlib-master.zip/file

not work

@ramueedupalli
Copy link

Can someone upload zlib1.dll for 1.2.12 version built using VS2010.

@ramueedupalli
Copy link

For me zlibwapi.dll only getting generated. How to build zlib1.dll?

@Duke98666
Copy link

Workaround

  1. Remove <ClCompile Include="..\..\masmx64\inffas8664.c"> lines from contrib/vstudio/vc14/zlibvc.vcxproj.
  2. Use ReleaseWithoutAsm config instead of Release.

With Visual Studio 2012, after making the suggested workaround in contrib/vstudio/vc11/zlibvc.vcxproj, I had to follow this issue #668. I redeclared (void)opaque; at the end of all variable declarations in contrib/minizip/ioapi.c. With that I was able to build the zlibvc project successfully with x64 platform.

@tbeu
Copy link
Contributor

tbeu commented Sep 5, 2022

Resolved by 7ecf7c7 and 6c532a8.

@madler
Copy link
Owner

madler commented Oct 6, 2022

Per @tbeu 's assertion, I will close this issue.

@madler madler closed this as completed Oct 6, 2022
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

No branches or pull requests

8 participants