Skip to content

fix(#70): include with_gvisor build tag in goClash archive#71

Merged
mixc6763-prog merged 1 commit into
mainfrom
fix/70-wireguard-gvisor
May 7, 2026
Merged

fix(#70): include with_gvisor build tag in goClash archive#71
mixc6763-prog merged 1 commit into
mainfrom
fix/70-wireguard-gvisor

Conversation

@mixc6763-prog
Copy link
Copy Markdown
Contributor

Summary

Fixes #70 — config loading fails for any profile containing a WireGuard proxy:

proxy 0: create WireGuard device: gVisor is not included in this build, rebuild with -tags with_gvisor

Root Cause

The mihomo core ships in two flavors in this project:

Artifact Source Used by with_gvisor
goClash.a goClash/main.go (-buildmode=c-archive) Main app process via cgo — config parsing, proxy creation ❌ missing
mihomo_core goClash/mihomo-bin/main.go (standalone binary) Auxiliary scenarios ✅ present

build_clash_universal.py already passed -tags with_gvisor for mihomo_core (line 51), but not for goClash.a (line 25). Since config loading and WireGuard device creation happen inside the main process via goClash.a, mihomo's tag-gated WireGuard implementation was unavailable and rejected every WireGuard proxy.

The github.com/metacubex/gvisor dependency is already present in go.mod, so this is purely a missing build flag — no new dependency, no Go code changes.

Change

One-line addition of -tags with_gvisor to the build_clash archive command, matching what build_mihomo_bin already does.

Local Verification

Rebuilt with the patch, then compared symbol tables:

Before After
goClash.a size 165 MB 184 MB (+20 MB gVisor netstack)
gvisor symbols (nm goClash.a | grep -ic gvisor) 2 (forward decls only) 7350

Build completes cleanly through both arm64 and amd64 arches and the universal lipo merge.

Impact

  • WireGuard proxies now load as expected.
  • Binary size +~20 MB (gVisor userspace network stack).
  • Runtime cost zero unless a WireGuard proxy is actually instantiated.
  • Enhanced Mode (TUN) unaffected — uses sing-tun, not gVisor.
  • CGO / signing / notarize flow unchanged.

The embedded mihomo core (goClash.a) was built without the with_gvisor
tag, causing WireGuard proxy creation to fail at config-load time:

    proxy 0: create WireGuard device: gVisor is not included in this
    build, rebuild with -tags with_gvisor

mihomo's WireGuard implementation depends on gVisor's userspace network
stack, gated behind the with_gvisor build tag. The standalone mihomo_core
binary already included this tag; the c-archive linked into the main app
process did not, so any config containing a WireGuard proxy failed to
load.

Add -tags with_gvisor to build_clash so goClash.a matches mihomo_core.
Verified locally: archive grew from 165 MB -> 184 MB and now contains
~7350 gvisor symbols (vs 2 forward declarations before).

Fixes #70
@mixc6763-prog mixc6763-prog merged commit 0a646c8 into main May 7, 2026
1 check passed
@mixc6763-prog mixc6763-prog deleted the fix/70-wireguard-gvisor branch May 7, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Config loading Fail

1 participant