heiher/hev-socks5-tproxy

consider using zig cc instead of musl.cc

Closed this issue · 4 comments

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"

reference

heiher commented

Could you please create a pull request? Thanks.

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

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

Not an issue actually, kinda like a FYI :)