I’m using a simple github actions to try to build some ELF binaries using windows-latest just to check if it works: https://github.com/libriscv/godot-sandbox-programs/blob/windows/.github/workflows/zig-windows.yml
CC: zig cc -target riscv64-linux-musl
CXX: zig c++ -target riscv64-linux-musl
- name: Build all examples
working-directory: ${{github.workspace}}
export PATH=$PWD/zig-windows-x86_64-0.14.0-dev.2441+3670910f2:$PATH
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSTRIPPED=ON -DCMAKE_TOOLCHAIN_FILE=cmake/zig-toolchain.cmake -DCMAKE_C_COMPILER="${{env.CC}}" -DCMAKE_CXX_COMPILER="${{env.CXX}}"
cmake --build build --parallel 8
<code> build:
runs-on: windows-latest
env:
CC: zig cc -target riscv64-linux-musl
CXX: zig c++ -target riscv64-linux-musl
...
- name: Build all examples
working-directory: ${{github.workspace}}
run: |
export PATH=$PWD/zig-windows-x86_64-0.14.0-dev.2441+3670910f2:$PATH
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSTRIPPED=ON -DCMAKE_TOOLCHAIN_FILE=cmake/zig-toolchain.cmake -DCMAKE_C_COMPILER="${{env.CC}}" -DCMAKE_CXX_COMPILER="${{env.CXX}}"
cmake --build build --parallel 8
shell: bash
</code>
build:
runs-on: windows-latest
env:
CC: zig cc -target riscv64-linux-musl
CXX: zig c++ -target riscv64-linux-musl
...
- name: Build all examples
working-directory: ${{github.workspace}}
run: |
export PATH=$PWD/zig-windows-x86_64-0.14.0-dev.2441+3670910f2:$PATH
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSTRIPPED=ON -DCMAKE_TOOLCHAIN_FILE=cmake/zig-toolchain.cmake -DCMAKE_C_COMPILER="${{env.CC}}" -DCMAKE_CXX_COMPILER="${{env.CXX}}"
cmake --build build --parallel 8
shell: bash
The toolchain file is very short:
<code>set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "riscv64")
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_C_COMPILER "zig" cc -target riscv64-linux-musl)
set(CMAKE_CXX_COMPILER "zig" c++ -target riscv64-linux-musl)
<code>set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "riscv64")
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_C_COMPILER "zig" cc -target riscv64-linux-musl)
set(CMAKE_CXX_COMPILER "zig" c++ -target riscv64-linux-musl)
</code>
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "riscv64")
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_C_COMPILER "zig" cc -target riscv64-linux-musl)
set(CMAKE_CXX_COMPILER "zig" c++ -target riscv64-linux-musl)
… and it works on Linux and macOS both.
On Windows I am using ninja to build, and it’s correctly showing Clang 19.1 as the compiler (Zig 0.14 nightly):
<code>Run export PATH=$PWD/zig-windows-x86_64-0.14.0-dev.2441+3670910f2:$PATH
-- The C compiler identification is Clang 19.1.0
-- The CXX compiler identification is Clang 19.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/a/godot-sandbox-programs/godot-sandbox-programs/zig-windows-x86_64-0.14.0-dev.2441+3670910f2/zig.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/a/godot-sandbox-programs/godot-sandbox-programs/zig-windows-x86_64-0.14.0-dev.2441+3670910f2/zig.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
<code>Run export PATH=$PWD/zig-windows-x86_64-0.14.0-dev.2441+3670910f2:$PATH
-- The C compiler identification is Clang 19.1.0
-- The CXX compiler identification is Clang 19.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/a/godot-sandbox-programs/godot-sandbox-programs/zig-windows-x86_64-0.14.0-dev.2441+3670910f2/zig.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/a/godot-sandbox-programs/godot-sandbox-programs/zig-windows-x86_64-0.14.0-dev.2441+3670910f2/zig.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
</code>
Run export PATH=$PWD/zig-windows-x86_64-0.14.0-dev.2441+3670910f2:$PATH
-- The C compiler identification is Clang 19.1.0
-- The CXX compiler identification is Clang 19.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/a/godot-sandbox-programs/godot-sandbox-programs/zig-windows-x86_64-0.14.0-dev.2441+3670910f2/zig.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/a/godot-sandbox-programs/godot-sandbox-programs/zig-windows-x86_64-0.14.0-dev.2441+3670910f2/zig.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
It then proceeds to build everything until the first program needs to be linked:
<code>[146/181] Linking CXX executable binasm
C:Windowssystem32cmd.exe /C "cd . && D:agodot-sandbox-programsgodot-sandbox-programszig-windows-x86_64-0.14.0-dev.2441+3670910f2zig.exe c++ -target riscv64-linux-musl -O3 -DNDEBUG -s -Xlinker --dependency-file -Xlinker programsasmCMakeFilesasm.dirlink.d programs/asm/CMakeFiles/asm.dir/main.cpp.o programs/asm/CMakeFiles/asm.dir/extra/obstack.c.o -o binasm -Wl,--whole-archive _deps/godot-sandbox-build/libsandbox_api.a -Wl,--no-whole-archive -static D:/a/godot-sandbox-programs/godot-sandbox-programs/programs/asm/zig-libRiscvAsmLib.a -Wl,--image-base=0x100000 _deps/zlib-build/libz.a && cd ."
error: unsupported linker arg: --dependency-file
<code>[146/181] Linking CXX executable binasm
FAILED: bin/asm
C:Windowssystem32cmd.exe /C "cd . && D:agodot-sandbox-programsgodot-sandbox-programszig-windows-x86_64-0.14.0-dev.2441+3670910f2zig.exe c++ -target riscv64-linux-musl -O3 -DNDEBUG -s -Xlinker --dependency-file -Xlinker programsasmCMakeFilesasm.dirlink.d programs/asm/CMakeFiles/asm.dir/main.cpp.o programs/asm/CMakeFiles/asm.dir/extra/obstack.c.o -o binasm -Wl,--whole-archive _deps/godot-sandbox-build/libsandbox_api.a -Wl,--no-whole-archive -static D:/a/godot-sandbox-programs/godot-sandbox-programs/programs/asm/zig-libRiscvAsmLib.a -Wl,--image-base=0x100000 _deps/zlib-build/libz.a && cd ."
error: unsupported linker arg: --dependency-file
</code>
[146/181] Linking CXX executable binasm
FAILED: bin/asm
C:Windowssystem32cmd.exe /C "cd . && D:agodot-sandbox-programsgodot-sandbox-programszig-windows-x86_64-0.14.0-dev.2441+3670910f2zig.exe c++ -target riscv64-linux-musl -O3 -DNDEBUG -s -Xlinker --dependency-file -Xlinker programsasmCMakeFilesasm.dirlink.d programs/asm/CMakeFiles/asm.dir/main.cpp.o programs/asm/CMakeFiles/asm.dir/extra/obstack.c.o -o binasm -Wl,--whole-archive _deps/godot-sandbox-build/libsandbox_api.a -Wl,--no-whole-archive -static D:/a/godot-sandbox-programs/godot-sandbox-programs/programs/asm/zig-libRiscvAsmLib.a -Wl,--image-base=0x100000 _deps/zlib-build/libz.a && cd ."
error: unsupported linker arg: --dependency-file
Looking at Kitware I find this issue which looks related, but ultimately is the opposite of what I’m doing: https://gitlab.kitware.com/cmake/cmake/-/issues/26250
That is, I’m not trying to build Windows binaries. This is a 64-bit RISC-V toolchain that produces ELF binaries on two other platforms. Windows should not be any different here.
What seems to be the issue here? Is there a way to solve this, or work around the issue?