aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--build.bat6
-rw-r--r--go-patches/0001-runtime-allow-builtin-write-function-to-be-redirecte.patch59
3 files changed, 69 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 1bd3517f..9881b9cb 100644
--- a/Makefile
+++ b/Makefile
@@ -25,13 +25,15 @@ define download =
if ! mv $$@.unverified $$@; then rm -f $$@.unverified; exit 1; fi
endef
-$(eval $(call download,go.tar.zst,https://download.wireguard.com/windows-toolchain/distfiles/go1.17beta1-linux_amd64_2021-06-11.tar.zst,fc25a3eccfdd1ad42b2963c7736f4fdb9b0e995aca3ecae88a6114da07aff2ec))
+$(eval $(call download,go.tar.gz,https://golang.org/dl/go1.17rc1.linux-amd64.tar.gz,bfbd3881a01ca3826777b1c40f241acacd45b14730d373259cd673d74e15e534))
$(eval $(call download,wintun.zip,https://www.wintun.net/builds/wintun-0.12.zip,eba90e26686ed86595ae0a6d4d3f4f022924b1758f5148a32a91c60cc6e604df))
-.deps/go/prepared: .distfiles/go.tar.zst
+.deps/go/prepared: .distfiles/go.tar.gz $(wildcard go-patches/*.patch)
mkdir -p .deps
rm -rf .deps/go
- bsdtar -C .deps -xf .distfiles/go.tar.zst
+ bsdtar -C .deps -xf .distfiles/go.tar.gz
+ chmod -R +w .deps/go
+ cat $(filter %.patch,$^) | patch -f -N -r- -p1 -d .deps/go
touch $@
.deps/wintun/prepared: .distfiles/wintun.zip
diff --git a/build.bat b/build.bat
index 6dd91254..c3911d7f 100644
--- a/build.bat
+++ b/build.bat
@@ -13,7 +13,7 @@ if exist .deps\prepared goto :render
rmdir /s /q .deps 2> NUL
mkdir .deps || goto :error
cd .deps || goto :error
- call :download go.zip https://download.wireguard.com/windows-toolchain/distfiles/go1.17beta1-windows_amd64_2021-06-11.zip 09601956a35ee4c2fa199da301c4b210fd365a46d286a7160388a1cdc07b7a6d || goto :error
+ call :download go.zip https://golang.org/dl/go1.17rc1.windows-amd64.zip 9f5303e420fdaf4ddea09a627726dec55914e151be473f7d206247f93732a976 || goto :error
rem Mirror of https://github.com/mstorsjo/llvm-mingw/releases/download/20201020/llvm-mingw-20201020-msvcrt-x86_64.zip
call :download llvm-mingw-msvcrt.zip https://download.wireguard.com/windows-toolchain/distfiles/llvm-mingw-20201020-msvcrt-x86_64.zip 2e46593245090df96d15e360e092f0b62b97e93866e0162dca7f93b16722b844 || goto :error
rem Mirror of https://imagemagick.org/download/binaries/ImageMagick-7.0.8-42-portable-Q16-x64.zip
@@ -21,7 +21,11 @@ if exist .deps\prepared goto :render
rem Mirror of https://sourceforge.net/projects/ezwinports/files/make-4.2.1-without-guile-w32-bin.zip
call :download make.zip https://download.wireguard.com/windows-toolchain/distfiles/make-4.2.1-without-guile-w32-bin.zip 30641be9602712be76212b99df7209f4f8f518ba764cf564262bc9d6e4047cc7 "--strip-components 1 bin" || goto :error
call :download wireguard-tools.zip https://git.zx2c4.com/wireguard-tools/snapshot/wireguard-tools-542b7c0f2474fca14e18c23148790f76728dd46a.zip 10ac31af150220850c82b7ed7b65a0e39b60557ed366fcb351da0e0ff2700aea "--exclude wg-quick --strip-components 1" || goto :error
+ rem Mirror of https://sourceforge.net/projects/gnuwin32/files/patch/2.5.9-7/patch-2.5.9-7-bin.zip with fixed manifest
+ call :download patch.zip https://download.wireguard.com/windows-toolchain/distfiles/patch-2.5.9-7-bin-fixed-manifest.zip 25977006ca9713f2662a5d0a2ed3a5a138225b8be3757035bd7da9dcf985d0a1 "--strip-components 1 bin" || goto :error
call :download wintun.zip https://www.wintun.net/builds/wintun-0.12.zip eba90e26686ed86595ae0a6d4d3f4f022924b1758f5148a32a91c60cc6e604df || goto :error
+ echo [+] Patching go
+ for %%a in ("..\go-patches\*.patch") do .\patch.exe -f -N -r- -d go -p1 --binary < "%%a" || goto :error
copy /y NUL prepared > NUL || goto :error
cd .. || goto :error
diff --git a/go-patches/0001-runtime-allow-builtin-write-function-to-be-redirecte.patch b/go-patches/0001-runtime-allow-builtin-write-function-to-be-redirecte.patch
new file mode 100644
index 00000000..d6a1ac65
--- /dev/null
+++ b/go-patches/0001-runtime-allow-builtin-write-function-to-be-redirecte.patch
@@ -0,0 +1,59 @@
+From 1c566ea2420f0503c8494e361bccb943d83c135c Mon Sep 17 00:00:00 2001
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Date: Thu, 3 Dec 2020 13:29:58 +0100
+Subject: [PATCH] runtime: allow builtin write function to be redirected with
+ function pointer
+
+The x/sys/windows package currently uses go:linkname for other facilities
+inside of runtime that are not suitable to be exposed as a public API
+due to their dangers but are still necessary for manipulating any
+low-level plumbing that the runtime controls.
+
+Logging, via the built-in println and panic handler, is one such
+low-level plumbing feature. In this case, x/sys/windows/svc needs to be
+able to redirect panics to the Windows event log. Because the event log
+is a complicated interface, this requires a bit more fiddling than the
+simple solution used on Android (baking it into runtime itself), and
+because Windows services are very diverse, the event log might not even
+always be a desirable destination.
+
+This commit accomplishes this by exposing a function pointer called
+"overrideWrite" that low-level runtime packages like x/sys/windows/svc
+can use to redirect output logs toward the event log or otherwise.
+
+It is not safe or acceptable to use as a generic mechanism, and for that
+reason, we wouldn't want to expose this as a real stable API, similar to
+the other instances of go:linkname in x/sys/windows. But for packages
+that must interoperate with low-level Go runtime fundamentals, this is a
+safety hatch for packages that are developed in tandem with the runtime.
+x/sys/windows is one such package.
+
+Updates #42888.
+
+Change-Id: I77a32ff7e1494324e8cc38e792e007f86d32672d
+---
+ src/runtime/time_nofake.go | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/runtime/time_nofake.go b/src/runtime/time_nofake.go
+index 5a4ceaf43d..68c01805a5 100644
+--- a/src/runtime/time_nofake.go
++++ b/src/runtime/time_nofake.go
+@@ -20,9 +20,14 @@ func nanotime() int64 {
+ return nanotime1()
+ }
+
++var overrideWrite func(fd uintptr, p unsafe.Pointer, n int32) int32
++
+ // write must be nosplit on Windows (see write1)
+ //
+ //go:nosplit
+ func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
++ if overrideWrite != nil {
++ return overrideWrite(fd, noescape(p), n)
++ }
+ return write1(fd, p, n)
+ }
+--
+2.32.0
+