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

Add support for building static lib with MSVC #195

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

cmb69
Copy link

@cmb69 cmb69 commented Dec 10, 2024

This PR solves a couple of mostly minor issues (see individual commit messages for details) which prevent building the static crypt.lib with MSVC on Windows. For building a shared library (DLL) exported functions would need to be decorated with __declspec(dllexport) and __declspec(dllimport), respectively (see 'win32-dll' argument of LT_INIT()).

The biggest hurdle is that autoconf currently (2.72) does not properly recognize C11 support (only has recently been fixed in the development branch). I worked around that with the following hack:

 configure.ac | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 4b8afd8..1523e92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@ m4_pattern_allow([PKG_INSTALLDIR])
 # Checks for programs.
 AC_CANONICAL_HOST
 AC_PROG_CC
+ac_prog_cc_stdc=c11
 
 # Dependencies
 PKG_PROG_PKG_CONFIG

Closes #193.

MSVC doesn't define any endianness macros, but for x64 (and ARM64EC) as
well as x86 processors MSVC uses little-endian order.  We define that
accordingly.
MSVC does not support any inline assembly (let alone symversioning).
`ssize_t` is not supported, but `SSIZE_T` with the same meaning.
MSVC doesn't support `explicit_memset()` nor `memset_s()`, but has
`SecureZeroMemory()`, which appears to be more appropriate than falling
back on an own function definition.
cmb69 added a commit to cmb69/winlib-builder that referenced this pull request Dec 11, 2024
This does a full client build of libxcrypt, using upstream's autotools
based build chain on MSYS2, but using MSVC build tools. This requires
wrappers for the MSVC build tools; ar-lib and compile are taken
unmodified from automake; windres is a minimalist self-made wrapper.

A prerequisite is a suitable libxcrypt patched to support MSVC
builds[1].

[1] <besser82/libxcrypt#195>
cmb69 added a commit to cmb69/winlib-builder that referenced this pull request Dec 11, 2024
This does a full client build of libxcrypt, using upstream's autotools
based build chain on MSYS2, but using MSVC build tools. This requires
wrappers for the MSVC build tools; ar-lib and compile are taken
unmodified from automake; windres is a minimalist self-made wrapper.

A prerequisite is a suitable libxcrypt patched to support MSVC
builds[1].

[1] <besser82/libxcrypt#195>
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

Successfully merging this pull request may close these issues.

Windows support plan
1 participant