misc/wasm: move wasm runtime files to lib/wasm

Fixes #68024

Change-Id: I730c3ecfb14472f3eea3895c2a4d5e1d4ac146f5
GitHub-Last-Rev: 4242f36010
GitHub-Pull-Request: golang/go#68840
Reviewed-on: https://go-review.googlesource.com/c/go/+/604696
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Zxilly 2024-08-24 08:39:47 +00:00 committed by Gopher Robot
parent 4f327f271d
commit 6781ff226d
56 changed files with 74 additions and 8 deletions

View File

@ -1,2 +1,5 @@
## Ports {#ports} ## Ports {#ports}
### WebAssembly {#wasm}
The support files for WebAssembly have been moved to `lib/wasm` from `misc/wasm`.

View File

@ -17,7 +17,7 @@ license that can be found in the LICENSE file.
<script src="https://cdn.jsdelivr.net/npm/text-encoding@0.7.0/lib/encoding.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/text-encoding@0.7.0/lib/encoding.min.js"></script>
(see https://caniuse.com/#feat=textencoder) (see https://caniuse.com/#feat=textencoder)
--> -->
<script src="wasm_exec.js"></script> <script src="../../lib/wasm/wasm_exec.js"></script>
<script> <script>
if (!WebAssembly.instantiateStreaming) { // polyfill if (!WebAssembly.instantiateStreaming) { // polyfill
WebAssembly.instantiateStreaming = async (resp, importObject) => { WebAssembly.instantiateStreaming = async (resp, importObject) => {

View File

@ -73,6 +73,11 @@ var modRules = []testRule{
{name: "golang.org/toolchain@*/src/cmd/go/main.go"}, {name: "golang.org/toolchain@*/src/cmd/go/main.go"},
{name: "golang.org/toolchain@*/src/bytes/bytes.go"}, {name: "golang.org/toolchain@*/src/bytes/bytes.go"},
{name: "golang.org/toolchain@*/lib/wasm/go_js_wasm_exec"},
{name: "golang.org/toolchain@*/lib/wasm/go_wasip1_wasm_exec"},
{name: "golang.org/toolchain@*/lib/wasm/wasm_exec.js"},
{name: "golang.org/toolchain@*/lib/wasm/wasm_exec_node.js"},
{name: "**/.DS_Store", exclude: true}, {name: "**/.DS_Store", exclude: true},
{name: "golang.org/toolchain@*/.git", exclude: true}, {name: "golang.org/toolchain@*/.git", exclude: true},
{name: "golang.org/toolchain@*/.gitattributes", exclude: true}, {name: "golang.org/toolchain@*/.gitattributes", exclude: true},

View File

@ -353,13 +353,20 @@ func Exec(gotoolchain string) {
base.Fatalf("download %s: %v", gotoolchain, err) base.Fatalf("download %s: %v", gotoolchain, err)
} }
if info.Mode()&0111 == 0 { if info.Mode()&0111 == 0 {
// allowExec sets the exec permission bits on all files found in dir. // allowExec sets the exec permission bits on all files found in dir if pattern is the empty string,
allowExec := func(dir string) { // or only those files that match the pattern if it's non-empty.
allowExec := func(dir, pattern string) {
err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
if err != nil { if err != nil {
return err return err
} }
if !d.IsDir() { if !d.IsDir() {
if pattern != "" {
if matched, _ := filepath.Match(pattern, d.Name()); !matched {
// Skip file.
return nil
}
}
info, err := os.Stat(path) info, err := os.Stat(path)
if err != nil { if err != nil {
return err return err
@ -380,12 +387,13 @@ func Exec(gotoolchain string) {
// then the check of bin/go above might succeed, the other go command // then the check of bin/go above might succeed, the other go command
// would skip its own mode-setting, and then the go command might // would skip its own mode-setting, and then the go command might
// try to run a tool before we get to setting the bits on pkg/tool. // try to run a tool before we get to setting the bits on pkg/tool.
// Setting pkg/tool before bin/go avoids that ordering problem. // Setting pkg/tool and lib before bin/go avoids that ordering problem.
// The only other tool the go command invokes is gofmt, // The only other tool the go command invokes is gofmt,
// so we set that one explicitly before handling bin (which will include bin/go). // so we set that one explicitly before handling bin (which will include bin/go).
allowExec(filepath.Join(dir, "pkg/tool")) allowExec(filepath.Join(dir, "pkg/tool"), "")
allowExec(filepath.Join(dir, "bin/gofmt")) allowExec(filepath.Join(dir, "lib"), "go_?*_?*_exec")
allowExec(filepath.Join(dir, "bin")) allowExec(filepath.Join(dir, "bin/gofmt"), "")
allowExec(filepath.Join(dir, "bin"), "")
} }
} }

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -12,3 +12,4 @@ echo go1.999testmod here!
-- bin/gofmt -- -- bin/gofmt --
echo i am unused echo i am unused
-- pkg/tool/fake -- -- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -8,3 +8,5 @@ module golang.org/toolchain
module golang.org/toolchain module golang.org/toolchain
-- bin/go.bat -- -- bin/go.bat --
@echo go1.999testmod here! @echo go1.999testmod here!
-- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -8,3 +8,5 @@ module golang.org/toolchain
module golang.org/toolchain module golang.org/toolchain
-- bin/go.bat -- -- bin/go.bat --
@echo go1.999testmod here! @echo go1.999testmod here!
-- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -8,3 +8,5 @@ module golang.org/toolchain
module golang.org/toolchain module golang.org/toolchain
-- bin/go.bat -- -- bin/go.bat --
@echo go1.999testmod here! @echo go1.999testmod here!
-- pkg/tool/fake --
-- lib/wasm/go_js_wasm_exec --

View File

@ -8,3 +8,4 @@ module golang.org/toolchain
module golang.org/toolchain module golang.org/toolchain
-- bin/go.bat -- -- bin/go.bat --
@echo go1.999testmod here! @echo go1.999testmod here!
-- lib/wasm/go_js_wasm_exec --

View File

@ -7,7 +7,7 @@
// To run these tests: // To run these tests:
// //
// - Install Node // - Install Node
// - Add /path/to/go/misc/wasm to your $PATH (so that "go test" can find // - Add /path/to/go/lib/wasm to your $PATH (so that "go test" can find
// "go_js_wasm_exec"). // "go_js_wasm_exec").
// - GOOS=js GOARCH=wasm go test // - GOOS=js GOARCH=wasm go test
// //