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

3.9.2 fails to build in release mode on windows #1089

Open
d3x0r opened this issue Aug 24, 2024 · 3 comments
Open

3.9.2 fails to build in release mode on windows #1089

d3x0r opened this issue Aug 24, 2024 · 3 comments

Comments

@d3x0r
Copy link
Contributor

d3x0r commented Aug 24, 2024

#266 has a reference to _CrtSetReportMode so I assume it was added because of this

'_CrtSetReportMode' is only available in the debug c runtime... according to https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode?view=msvc-170

Libraries: Debug versions of the C runtime libraries only.

Unfortunately _DEBUG which is normally defined by Visual studio default projects isn't set when cmake generates the project file (without additional code in the cmakelists)

But then RelWithDebugInfo cmake builds link against release runtime, but should also have _DEBUG enabled... I added a few lines like the following to the cmake lists and then put #if defined _MSC_VER && _MSC_VER >= 1900 && defined( _DEBUG ) && !defined( _REL_DEBUG ) around the code in crypto\compat\posix_win.c that defines using _CrtSetReportMode..

if( ${CMAKE_BUILD_TYPE} MATCHES "[rR][eE][lL][wW][iI].*" )
   ADD_DEFINITIONS( -D_REL_DEBUG )
endif()

if( ${CMAKE_BUILD_TYPE} MATCHES "[dD][eE][bB][uU][gG]"
   OR ${CMAKE_BUILD_TYPE} MATCHES "[rR][eE][lL][wW][iI].*" )
   ADD_DEFINITIONS( -D_DEBUG )
endif()

as a side note, NDEBUG is defined for release builds of projects created by Visual Studio, and again, not by CMake.

@datadiode
Copy link

My understanding is that a RelWithDebugInfo cmake build should see the exact same source code as a Release cmake build.
For either of them, I'd expect _DEBUG to not be defined.

@d3x0r
Copy link
Contributor Author

d3x0r commented Sep 21, 2024

other than it says 'With Debug Info' ...it's not part of visual studio's default practices... but even so...

https://github.com/libressl/portable/blob/master/crypto/compat/posix_win.c#L155

has no specification of debug or release, so it will just build if MSVC, which under release will fail or relwithdebug info (since they should both link against release runtime) regardless of whether debug in the app/library is enabled.

@datadiode
Copy link

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

2 participants