Skip to content

Commit c82aed1

Browse files
Add patch for RemoveAll change in Go 1.25
reference: https://github.com/thongtech/go-legacy-win7/blob/main/patches/0006-Use-removeall_noat-variant-on-Windows.patch May refactor this patch in Go 1.26
1 parent c40eab9 commit c82aed1

File tree

6 files changed

+140
-2
lines changed

6 files changed

+140
-2
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
- name: Apply patch
4747
run: |
4848
curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/raw/refs/heads/build/unified-1-25-patch.diff | patch --verbose -p 1
49+
# curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/commit/0731a1bffeb285ee576629452e095bf833862b9b.diff | patch --verbose -p 1
4950
# curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/commit/830f1acfc984be44520621b001096845ebf40c7a.diff | patch --verbose -p 1
5051
# curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/commit/b5e4a6d5b3d0b076414d04cc3d6002f816bc0c25.diff | patch --verbose -p 1
5152
# curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/commit/949393bde276adbeaf41688f086feb23e24abe88.diff | patch --verbose -p 1

.github/workflows/test-go1_25.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
- name: Apply patch
5353
run: |
5454
curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/raw/refs/heads/build/unified-1-25-patch.diff | patch --verbose -p 1
55+
# curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/commit/0731a1bffeb285ee576629452e095bf833862b9b.diff | patch --verbose -p 1
5556
# curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/commit/830f1acfc984be44520621b001096845ebf40c7a.diff | patch --verbose -p 1
5657
# curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/commit/b5e4a6d5b3d0b076414d04cc3d6002f816bc0c25.diff | patch --verbose -p 1
5758
# curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/commit/949393bde276adbeaf41688f086feb23e24abe88.diff | patch --verbose -p 1

LOG-RRB

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Go 1.21
2+
2023-01-25 https://github.com/golang/go/commit/cc82867f6bf650e6b48a6e87849e4fdd5b94ef70 runtime/race: update race_windows_amd64.syso [effected] [not main function] [wontfix]
3+
2023-01-31 https://github.com/golang/go/commit/a17d959debdb04cd550016a3501dd09d50cd62e7 runtime: always use LoadLibraryEx to load system libraries [effected]
4+
5+
Go 1.22
6+
2023-07-20 https://github.com/golang/go/commit/7c1157f9544922e96945196b47b95664b1e39108 net: remove sysSocket fallback for Windows 7 [effected]
7+
2023-07-26 https://github.com/golang/go/commit/f0894a00f4b756d4b9b4078af2e686b359493583 os: remove 5ms sleep on Windows in (*Process).Wait [minor]
8+
2023-09-27 https://github.com/golang/go/commit/48042aa09c2f878c4faa576948b07fe625c4707a syscall: remove Windows 7 console handle workaround [effected]
9+
2023-10-20 https://github.com/golang/go/commit/693def151adff1af707d82d28f55dba81ceb08e1 crypto/rand,runtime: switch RtlGenRandom for ProcessPrng [critical]
10+
11+
Go 1.24
12+
2024-10-07 https://github.com/golang/go/commit/534d6a1a9c81b25bdad1052e736b2f072caa3903 crypto/rand: prevent Read argument from escaping to heap [related 693def151adff1af707d82d28f55dba81ceb08e1] [minor]
13+
14+
Go 1.25
15+
2025-03-31 https://github.com/golang/go/commit/6d418096b2dfe2a2e47b7aa83b46748fb301e6cb os: avoid symlink races in RemoveAll on Windows [effected]
16+
2025-05-21 https://github.com/golang/go/commit/896097000912761dbd31cead2bec99f17534f521 os: add Root.RemoveAll [related 6d418096b2dfe2a2e47b7aa83b46748fb301e6cb] [effected]

README-eng.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Currently found these changes in Go SDK will stop running Windows 7:
1515
- `48042aa09c2f878c4faa576948b07fe625c4707a` (`syscall: remove Windows 7 console handle workaround`)
1616
- `693def151adff1af707d82d28f55dba81ceb08e1` (`crypto/rand,runtime: switch RtlGenRandom for ProcessPrng`)
1717
- `534d6a1a9c81b25bdad1052e736b2f072caa3903` (`crypto/rand: prevent Read argument from escaping to heap`) (breaking previous patch on `crypto/rand,runtime: switch RtlGenRandom for ProcessPrng`)
18+
- `6d418096b2dfe2a2e47b7aa83b46748fb301e6cb` (`os: avoid symlink races in RemoveAll on Windows`)
19+
- `896097000912761dbd31cead2bec99f17534f521` (`os: add Root.RemoveAll`)
1820

1921
### Testing environment
2022

@@ -76,13 +78,14 @@ These patches must be applied from up to down:
7678

7779
### Go 1.25
7880

79-
- Windows 8.1 Update 3 / Windows Server 2012 R2: Can run official distributed Go SDK and binaries built from official SDK.
81+
- Windows 8.1 Update 3 / Windows Server 2012 R2: Can run official distributed Go SDK and binaries built from official SDK, but a problem may occur when removing files.
8082
- Windows 7 SP1 / Windows Server 2008 R2: Require patches in SDK, and binaries must be built with patched SDK.
8183

8284
#### Patches for Windows 7 / Windows Server 2008 R2
8385

8486
These patches must be applied from up to down:
8587

88+
1. https://github.com/XTLS/go-win7/commit/0731a1bffeb285ee576629452e095bf833862b9b / [Git diff](https://github.com/XTLS/go-win7/commit/0731a1bffeb285ee576629452e095bf833862b9b.diff)
8689
1. https://github.com/XTLS/go-win7/commit/830f1acfc984be44520621b001096845ebf40c7a / [Git diff](https://github.com/XTLS/go-win7/commit/830f1acfc984be44520621b001096845ebf40c7a.diff)
8790
1. https://github.com/XTLS/go-win7/commit/b5e4a6d5b3d0b076414d04cc3d6002f816bc0c25 / [Git diff](https://github.com/XTLS/go-win7/commit/b5e4a6d5b3d0b076414d04cc3d6002f816bc0c25.diff)
8891
1. https://github.com/XTLS/go-win7/commit/949393bde276adbeaf41688f086feb23e24abe88 / [Git diff](https://github.com/XTLS/go-win7/commit/949393bde276adbeaf41688f086feb23e24abe88.diff)

README-zho-hans.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
- `48042aa09c2f878c4faa576948b07fe625c4707a` (`syscall: remove Windows 7 console handle workaround`)
1616
- `693def151adff1af707d82d28f55dba81ceb08e1` (`crypto/rand,runtime: switch RtlGenRandom for ProcessPrng`)
1717
- `534d6a1a9c81b25bdad1052e736b2f072caa3903` (`crypto/rand: prevent Read argument from escaping to heap`) (导致应对 `crypto/rand,runtime: switch RtlGenRandom for ProcessPrng` 的补丁故障)
18+
- `6d418096b2dfe2a2e47b7aa83b46748fb301e6cb` (`os: avoid symlink races in RemoveAll on Windows`)
19+
- `896097000912761dbd31cead2bec99f17534f521` (`os: add Root.RemoveAll`)
1820

1921
### 测试环境
2022

@@ -76,13 +78,14 @@
7678

7779
### Go 1.25
7880

79-
- Windows 8.1 Update 3 / Windows Server 2012 R2: 可直接运行官方 Go SDK 及其构建的二进制文件。
81+
- Windows 8.1 Update 3 / Windows Server 2012 R2: 可直接运行官方 Go SDK 及其构建的二进制文件,但是可能会在文件删除操作上出现问题
8082
- Windows 7 SP1 / Windows Server 2008 R2:需要在 SDK 中植入补丁,并且只能运行用修补后的 SDK 构建的二进制。
8183

8284
#### 用于 Windows 7 / Windows Server 2008 R2 的补丁
8385

8486
这些补丁必须按照从上到下的顺序来修补:
8587

88+
1. https://github.com/XTLS/go-win7/commit/0731a1bffeb285ee576629452e095bf833862b9b / [Git diff](https://github.com/XTLS/go-win7/commit/0731a1bffeb285ee576629452e095bf833862b9b.diff)
8689
1. https://github.com/XTLS/go-win7/commit/830f1acfc984be44520621b001096845ebf40c7a / [Git diff](https://github.com/XTLS/go-win7/commit/830f1acfc984be44520621b001096845ebf40c7a.diff)
8790
1. https://github.com/XTLS/go-win7/commit/b5e4a6d5b3d0b076414d04cc3d6002f816bc0c25 / [Git diff](https://github.com/XTLS/go-win7/commit/b5e4a6d5b3d0b076414d04cc3d6002f816bc0c25.diff)
8891
1. https://github.com/XTLS/go-win7/commit/949393bde276adbeaf41688f086feb23e24abe88 / [Git diff](https://github.com/XTLS/go-win7/commit/949393bde276adbeaf41688f086feb23e24abe88.diff)

unified-1-25-patch.diff

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,117 @@
1+
diff --git a/src/os/removeall_at.go b/src/os/removeall_at.go
2+
index 5ddc1ade6134e5..61298a46bc70df 100644
3+
--- a/src/os/removeall_at.go
4+
+++ b/src/os/removeall_at.go
5+
@@ -2,7 +2,7 @@
6+
// Use of this source code is governed by a BSD-style
7+
// license that can be found in the LICENSE file.
8+
9+
-//go:build unix || wasip1 || windows
10+
+//go:build unix || wasip1
11+
12+
package os
13+
14+
diff --git a/src/os/removeall_noat.go b/src/os/removeall_noat.go
15+
index 395a1503d49442..02f6fca70283f7 100644
16+
--- a/src/os/removeall_noat.go
17+
+++ b/src/os/removeall_noat.go
18+
@@ -2,7 +2,7 @@
19+
// Use of this source code is governed by a BSD-style
20+
// license that can be found in the LICENSE file.
21+
22+
-//go:build (js && wasm) || plan9
23+
+//go:build (js && wasm) || plan9 || windows
24+
25+
package os
26+
27+
diff --git a/src/os/root.go b/src/os/root.go
28+
index d759727ce7a89b..1ecbcc094f15b0 100644
29+
--- a/src/os/root.go
30+
+++ b/src/os/root.go
31+
@@ -189,12 +189,6 @@ func (r *Root) Remove(name string) error {
32+
return rootRemove(r, name)
33+
}
34+
35+
-// RemoveAll removes the named file or directory and any children that it contains.
36+
-// See [RemoveAll] for more details.
37+
-func (r *Root) RemoveAll(name string) error {
38+
- return rootRemoveAll(r, name)
39+
-}
40+
-
41+
// Stat returns a [FileInfo] describing the named file in the root.
42+
// See [Stat] for more details.
43+
func (r *Root) Stat(name string) (FileInfo, error) {
44+
diff --git a/src/os/root_noopenat.go b/src/os/root_noopenat.go
45+
index 59f1abe91b0b2e..ecdf264f28d7d6 100644
46+
--- a/src/os/root_noopenat.go
47+
+++ b/src/os/root_noopenat.go
48+
@@ -11,7 +11,6 @@ import (
49+
"internal/filepathlite"
50+
"internal/stringslite"
51+
"sync/atomic"
52+
- "syscall"
53+
"time"
54+
)
55+
56+
@@ -186,25 +185,6 @@ func rootRemove(r *Root, name string) error {
57+
return nil
58+
}
59+
60+
-func rootRemoveAll(r *Root, name string) error {
61+
- if endsWithDot(name) {
62+
- // Consistency with os.RemoveAll: Return EINVAL when trying to remove .
63+
- return &PathError{Op: "RemoveAll", Path: name, Err: syscall.EINVAL}
64+
- }
65+
- if err := checkPathEscapesLstat(r, name); err != nil {
66+
- if err == syscall.ENOTDIR {
67+
- // Some intermediate path component is not a directory.
68+
- // RemoveAll treats this as success (since the target doesn't exist).
69+
- return nil
70+
- }
71+
- return &PathError{Op: "RemoveAll", Path: name, Err: err}
72+
- }
73+
- if err := RemoveAll(joinPath(r.root.name, name)); err != nil {
74+
- return &PathError{Op: "RemoveAll", Path: name, Err: underlyingError(err)}
75+
- }
76+
- return nil
77+
-}
78+
-
79+
func rootReadlink(r *Root, name string) (string, error) {
80+
if err := checkPathEscapesLstat(r, name); err != nil {
81+
return "", &PathError{Op: "readlinkat", Path: name, Err: err}
82+
diff --git a/src/os/root_openat.go b/src/os/root_openat.go
83+
index 192c29e319d394..f5473e75bd6adf 100644
84+
--- a/src/os/root_openat.go
85+
+++ b/src/os/root_openat.go
86+
@@ -197,28 +197,6 @@ func rootRemove(r *Root, name string) error {
87+
return nil
88+
}
89+
90+
-func rootRemoveAll(r *Root, name string) error {
91+
- // Consistency with os.RemoveAll: Strip trailing /s from the name,
92+
- // so RemoveAll("not_a_directory/") succeeds.
93+
- for len(name) > 0 && IsPathSeparator(name[len(name)-1]) {
94+
- name = name[:len(name)-1]
95+
- }
96+
- if endsWithDot(name) {
97+
- // Consistency with os.RemoveAll: Return EINVAL when trying to remove .
98+
- return &PathError{Op: "RemoveAll", Path: name, Err: syscall.EINVAL}
99+
- }
100+
- _, err := doInRoot(r, name, nil, func(parent sysfdType, name string) (struct{}, error) {
101+
- return struct{}{}, removeAllFrom(parent, name)
102+
- })
103+
- if IsNotExist(err) {
104+
- return nil
105+
- }
106+
- if err != nil {
107+
- return &PathError{Op: "RemoveAll", Path: name, Err: underlyingError(err)}
108+
- }
109+
- return err
110+
-}
111+
-
112+
func rootRename(r *Root, oldname, newname string) error {
113+
_, err := doInRoot(r, oldname, nil, func(oldparent sysfdType, oldname string) (struct{}, error) {
114+
_, err := doInRoot(r, newname, nil, func(newparent sysfdType, newname string) (struct{}, error) {
1115
diff --git a/src/crypto/internal/sysrand/rand_windows.go b/src/crypto/internal/sysrand/rand_windows.go
2116
index 91f1490c15cda3..0c9f06787d0fb3 100644
3117
--- a/src/crypto/internal/sysrand/rand_windows.go

0 commit comments

Comments
 (0)