Skip to content

Add toolchain file to optimize MSVC-based release builds - #718

Open
fredemmott wants to merge 1 commit into
trabucayre:masterfrom
fredemmott:msvc-redist-toolchain
Open

Add toolchain file to optimize MSVC-based release builds#718
fredemmott wants to merge 1 commit into
trabucayre:masterfrom
fredemmott:msvc-redist-toolchain

Conversation

@fredemmott

Copy link
Copy Markdown
  • use 'hybrid CRT' to keep it dependency-free on Win10+ without the full size of static linking
  • add default MSVC release optimizations to RelWithDebInfo

refs #704


Testing:

cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/openfpgaloader/cmake/Toolchain-x86_64-w64-msvc-redist.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static

cmake --build . --parallel --config RelWithDebInfo

On my v1.1.1 branch, this gets me a 2.5MB exe that only depends on:

  • WS2_32.dll (winsock2, specifically ntohs()
  • KERNEL32.dll
  • ucrtbase.dll (~ libc)

... and also gives me ~ 20MB of debug symbols, separate to the exe:

image

I then used this to re-flash a ModRetro Chromatic with customized firmware:

image

- use 'hybrid CRT' to keep it dependency-free on Win10+ without the full
  size of static linking
- add default MSVC release optimizations to RelWithDebInfo

refs trabucayre#704
@fredemmott

fredemmott commented Aug 12, 2026

Copy link
Copy Markdown
Author

Just for comparison, here's the current mingw build (~ 4MB):

image

... and the mingw ucrt build (~ 4MB):

image

By comparison, this toolchain + MSVC allows 'just download the exe', more suitable for integration with other programs (e.g. FlashGBX) - and it's ~ half the size of the mingw binaries that depend on libftdi/libusb

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.

1 participant