consider using zig cc instead of musl.cc
cattyhouse opened this issue · comments
Justin commented
With zig cc, there is no need to download tool chains, as zig cc is able to prepare/compile needed libc for various arch on the fly.
Build linux binary on macOS for instance:
make CC="zig cc -s -static -target x86_64-linux-musl" AR="zig ar"
hev commented
Could you please create a pull request? Thanks.
Justin commented
hev-socks5-tunnel example
make clean ; make CC="zig cc -s -static -fpie -target x86_64-linux-musl" AR="zig ar" -j
...
Compiling objects ....
...
tree -L 1 ~/.cache/zig
Compiled objects are cached for reuse
/Users/m1/.cache/zig
├── h
├── o
├── tmp
└── z
5 directories, 0 files
file bin/hev-socks5-tunnel
bin/hev-socks5-tunnel: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, stripped
Caveat
I got this message from macOS strip, maybe it is due to how Makefile was written?
...
LINK bin/libhev-task-system.a
LINK bin/hev-socks5-tunnel
/Library/Developer/CommandLineTools/usr/bin/strip: warning: can't process non-object and non-archive file: /Users/m1/make/hev-socks5-tunnel/bin/hev-socks5-tunnel
STRIP bin/hev-socks5-tunnel
Justin commented
Could you please create a pull request? Thanks.
I am not familiar with Github Actions, but this is just another way to cross static compile
Justin commented
Not an issue actually, kinda like a FYI :)