aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-07 19:12:53 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-10 17:35:01 +0100
commitd58bf877bb6f5672cf4cd53e299b64ff85b808df (patch)
tree084c1687a4677d3b8c9b4bf08f659264dcd220c5
parentui: syntax: port to go (diff)
downloadwireguard-windows-d58bf877bb6f5672cf4cd53e299b64ff85b808df.tar.xz
wireguard-windows-d58bf877bb6f5672cf4cd53e299b64ff85b808df.zip
build: remove cgo
This doesn't yet build but we'll get there. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--Makefile10
-rw-r--r--build.bat10
-rw-r--r--gotext.go2
-rw-r--r--installer/build.bat1
4 files changed, 5 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 18fb7125..76f7240a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,4 @@
-GOFLAGS := -ldflags="-H windowsgui -s -w" -v -tags walk_use_cgo -trimpath
-export CGO_ENABLED := 1
-export CGO_CFLAGS := -O3 -Wall -Wno-unused-function -Wno-switch -std=gnu11 -DWINVER=0x0601
+GOFLAGS := -ldflags="-H windowsgui -s -w" -v -trimpath
export GOOS := windows
VERSION := $(shell sed -n 's/^\s*Number\s*=\s*"\([0-9.]\+\)"$$/\1/p' version/version.go)
@@ -45,23 +43,19 @@ resources_386.syso: $(RESOURCE_FILES)
resources_arm.syso: $(RESOURCE_FILES)
armv7-w64-mingw32-windres $(RCFLAGS) -I .deps/wintun/bin/arm -i $< -o $@
-amd64/wireguard.exe: export CC := x86_64-w64-mingw32-gcc
amd64/wireguard.exe: export GOARCH := amd64
amd64/wireguard.exe: resources_amd64.syso $(SOURCE_FILES)
GOROOT="$(CURDIR)/.deps/goroot" go build $(GOFLAGS) -o $@
-x86/wireguard.exe: export CC := i686-w64-mingw32-gcc
x86/wireguard.exe: export GOARCH := 386
x86/wireguard.exe: resources_386.syso $(SOURCE_FILES)
GOROOT="$(CURDIR)/.deps/goroot" go build $(GOFLAGS) -o $@
-arm/wireguard.exe: export CC := armv7-w64-mingw32-gcc
arm/wireguard.exe: export GOARCH := arm
arm/wireguard.exe: export GOARM := 7
arm/wireguard.exe: resources_arm.syso $(SOURCE_FILES)
GOROOT="$(CURDIR)/.deps/goroot" go build $(GOFLAGS) -o $@
-remaster: export CC := x86_64-w64-mingw32-gcc
remaster: export GOARCH := amd64
remaster: export GOPROXY := direct
remaster:
@@ -69,13 +63,11 @@ remaster:
cp go.mod.master go.mod
go get -d
-fmt: export CC := x86_64-w64-mingw32-gcc
fmt: export GOARCH := amd64
fmt:
go fmt ./...
generate: export GOOS :=
-generate: export CGO_ENABLED := 0
generate:
go generate ./...
diff --git a/build.bat b/build.bat
index 1a79b79b..d43b0507 100644
--- a/build.bat
+++ b/build.bat
@@ -38,6 +38,7 @@ if exist .deps\prepared goto :render
set WIREGUARD_VERSION=%WIREGUARD_VERSION:"=%
for /f "tokens=1-4" %%a in ("%WIREGUARD_VERSION:.= % 0 0 0") do set WIREGUARD_VERSION_ARRAY=%%a,%%b,%%c,%%d
set GOOS=windows
+ set GOARM=7
set GOPATH=%BUILDDIR%.deps\gopath
set GOROOT=%BUILDDIR%.deps\go
set PATH=%BUILDDIR%.deps\llvm-mingw\bin;%PATH%
@@ -45,12 +46,8 @@ if exist .deps\prepared goto :render
echo [+] Regenerating files
go generate ./... || exit /b 1
)
- set CGO_ENABLED=1
- set CGO_CFLAGS=-O3 -Wall -Wno-unused-function -Wno-switch -std=gnu11 -DWINVER=0x0601
call :build_plat x86 i686 386 || goto :error
call :build_plat amd64 x86_64 amd64 || goto :error
- set CGO_ENABLED=0
- set GOARM=7
call :build_plat arm armv7 arm || goto :error
:sign
@@ -76,17 +73,16 @@ if exist .deps\prepared goto :render
goto :eof
:build_plat
- set CC=%~2-w64-mingw32-gcc
set GOARCH=%~3
mkdir %1 >NUL 2>&1
echo [+] Assembling resources %1
%~2-w64-mingw32-windres -I ".deps\wintun\bin\%~1" -DWIREGUARD_VERSION_ARRAY=%WIREGUARD_VERSION_ARRAY% -DWIREGUARD_VERSION_STR=%WIREGUARD_VERSION% -i resources.rc -o "resources_%~3.syso" -O coff || exit /b %errorlevel%
echo [+] Building program %1
- go build -ldflags="-H windowsgui -s -w" -tags walk_use_cgo -trimpath -v -o "%~1\wireguard.exe" || exit /b 1
+ go build -ldflags="-H windowsgui -s -w" -trimpath -v -o "%~1\wireguard.exe" || exit /b 1
if not exist "%~1\wg.exe" (
echo [+] Building command line tools %1
del .deps\src\*.exe .deps\src\*.o .deps\src\wincompat\*.o 2> NUL
- make --no-print-directory -C .deps\src PLATFORM=windows CC=%CC% V=1 LDFLAGS=-s RUNSTATEDIR= SYSTEMDUNITDIR= -j%NUMBER_OF_PROCESSORS% || exit /b 1
+ make --no-print-directory -C .deps\src PLATFORM=windows CC=%~2-w64-mingw32-gcc V=1 LDFLAGS=-s RUNSTATEDIR= SYSTEMDUNITDIR= -j%NUMBER_OF_PROCESSORS% || exit /b 1
move /Y .deps\src\wg.exe "%~1\wg.exe" > NUL || exit /b 1
)
goto :eof
diff --git a/gotext.go b/gotext.go
index d61ce393..43af872f 100644
--- a/gotext.go
+++ b/gotext.go
@@ -65,7 +65,7 @@ func main() {
panic(err)
}
cmd = exec.Command(gotextFilename, "-srclang=en", "update", "-out=zgotext.go", "-lang="+strings.Join(langs, ","))
- cmd.Env = append(os.Environ(), "GOOS=windows", "GOARCH=amd64", "CGO_ENABLED=1", "CC=x86_64-w64-mingw32-gcc")
+ cmd.Env = append(os.Environ(), "GOOS=windows", "GOARCH=amd64")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
diff --git a/installer/build.bat b/installer/build.bat
index ef73d147..c4b49fdb 100644
--- a/installer/build.bat
+++ b/installer/build.bat
@@ -35,7 +35,6 @@ if exist .deps\prepared goto :build
set LDFLAGS=-shared -s -Wl,--kill-at -Wl,--major-os-version=6 -Wl,--minor-os-version=1 -Wl,--major-subsystem-version=6 -Wl,--minor-subsystem-version=1 -Wl,--tsaware -Wl,--dynamicbase -Wl,--nxcompat -Wl,--export-all-symbols
set LDLIBS=-lmsi -lole32 -lshlwapi -lshell32 -luuid
call :msi x86 i686 x86 || goto :error
- set CGO_LDFLAGS=%CGO_LDFLAGS% -Wl,--high-entropy-va
call :msi amd64 x86_64 x64 || goto :error
if exist ..\sign.bat call ..\sign.bat
if "%SigningCertificate%"=="" goto :success