Skip to content

Add MSVC build scripts & fix for MSVC#11

Merged
solardiz merged 3 commits into
openwall:mainfrom
quadcpu:msvc
Jun 15, 2026
Merged

Add MSVC build scripts & fix for MSVC#11
solardiz merged 3 commits into
openwall:mainfrom
quadcpu:msvc

Conversation

@quadcpu

@quadcpu quadcpu commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Adding build scripts for Windows MSVC and applied some fixes for MSVC compiler ( which doesn't support many of C lang keywords and unix apis )

This is implemented because Rust and Node.js still requires MSVC targets for c bindings ( maybe they would add support for clang-cl at the future, but I think it would not happen at least on upcoming years ), and since gcc / clang still remains experimental for windows support :(

Source fixes for MSVC (all guarded so GCC behavior is unchanged):

  • sha256.c — [static restrict N] → [restrict N] (MSVC rejects static in array params).
  • tests.c — setvbuf(..._IOLBF...) → _IONBF under _MSC_VER (the _IOLBF+NULL form crashes MSVC).
  • phc.c — added a Win32 times/sysconf/struct tms shim under _MSC_VER (timing only, goes to stderr; doesn't affect hashes).

It builds on Windows like https://github.com/quadcpu/yescrypt/actions/runs/27431709479/job/81083451845

@solardiz

Copy link
Copy Markdown
Member

Thanks. I'll comment in openwall/yespower#4 first, then we can revisit this one. We also need to decide on what to do with #10.

- Makefile: make the "check" target exit non-zero on a test mismatch
  instead of merely printing FAILED.
- CI: rely on "make check" / "build.ps1 -Target check" exit codes rather
  than reimplementing the test/diff logic in YAML; compile-cover the
  OpenMP/SysV-shm path on Linux by building initrom and userom.
- build.ps1: add the copyright/license header.
@quadcpu

quadcpu commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@solardiz Done, applied similar changes as requested on openwall/yespower#4

Comment thread phc.c Outdated

#ifdef TEST
#include <stdio.h>
#ifdef _MSC_VER

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please invert the condition here (and swap the blocks).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread README Outdated
We do most of our testing on Linux systems with gcc. The supplied
Makefile assumes that you use gcc.

On Windows.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this "On Windows." line is not correctly indented. We use one tab for other headings in README, and this probably uses 4 spaces. (I only noticed this after merging the yespower PR, as GitHub UI does not show the distinction - it assumes tab width of 4, but I normally use 8.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please include two empty lines (not one) before this heading for consistency with the rest of them in this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, also VScode sucks to detect it ( only linux / nano editor were capable to detect it so far )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

quadcpu added a commit to quadcpu/yescrypt that referenced this pull request Jun 15, 2026
- phc.c: invert the _MSC_VER condition so the POSIX include block comes
  first (#ifndef _MSC_VER), with the MSVC shim under #else.
- README: fix the "On Windows." heading to use a tab like other headings
  instead of 4 spaces.

Per review on openwall/yescrypt PR openwall#11.
@quadcpu quadcpu requested a review from solardiz June 15, 2026 18:16
- phc.c: invert the _MSC_VER condition so the POSIX include block comes
  first (#ifndef _MSC_VER), with the MSVC shim under #else.
- README: fix the "On Windows." heading to use a tab like other headings
  instead of 4 spaces.

Per review on openwall/yescrypt PR openwall#11.
@quadcpu

quadcpu commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@solardiz Done

@solardiz solardiz merged commit ccdf3e9 into openwall:main Jun 15, 2026
@solardiz

Copy link
Copy Markdown
Member

Merged, thanks! I also realized we completely forgot to update CHANGES for both projects, but I guess I'll take care of that separately later.

@quadcpu quadcpu deleted the msvc branch June 15, 2026 19:00
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.

2 participants