windows: add clang cross-compile support on Linux

This commit is contained in:
Selim Sandal
2026-02-17 22:17:35 +03:00
parent 278e04ebd6
commit 7a2ea1376e
3 changed files with 108 additions and 14 deletions
+22 -4
View File
@@ -206,9 +206,9 @@ openFPGALoader can be installed via MSYS2:
Cross-compilation from Linux
----------------------------
openFPGALoader can be cross-compiled for Windows from Linux using MinGW-w64.
The build system will automatically download and build the required dependencies
(libusb, libftdi).
openFPGALoader can be cross-compiled for Windows from Linux using MinGW-w64
toolchains (GCC or Clang). The build system will automatically download and
build the required dependencies (libusb, libftdi).
**Prerequisites (Debian/Ubuntu):**
@@ -217,6 +217,8 @@ The build system will automatically download and build the required dependencies
sudo apt install \
mingw-w64 \
libz-mingw-w64-dev \
clang \
lld \
cmake \
pkg-config \
p7zip-full
@@ -230,11 +232,13 @@ The build system will automatically download and build the required dependencies
mingw64-gcc-c++ \
mingw64-zlib \
mingw64-zlib-static \
clang \
lld \
cmake \
p7zip \
p7zip-plugins
**Build:**
**Build (shared steps):**
.. code-block:: bash
@@ -242,9 +246,21 @@ The build system will automatically download and build the required dependencies
cd openFPGALoader
mkdir build-win64
cd build-win64
**Configure + build with GCC (MinGW-w64):**
.. code-block:: bash
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-x86_64-w64-mingw32.cmake ..
cmake --build . --parallel
**Configure + build with Clang (MinGW-w64 target):**
.. code-block:: bash
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-x86_64-w64-mingw32-clang.cmake ..
cmake --build . --parallel
The resulting ``openFPGALoader.exe`` will be a statically-linked executable
that only depends on standard Windows system DLLs (KERNEL32, msvcrt, WS2_32).
@@ -260,6 +276,8 @@ that only depends on standard Windows system DLLs (KERNEL32, msvcrt, WS2_32).
.. code-block:: bash
x86_64-w64-mingw32-strip openFPGALoader.exe
# or
llvm-strip openFPGALoader.exe
**Cross-compilation options:**