-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build(client/electron): build cross-platform with zig #1960
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! You mentioned podman is too slow, do we still need podman in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code LGTM, with a few comments! By the way, zig
seems to be very powerful:
When it comes to macOS, Zig even has a custom built linker able to cross-compile for both Intel and Apple Silicon M1, something that not even lld (LLVM's linker) can do.
The only concern is zig
has not published any stable release yet, the latest version is 0.11.0
.
Makefile
Outdated
@@ -57,15 +55,12 @@ windows: $(WINDOWS_BUILDDIR)/tun2socks.exe | |||
|
|||
$(WINDOWS_BUILDDIR)/tun2socks.exe: | |||
mkdir -p "$(@D)" | |||
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" go build --ldflags=--extldflags=$(XGO_LDFLAGS) -o "$@" $(ELECTRON_PKG) | |||
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -trimpath -ldflags=--extldflags=$(LDFLAGS) -o "$@" $(ELECTRON_PKG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zig
also supports x86_64-windows
as well. But it only supports Windows 10+. We can keep using MinGW-w64 for backward compatibility now, but I'd prefer to use the same toolchain in the future when we decide to drop the support of old Windows.
src/electron/README.md
Outdated
``` | ||
|
||
With Homebrew (unofficial, how to ensure consistent version?): | ||
You can download the binary tarball, or use a package manager, like Homebrew: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A link to the supported package managers may be useful. It covers almost all platforms including Windows, macOS and Ubuntu.
You can download the binary tarball, or use a package manager, like Homebrew: | |
You can download the binary tarball, or use a [package manager](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager), like Homebrew: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added (though the install instruction above also mentions list them)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments addressed
src/electron/README.md
Outdated
``` | ||
|
||
With Homebrew (unofficial, how to ensure consistent version?): | ||
You can download the binary tarball, or use a package manager, like Homebrew: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added (though the install instruction above also mentions list them)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Now we have a more consistent toolchain for build.
I'm using zig to cross-compile. It's SO MUCH EASIER:
https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho
/cc @daniellacosse @amircybersec