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 fails to link with Whole Program Optimization enabled #2183

Open
3 tasks done
TobyShaw opened this issue Nov 27, 2023 · 1 comment
Open
3 tasks done

Zlib fails to link with Whole Program Optimization enabled #2183

TobyShaw opened this issue Nov 27, 2023 · 1 comment

Comments

@TobyShaw
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

There's a strong possibility that I'm doing something wrong here with my VS setup. That said, I believe I've faithfully followed the instructions here: https://github.com/PowerShell/Win32-OpenSSH/wiki/Building-OpenSSH-for-Windows-(using-LibreSSL-crypto).

Relevant versions:

Microsoft Visual Studio Enterprise 2022
Version 17.8.0
VisualStudio.17.Release/17.8.0+34309.116
Microsoft .NET Framework
Version 4.8.09032

Visual C++ 2022 00482-20704-71775-AA324
Microsoft Visual C++ 2022

Despite zlib and OpenSSH both referencing PlatformToolset v143, I get a link error with Whole Program Optimization enabled:

Error C1047 The object or library file '...\ZLib\bin\x64\zlib.lib' was created by a different version of the compiler than other objects like 'x64\Release\ssh\clientloop.obj'; rebuild all objects and libraries with the same compiler ssh

The error goes away if I disable this setting.

Expected behavior

It builds

Actual behavior

I get the error:
> Error	C1047	The object or library file '...\ZLib\bin\x64\zlib.lib' was created by a different version of the compiler than other objects like 'x64\Release\ssh\clientloop.obj'; rebuild all objects and libraries with the same compiler	ssh

Error details

No response

Environment data

n/a

Version

9.4.0.0-p1

Visuals

No response

@tgauth
Copy link
Collaborator

tgauth commented Nov 27, 2023

You're not doing anything wrong - we just started seeing this on our CI as well - thanks for opening an issue!

Since ZLib and OpenSSH are built with optimizations, Visual Studio requires that both are built with the same compiler version (major and minor, per https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1047?view=msvc-170). PowerShell/ZLib was compiled with version 17.7.

Other temporary workarounds besides what you already mentioned:

  1. Compile OpenSSH with Visual Studio 17.7.
  2. Build ZLib with Visual Studio 17.8.

We are working on a more permanent solution.

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

No branches or pull requests

2 participants