build: support Windows and CGO_ENABLED=0 targets#12
Merged
Conversation
Enables clean builds under GOOS=windows CGO_ENABLED=0 and under CGO_ENABLED=0 on Linux. The three tools that can't be built in those configurations now substitute a stub that prints a clear message and exits 1, so go build ./... succeeds across all target platforms. - tools/sniff: tagged !windows && cgo (needs libpcap via cgo). Stub (main_stub.go) covers windows || !cgo. - tools/split: same tags as sniff (also pcap). - tools/sniffer: tagged !windows (uses Unix raw sockets directly via syscall, not cgo). Stub (main_windows.go) covers Windows. Verified: - go build ./... clean (default, cgo=1 Linux) - CGO_ENABLED=0 go build ./... clean (portable Linux) - GOOS=windows CGO_ENABLED=0 go build ./... clean (Windows) - go vet clean across all three configurations - All 13 pkg/transport tests pass under CGO_ENABLED=0, confirming direct_portable.go's directDial path is correct.
Replaces the "Linux/macOS only, use WSL on Windows" note with a table showing the three supported build configurations (default cgo, CGO_ENABLED=0 Linux, Windows), which tools are available in each, and which proxy path works. Also drops a stray reference to a specific KNOWN_ISSUES section number that will drift over time.
Extends the installer to produce CGO_ENABLED=0 static Linux binaries and GOOS=windows .exe cross-compiles, not just the default native cgo build. New flag: --target native (default) Linux/macOS cgo + install (today's flow) --target portable CGO_ENABLED=0, host OS, output to ./dist/portable/ --target windows GOOS=windows amd64, output to ./dist/windows/ --target all build every target in one run When run with no --target and a TTY on stdin, the installer prints an interactive menu that explains each target briefly (tool set, proxy path, output location). Non-TTY invocations (CI, pipes) default silently to native so existing automation keeps working unchanged. Cross-compile targets never install to /usr/local/bin. They drop binaries in ./dist/<target>/ for the user to copy to the right host. The libpcap check and GCC check are now conditional: required for the native target, skipped for portable/windows since those paths use build-tag stubs for libpcap/raw-socket tools.
The Platform Support table already described the three build targets but the Installation block still only showed the default invocation. A reader could see that a windows target existed without knowing how to actually build it. Adds example --target invocations for portable, windows, and all, and softens the dependency paragraph since GCC and libpcap are only required for the native target.
This was referenced Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Finishes what #5 started. Makes
go build ./...succeed on Windows (GOOS=windows CGO_ENABLED=0) and on Linux withCGO_ENABLED=0, without forcing users through WSL. Pairs with the-proxyflag from #10 so Windows and cgo-off users have a proxy path at all.Builds on the
direct_portable.goscaffolding already landed in #10, which provides the pure-Go dialer non-cgo / Windows builds fall back to. This PR just tags the three tools that can't follow that path, gives them stubs, teaches the installer about the new targets, and updates the README accordingly.Changes
Build tags on the three affected tools:
tools/sniff/main.go,tools/split/main.go: tagged!windows && cgo(they importgithub.com/google/gopacket/pcap, which needs libpcap via cgo). Newmain_stub.gotaggedwindows || !cgo.tools/sniffer/main.go: tagged!windows(Unix raw sockets viasyscall.Socket+IP_HDRINCL, no cgo dependency). Newmain_windows.gotaggedwindows.go build ./...always produces a binary and the install layout stays consistent across platforms.install.shgets a--targetflag:--target native(default): today's flow, Linux/macOS cgo, install to/usr/local/bin.--target portable:CGO_ENABLED=0for the host OS, output in./dist/portable/.--target windows:GOOS=windows CGO_ENABLED=0,.exeoutput in./dist/windows/.--target all: build every target in one run.README updates:
--targetinvocations.#9section-number reference in the Proxy Support section.Not changed
install.sh's libpcap check stays for the native target. Cross-compile targets skip it (the stubs handle the absence). The existing sniff/split skip-when-libpcap-missing behavior is preserved for native builds.pkg/third_party/smb2handles its own platform concerns; no tags needed from us.ping.exe,net.exe, etc). These collide with Windows built-ins when run from the same directory in cmd.exe. The native install already prefixes withgopacket-; doing the same for cross-compile outputs is queued as a follow-up.Test plan
go build ./...clean (default, cgo=1 Linux)CGO_ENABLED=0 go build ./...cleanGOOS=windows CGO_ENABLED=0 go build ./...cleango vet ./...clean across all three configurationsgo test ./pkg/transport/passes, 13/13CGO_ENABLED=0 go test ./pkg/transport/passes, 13/13, exercising the portabledirectDialpath end-to-end.exebinaries confirmed working:DumpNTLMInfo(SMB2 negotiate + NTLM info),lookupsid(SAMR over SMB named pipe),samrdump(SAMR user/group enum),rpcdump(RPC epmapper, 435 endpoints listed). Four different protocol stacks exercised via the pure-Gonet.Dialerpath on Windows.