Skip to content

Commit db3de47

Browse files
authored
Use Zig for Windows and ARM64 Linux (#1713)
I'm making steps to simplify our build dependencies, consolidating our C compiler requirements so we only depend on Zig. Before, we used Zig for x64 but not for arm64. This meant that users using an ARM dev machine would need to install `build-essentials` and Zig. We also required MinGW-w64 on Windows, which is a pain to install since it can be provided by a bunch of different tools, the smallest of which is like a 2GB install.
1 parent 0812c6a commit db3de47

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

.github/workflows/build-helper.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ jobs:
3838
sudo apt-get update
3939
sudo apt-get install --no-install-recommends -y libarchive-tools libopenjp2-tools rpm squashfs-tools
4040
sudo snap install snapcraft --classic
41-
sudo snap install zig --classic --beta # We use Zig instead of glibc for cgo compilation as it is more-easily statically linked
41+
- name: Install Zig (not Mac)
42+
if: matrix.platform != 'darwin'
43+
uses: mlugg/setup-zig@v1
4244

4345
# The pre-installed version of the AWS CLI has a segfault problem so we'll install it via Homebrew instead.
4446
- name: Upgrade AWS CLI (Mac only)

.github/workflows/testdriver-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ jobs:
5757
with:
5858
version: 3.x
5959
repo-token: ${{ secrets.GITHUB_TOKEN }}
60+
- name: Install Zig
61+
uses: mlugg/setup-zig@v1
6062

6163
- name: Build
6264
run: task package

BUILD.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ For packaging, the following additional packages are required:
5050

5151
#### Windows
5252

53-
You will need the GNU build toolchain installed in order for Go to work on Windows. In most cases, this requires installing MinGW-w64.
53+
You will need the Zig [Zig](https://ziglang.org/) compiler for statically linking CGO.
5454

55-
The easiest way to install this is using MSYS2: https://www.msys2.org/
56-
57-
If you prefer an alternative method, you can find other methods here: https://www.mingw-w64.org/downloads/
55+
You can find installation instructions for Zig on Windows [here](https://ziglang.org/learn/getting-started/#managers).
5856

5957
### Task
6058

Taskfile.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ tasks:
150150
vars:
151151
ARCHS:
152152
sh: echo {{if eq "arm" ARCH}}arm64{{else}}{{ARCH}}{{end}}
153+
GO_ENV_VARS:
154+
sh: echo "{{if eq "amd64" ARCH}}CC=\"zig cc -target x86_64-windows-gnu\"{{else}}CC=\"zig cc -target aarch64-windows-gnu\"{{end}}"
153155

154156
build:server:linux:
155157
desc: Build the wavesrv component for Linux platforms (only generates artifacts for the current architecture).
@@ -162,7 +164,7 @@ tasks:
162164
ARCHS:
163165
sh: echo {{if eq "arm" ARCH}}arm64{{else}}{{ARCH}}{{end}}
164166
GO_ENV_VARS:
165-
sh: echo "{{if eq "amd64" ARCH}}CC=\"zig cc -target x86_64-linux-gnu.2.28\"{{end}}"
167+
sh: echo "{{if eq "amd64" ARCH}}CC=\"zig cc -target x86_64-linux-gnu.2.28\"{{else}}CC=\"zig cc -target aarch64-linux-gnu.2.28\"{{end}}"
166168

167169
build:server:internal:
168170
requires:

0 commit comments

Comments
 (0)