From 0e21b728dbe18fcfbb4a252fcf79b3c674ecf5ef Mon Sep 17 00:00:00 2001 From: leongross Date: Fri, 4 Oct 2024 16:01:00 +0200 Subject: [PATCH] switch net via build tags Signed-off-by: leongross --- .gitmodules | 3 +++ loader/goroot.go | 19 +++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.gitmodules b/.gitmodules index 2749d21f6a..29778d6709 100644 --- a/.gitmodules +++ b/.gitmodules @@ -35,3 +35,6 @@ [submodule "lib/wasi-cli"] path = lib/wasi-cli url = https://github.com/WebAssembly/wasi-cli +[submodule "src/net"] + path = src/net + url = https://github.com/tinygo-org/net diff --git a/loader/goroot.go b/loader/goroot.go index 36d3602d5a..dcb6c42108 100644 --- a/loader/goroot.go +++ b/loader/goroot.go @@ -236,14 +236,16 @@ func linuxNetworking(buildTags []string) bool { return false } -// The boolean indicates whether to merge the subdirs. True means merge, false -// means use the TinyGo version. +// The boolean indicates whether to merge the subdirs. +// +// True: Merge the golang and tinygo source directories. +// False: Uses the TinyGo version exclusively. func pathsToOverride(goMinor int, buildTags []string) map[string]bool { paths := map[string]bool{ - "": true, + "": true, // root "crypto/": true, "crypto/rand/": false, - "crypto/tls/": false, + "crypto/tls/": false, // necessary for embedded tls "device/": false, "examples/": false, "internal/": true, @@ -256,7 +258,7 @@ func pathsToOverride(goMinor int, buildTags []string) map[string]bool { "internal/task/": false, "internal/wasi/": false, "machine/": false, - "net/": true, // this is important if the GOOS is not linux + "net/": true, // this is important if the GOOS != linux "net/http/": false, "os/": true, "reflect/": false, @@ -276,15 +278,12 @@ func pathsToOverride(goMinor int, buildTags []string) map[string]bool { paths["syscall/"] = true // include syscall/js } + // To make sure the correct version of the net package is used, it is advised + // to clean the go cache before building if linuxNetworking(buildTags) { for _, v := range []string{"crypto/tls/", "net/http/", "net/"} { delete(paths, v) // remove entries so go stdlib is used } - - // ensure that the goroot path does not contain the the tinygo net package - // path - } else { - // if the GOOS!=linux several tls files have to be for tls } return paths