Skip to content

A cross compilation example from arm64 macos to amd64 linux using Go and zig cc.

Notifications You must be signed in to change notification settings

klingtnet/cross-compile-with-zigcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cross compiling with zig cc

Andrew Kelley announced zig cc, a replacement for GCC/clang, with this blog post. In this repository I want to experiment with cross compiling a sample Go project with C dependencies using zig cc.

To list compilation targets use zig targets, e.g. to list all libc targets for amd64 linux:

$ zig targets | jq -r '.libc[] | select(startswith("x86_64-linux"))'
x86_64-linux-gnu
x86_64-linux-gnux32
x86_64-linux-musl

Please note that I developed this example on an M1 🍏 and thus my target system for cross compilation is amd64 linux.

Run

Just do make run and it should print out a bunch of text ending with

1 foo
2 bar
3 baz

About

A cross compilation example from arm64 macos to amd64 linux using Go and zig cc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published