Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 43f345e

Browse files
committedMar 19, 2025·
Support zig compiler
1 parent 1a1eb18 commit 43f345e

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed
 

‎.github/workflows/zig.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Zig compiler
2+
on:
3+
push:
4+
branches: [ '*' ]
5+
pull_request:
6+
branches: [ '*' ]
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref_name }}
9+
cancel-in-progress: true
10+
jobs:
11+
zig:
12+
if: github.repository_owner == 'aws'
13+
runs-on: ${{ matrix.os.name }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os:
18+
- name: windows-latest
19+
target: x86_64-windows
20+
- name: ubuntu-latest
21+
target: x86_64-linux
22+
- name: macos-latest
23+
target: aarch64-macos
24+
steps:
25+
- name: Install NASM
26+
uses: ilammy/setup-nasm@v1.5.1
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
- name: Install ninja-build tool
30+
uses: seanmiddleditch/gha-setup-ninja@v4
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.13'
34+
- uses: actions/setup-go@v4
35+
with:
36+
go-version: '>= 1.18'
37+
- name: Install zigcc
38+
uses: jiacai2050/zigcc@v1.0.1
39+
with:
40+
zig-version: 0.14.0
41+
- name: Locate zig not on Windows
42+
if: matrix.os.name != 'windows-latest'
43+
shell: bash
44+
run: |
45+
cat <<'EOF' > ${PWD}/zig-cc
46+
#!/bin/bash
47+
zig cc "$@"
48+
EOF
49+
chmod +x ${PWD}/zig-cc
50+
cat <<'EOF' > ${PWD}/zig-c++
51+
#!/bin/bash
52+
zig c++ "$@"
53+
EOF
54+
chmod +x ${PWD}/zig-c++
55+
echo "ZIGCC=${PWD}/zig-cc" >> $GITHUB_ENV
56+
echo "ZIGCXX=${PWD}/zig-c++" >> $GITHUB_ENV
57+
- name: Locate zig on Windows
58+
if: matrix.os.name == 'windows-latest'
59+
shell: bash
60+
run: |
61+
ZIGCC="python3 $(cygpath -m $(which zigcc))"
62+
ZIGCXX="python3 $(cygpath -m $(which zigcxx))"
63+
echo "ZIGCC=${ZIGCC}" >> $GITHUB_ENV
64+
echo "ZIGCXX=${ZIGCXX}" >> $GITHUB_ENV
65+
- name: Create toolchain
66+
shell: bash
67+
run: |
68+
cat <<EOF > ./toolchain.cmake
69+
set(CMAKE_C_COMPILER ${ZIGCC})
70+
set(CMAKE_C_COMPILER_TARGET ${{ matrix.os.target }})
71+
set(CMAKE_CXX_COMPILER ${ZIGCXX})
72+
set(CMAKE_CXX_COMPILER_TARGET ${{ matrix.os.target }})
73+
set(CMAKE_ASM_COMPILER ${ZIGCC})
74+
set(CMAKE_ASM_COMPILER_TARGET ${{ matrix.os.target }})
75+
set(CMAKE_VERBOSE_MAKEFILE ON)
76+
set(CMAKE_MESSAGE_LOG_LEVEL DEBUG)
77+
EOF
78+
- name: Setup CMake
79+
shell: bash
80+
run: |
81+
printenv | sort
82+
which zigcc
83+
which zigcxx
84+
cat ./toolchain.cmake
85+
cmake '.' -B ./build -G Ninja -DCMAKE_TOOLCHAIN_FILE=./toolchain.cmake -DCMAKE_BUILD_TYPE=Release
86+
- name: Build Project
87+
shell: bash
88+
run: |
89+
cmake --build ./build --target ssl --verbose

‎CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ if(GCC OR CLANG)
428428
endif()
429429
endif()
430430

431-
if(MINGW)
431+
if(MINGW AND NOT CLANG)
432432
# Some MinGW compilers set _WIN32_WINNT to an older version (Windows Server 2003)
433433
# See: https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
434434
# Support Windows 7 and later.

0 commit comments

Comments
 (0)
Please sign in to comment.