Skip to content

Commit 8510a09

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 673441e commit 8510a09

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

loader/goroot.go

Lines changed: 20 additions & 8 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,9 +225,20 @@ 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{
232243
"": true,
233244
"crypto/": true,
@@ -264,15 +275,16 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
264275
paths["crypto/internal/boring/sig/"] = false
265276
}
266277

267-
if needsSyscallPackage {
278+
if needsSyscallPackage(buildTags) {
268279
paths["syscall/"] = true // include syscall/js
269280
}
270281

271-
// to enable network support for linux systems, reuse the Go version of the net package
272-
// and the according runtime functions
273-
// if runtime.GOOS == "linux" {
274-
// paths["runtime/netpoll/"] = true
275-
// }
282+
if linuxNetworking(buildTags) {
283+
for _, v := range []string{"crypto/tls/", "net/http/", "net/"} {
284+
delete(paths, v) // remote entries so go stdlib is used
285+
}
286+
}
287+
276288
return paths
277289
}
278290

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)