Skip to content
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

Merged
merged 7 commits into from
Apr 10, 2024
Merged

Conversation

fortuna
Copy link
Collaborator

@fortuna fortuna commented Apr 6, 2024

@fortuna fortuna requested a review from jyyi1 April 6, 2024 00:12
@fortuna fortuna requested a review from a team as a code owner April 6, 2024 00:12
@fortuna fortuna enabled auto-merge (squash) April 6, 2024 00:13
Copy link
Contributor

@jyyi1 jyyi1 left a 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?

src/electron/README.md Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@fortuna fortuna changed the title build(client/electron/linux): build linux with musl-cross build(client/electron): build cross-platform with zig Apr 10, 2024
Copy link
Collaborator Author

@fortuna fortuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another look?

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
src/electron/README.md Outdated Show resolved Hide resolved
@fortuna fortuna requested a review from jyyi1 April 10, 2024 16:14
Copy link
Contributor

@jyyi1 jyyi1 left a 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)
Copy link
Contributor

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 Show resolved Hide resolved
```

With Homebrew (unofficial, how to ensure consistent version?):
You can download the binary tarball, or use a package manager, like Homebrew:
Copy link
Contributor

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.

Suggested change
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:

Copy link
Collaborator Author

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)

src/electron/README.md Show resolved Hide resolved
Copy link
Collaborator Author

@fortuna fortuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments addressed

```

With Homebrew (unofficial, how to ensure consistent version?):
You can download the binary tarball, or use a package manager, like Homebrew:
Copy link
Collaborator Author

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)

src/electron/README.md Show resolved Hide resolved
@fortuna fortuna requested a review from jyyi1 April 10, 2024 18:08
Copy link
Contributor

@jyyi1 jyyi1 left a 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.

@fortuna fortuna merged commit 1089944 into master Apr 10, 2024
19 checks passed
@fortuna fortuna deleted the fortuna-linux branch April 10, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants