Skip to content

Conversation

@vmoroz
Copy link
Member

@vmoroz vmoroz commented Nov 1, 2025

This PR introduces two main improvements to the hermes-windows fork:

  1. Hybrid CRT Implementation (Win32 targets):
    The Win32 build now follows the “Hybrid CRT” model from the Windows App SDK Coding Guidelines: the static C++ runtime (/MTd or /MT) is linked while the Universal CRT (UCRT) remains dynamically linked. This removes the dependency on the Visual C++ Redistributable (MSVCP140.dll, etc.), so Hermes-based apps only require the inbox UCRT.
    Note: UWP (WindowsStore) builds continue to use the default dynamic CRT, because the platform forbids statically linking the MSVC runtime. CMake’s CMAKE_MSVC_RUNTIME_LIBRARY is therefore only forced for Win32 configurations.

  2. Windows Build Logic Consolidation:
    All Windows-specific build logic, patches, and workarounds now live in HermesWindows.cmake instead of being scattered through the upstream CMakeLists.txt files. This keeps our fork closer to facebook/hermes, easing future merges.

Key Changes

  • Build System & Hybrid CRT
    • Win32 builds link the static C++ runtime and the dynamic UCRT, eliminating the need to redistribute the VC runtime.
    • Example dependency diff for hermes.dll (Win32 Release):
Before (Release) After (Release)
MSVCP140.dll
VCRUNTIME140.dll
VCRUNTIME140_1.dll
KERNEL32.dll KERNEL32.dll
ADVAPI32.dll ADVAPI32.dll
WINMM.dll WINMM.dll
icuuc.dll icuuc.dll
icuin.dll icuin.dll
api-ms-win-crt-stdio-l1-1-0.dll api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll api-ms-win-crt-utility-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
  • hermes.dll size change (Win32 Release):
Before (bytes) After (bytes) Delta % Change
5,136,896 5,300,224 +163,328 +3.18 %
  • Build Logic Consolidation

    • HermesWindows.cmake centralizes the Windows configuration.
    • CMAKE_MSVC_RUNTIME_LIBRARY is set there only for non-UWP builds so Win32 uses Hybrid CRT while UWP keeps the supported dynamic CRT.
    • Upstream CMakeLists were cleaned up; MSVC-specific tweaks now flow from this central module, and older property-based flag wiring moved to target_compile_options.
  • Documentation

    • Added HermesWindowsFork.md to explain the fork’s principles, Hybrid CRT approach, and merge strategy.
  • Cleanup

    • Removed the lingering test/node-hermes directory so our tree matches upstream.
Microsoft Reviewers: Open in CodeFlow

@vmoroz vmoroz requested a review from a team as a code owner November 1, 2025 00:15
set(MSVC_CXX_FLAGS "${MSVC_CXX_FLAGS} /wd4275")
# C4646: function declared with 'noreturn' has non-void return type
set(MSVC_CXX_FLAGS "${MSVC_CXX_FLAGS} /wd4646")
# C4312: 'reinterpret_cast': conversion from 'X' to 'hermes::vm::GCCell *' of greater size
Copy link
Member

Choose a reason for hiding this comment

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

seems scary to suppress this one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, but I had no choice before. I cannot affect the code from Meta. I can try to remove it to see how it behaves today, Or at least change it to a warning instead of error.


### Hybrid CRT Configuration

A major feature of this fork is the **Hybrid CRT configuration**, which ensures
Copy link
Member

Choose a reason for hiding this comment

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

Is this for non-Office usage? I would hope the binaries we ship in Office aren't statically linking the CRT at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is exactly the reason for the PR. Tiago said that currently the hermes.dll causes issues with Office because of the imports. Thus, as he suggested and pointed to your PR we statically link the C++ runtime and dynamically the UCRT.

Copy link
Member

Choose a reason for hiding this comment

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

Oh. So, Office is presumably consuming a hermes.dll that statically links the CRT. This will help that case. I would guess dynamically linking the CRT is too hard to synchronize the versions with Office.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just checked the DLL size and updated the PR description. The size increase is just about 163K or 3.18%.

@vmoroz vmoroz force-pushed the PR/fix-dll-dependencies branch from b95ae9a to d7a00cd Compare November 1, 2025 15:59
@tiagomacarios
Copy link
Member

lgtm

@vmoroz vmoroz merged commit c575612 into microsoft:main Nov 3, 2025
12 checks passed
@vmoroz vmoroz deleted the PR/fix-dll-dependencies branch November 3, 2025 18:30
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.

4 participants