Skip to content

Commit 549bab3

Browse files
committed
fix uncommited net exclusion
if this does not work, do the folliwing steps: 1. remove net submodule 2. remove symlink in local ~/.cache/tinygo/goroot-<hash>/net 3. manual symlink yo local golang /usr/local/bin/src/net Signed-off-by: leongross <leon.gross@9elements.com>
1 parent d5ae016 commit 549bab3

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

loader/goroot.go

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func GetCachedGoroot(config *compileopts.Config) (string, error) {
4545
}
4646

4747
// Find the overrides needed for the goroot.
48-
overrides := pathsToOverride(config.GoMinorVersion, needsSyscallPackage(config.BuildTags()))
48+
overrides := pathsToOverride(config.GoMinorVersion, config.BuildTags())
4949

5050
// Resolve the merge links within the goroot.
5151
merge, err := listGorootMergeLinks(goroot, tinygoroot, overrides)
@@ -225,14 +225,25 @@ func needsSyscallPackage(buildTags []string) bool {
225225
return false
226226
}
227227

228+
// linuxNetworking returns whether the unmodified go linux net stack should be used
229+
// until the full rework of the net package is done.
230+
func linuxNetworking(buildTags []string) bool {
231+
for _, tag := range buildTags {
232+
if tag == "linux" {
233+
return true
234+
}
235+
}
236+
return false
237+
}
238+
228239
// The boolean indicates whether to merge the subdirs. True means merge, false
229240
// means use the TinyGo version.
230-
func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
241+
func pathsToOverride(goMinor int, buildTags []string) map[string]bool {
231242
paths := map[string]bool{
232-
"": true,
233-
"crypto/": true,
234-
"crypto/rand/": false,
235-
// "crypto/tls/": false,
243+
"": true,
244+
"crypto/": true,
245+
"crypto/rand/": false,
246+
"crypto/tls/": false,
236247
"device/": false,
237248
"examples/": false,
238249
"internal/": true,
@@ -246,13 +257,13 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
246257
"internal/wasi/": false,
247258
"machine/": false,
248259
"net/": false,
249-
// "net/http/": false,
250-
"os/": true,
251-
"reflect/": false,
252-
"runtime/": false,
253-
"sync/": true,
254-
"testing/": true,
255-
"unique/": false,
260+
"net/http/": false,
261+
"os/": true,
262+
"reflect/": false,
263+
"runtime/": false,
264+
"sync/": true,
265+
"testing/": true,
266+
"unique/": false,
256267
}
257268

258269
if goMinor >= 19 {
@@ -261,15 +272,16 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
261272
paths["crypto/internal/boring/sig/"] = false
262273
}
263274

264-
if needsSyscallPackage {
275+
if needsSyscallPackage(buildTags) {
265276
paths["syscall/"] = true // include syscall/js
266277
}
267278

268-
// to enable network support for linux systems, reuse the Go version of the net package
269-
// and the according runtime functions
270-
// if runtime.GOOS == "linux" {
271-
// paths["runtime/netpoll/"] = true
272-
// }
279+
if linuxNetworking(buildTags) {
280+
for _, v := range []string{"crypto/tls/", "net/http/", "net/"} {
281+
delete(paths, v) // remote entries so go stdlib is used
282+
}
283+
}
284+
273285
return paths
274286
}
275287

loader/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func (p *Program) getOriginalPath(path string) string {
279279
originalPath = realgorootPath
280280
}
281281
maybeInTinyGoRoot := false
282-
for prefix := range pathsToOverride(p.config.GoMinorVersion, needsSyscallPackage(p.config.BuildTags())) {
282+
for prefix := range pathsToOverride(p.config.GoMinorVersion, p.config.BuildTags()) {
283283
if runtime.GOOS == "windows" {
284284
prefix = strings.ReplaceAll(prefix, "/", "\\")
285285
}

0 commit comments

Comments
 (0)