Commit ec7267caa3 for golang

commit ec7267caa3b834d7d3b2cd9887bb193d8dbe514f
Author: Zxilly <zhouxinyu1001@gmail.com>
Date:   Mon Sep 7 20:00:34 2026 +0800

    all: share WebAssembly library implementations with wasm32

    Use the existing WebAssembly library implementations on wasm32. Share
    the memchr helper and math assembly between wasm and wasm32, and apply
    the same recursion limits and platform-specific test exclusions.

    Many _wasm.go files were renamed to _wasmx.go and build-tagged for both.

    Rebased and reviewed and uploaded by drchase@google.com .

    Updates #63131

    Cq-Include-Trybots: luci.golang.try:gotip-darwin-arm64-longtest,gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race,gotip-wasip1-wasm_wazero
    Change-Id: I560d380db5d62f91d5d0844d84c6e4f174474c22
    Reviewed-on: https://go-review.googlesource.com/c/go/+/836655
    TryBot-Bypass: David Chase <drchase@google.com>
    Reviewed-by: Carlos Amedee <carlos@golang.org>

diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 0fdf37f540..f3a3cb5a56 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -1875,8 +1875,10 @@ func raceDetectorSupported(goos, goarch string) bool {
 // internal/platform.FIPS140Supported, which can't be used here
 // because cmd/dist can not import internal packages during bootstrap.
 func fips140Supported(goos, goarch string) bool {
+		// Keep this in sync with internal/platform/supported.go:FIPS140Supported
+		// Keep this in sync with crypto/internal/fips140/fips140.go:supported
 	switch {
-	case goarch == "wasm",
+	case goarch == "wasm", goarch == "wasm32",
 		goos == "windows" && goarch == "386",
 		goos == "openbsd",
 		goos == "aix":
diff --git a/src/context/x_test.go b/src/context/x_test.go
index aeb5470399..780a9d1869 100644
--- a/src/context/x_test.go
+++ b/src/context/x_test.go
@@ -1185,7 +1185,7 @@ func TestContextErrDoneRace(t *testing.T) {
 		donec := ctx.Done()
 		go cancel()
 		for ctx.Err() == nil {
-			if runtime.GOARCH == "wasm" {
+			if runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 				runtime.Gosched() // need to explicitly yield
 			}
 		}
diff --git a/src/crypto/internal/fips140/check/checktest/asm.s b/src/crypto/internal/fips140/check/checktest/asm.s
index cc74e56f98..7a4eedb9df 100644
--- a/src/crypto/internal/fips140/check/checktest/asm.s
+++ b/src/crypto/internal/fips140/check/checktest/asm.s
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build !purego && !wasm
+//go:build !purego && !wasm && !wasm32

 #include "textflag.h"

diff --git a/src/crypto/internal/fips140/fips140.go b/src/crypto/internal/fips140/fips140.go
index 2f981bf7b1..7b639c6266 100644
--- a/src/crypto/internal/fips140/fips140.go
+++ b/src/crypto/internal/fips140/fips140.go
@@ -52,7 +52,9 @@ func Supported() error {
 	// Also, js/wasm and windows/386 don't have good enough timers
 	// for the CPU jitter entropy source.
 	switch {
-	case runtime.GOARCH == "wasm",
+		// Keep this in sync with internal/platform/supported.go:FIPS140Supported
+		// Keep this in sync with cmd/test/test.go:fips140Supported
+	case runtime.GOARCH == "wasm", runtime.GOARCH == "wasm32",
 		runtime.GOOS == "windows" && runtime.GOARCH == "386",
 		runtime.GOOS == "openbsd", // due to -fexecute-only, see #70880
 		runtime.GOOS == "aix":
diff --git a/src/crypto/tls/bogo_shim_notunix_test.go b/src/crypto/tls/bogo_shim_notunix_test.go
index 2dcb5c09df..a1a0d59bed 100644
--- a/src/crypto/tls/bogo_shim_notunix_test.go
+++ b/src/crypto/tls/bogo_shim_notunix_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build !unix || wasm
+//go:build !unix || wasm || wasm32

 package tls

diff --git a/src/crypto/tls/bogo_shim_unix_test.go b/src/crypto/tls/bogo_shim_unix_test.go
index 3b5f5f92c2..2dad6bf675 100644
--- a/src/crypto/tls/bogo_shim_unix_test.go
+++ b/src/crypto/tls/bogo_shim_unix_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build unix && !wasm
+//go:build unix && !wasm && !wasm32

 package tls

diff --git a/src/crypto/x509/root_wasm.go b/src/crypto/x509/root_wasmx.go
similarity index 93%
rename from src/crypto/x509/root_wasm.go
rename to src/crypto/x509/root_wasmx.go
index 275c9213d9..eb6097626c 100644
--- a/src/crypto/x509/root_wasm.go
+++ b/src/crypto/x509/root_wasmx.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build wasm
+//go:build wasm || wasm32

 package x509

diff --git a/src/encoding/asn1/asn1.go b/src/encoding/asn1/asn1.go
index 4e65924c0f..1e5e9fd00c 100644
--- a/src/encoding/asn1/asn1.go
+++ b/src/encoding/asn1/asn1.go
@@ -713,7 +713,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
 		maxDecodeDepth     = 10000
 		maxDecodeDepthWasm = 5000 // go.dev/issue/56498
 	)
-	if depth > maxDecodeDepth || runtime.GOARCH == "wasm" && depth > maxDecodeDepthWasm {
+	if depth > maxDecodeDepth || (runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32") && depth > maxDecodeDepthWasm {
 		return initOffset, StructuralError{"nesting depth exceeded"}
 	}
 	offset = initOffset
diff --git a/src/encoding/asn1/asn1_test.go b/src/encoding/asn1/asn1_test.go
index 1aaab0eb9f..f9dcde1d48 100644
--- a/src/encoding/asn1/asn1_test.go
+++ b/src/encoding/asn1/asn1_test.go
@@ -1259,7 +1259,7 @@ func TestUnmarshalNestingLimitSlice(t *testing.T) {
 	type Recursive []Recursive

 	limit := 10000
-	if runtime.GOARCH == "wasm" {
+	if runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 		limit = 5000
 	}

@@ -1305,7 +1305,7 @@ func TestUnmarshalNestingLimitStruct(t *testing.T) {
 	}

 	limit := 5000
-	if runtime.GOARCH == "wasm" {
+	if runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 		limit = 2500
 	}

diff --git a/src/encoding/binary/native_endian_little.go b/src/encoding/binary/native_endian_little.go
index 38d3e9b695..c53b728b47 100644
--- a/src/encoding/binary/native_endian_little.go
+++ b/src/encoding/binary/native_endian_little.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm
+//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm || wasm32

 package binary

diff --git a/src/encoding/xml/read.go b/src/encoding/xml/read.go
index bb2302d461..0ac25a4785 100644
--- a/src/encoding/xml/read.go
+++ b/src/encoding/xml/read.go
@@ -324,7 +324,7 @@ var errUnmarshalDepth = errors.New("exceeded max depth")

 // Unmarshal a single XML element into val.
 func (d *Decoder) unmarshal(val reflect.Value, start *StartElement) error {
-	if d.stkDepth > maxUnmarshalDepth || runtime.GOARCH == "wasm" && d.stkDepth > maxUnmarshalDepthWasm {
+	if d.stkDepth > maxUnmarshalDepth || (runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32") && d.stkDepth > maxUnmarshalDepthWasm {
 		return errUnmarshalDepth
 	}
 	// Find start element if we need it.
diff --git a/src/encoding/xml/read_test.go b/src/encoding/xml/read_test.go
index 0a5bd58b7f..646e3d3062 100644
--- a/src/encoding/xml/read_test.go
+++ b/src/encoding/xml/read_test.go
@@ -1113,7 +1113,7 @@ func TestCVE202228131(t *testing.T) {
 }

 func TestCVE202230633(t *testing.T) {
-	if testing.Short() || runtime.GOARCH == "wasm" {
+	if testing.Short() || runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 		t.Skip("test requires significant memory")
 	}
 	defer func() {
@@ -1151,7 +1151,7 @@ func TestDecodeElementRecursion(t *testing.T) {
 		t.Skip("test requires significant memory")
 	}
 	maxDepth := maxUnmarshalDepth
-	if runtime.GOARCH == "wasm" {
+	if runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 		maxDepth = maxUnmarshalDepthWasm
 	}
 	tests := []struct {
diff --git a/src/hash/maphash/smhasher_test.go b/src/hash/maphash/smhasher_test.go
index 86ff7c2cdb..6058b2c411 100644
--- a/src/hash/maphash/smhasher_test.go
+++ b/src/hash/maphash/smhasher_test.go
@@ -169,8 +169,8 @@ func TestSmhasherZeros(t *testing.T) {

 // Strings with up to two nonzero bytes all have distinct hashes.
 func TestSmhasherTwoNonzero(t *testing.T) {
-	if runtime.GOARCH == "wasm" {
-		t.Skip("Too slow on wasm")
+	if a := runtime.GOARCH; a == "wasm" || a == "wasm32" {
+		t.Skipf("Too slow on %s", a)
 	}
 	if testing.Short() {
 		t.Skip("Skipping in short mode")
@@ -242,8 +242,8 @@ func TestSmhasherCyclic(t *testing.T) {

 // Test strings with only a few bits set
 func TestSmhasherSparse(t *testing.T) {
-	if runtime.GOARCH == "wasm" {
-		t.Skip("Too slow on wasm")
+	if a := runtime.GOARCH; a == "wasm" || a == "wasm32" {
+		t.Skipf("Too slow on %s", a)
 	}
 	if testing.Short() {
 		t.Skip("Skipping in short mode")
@@ -282,8 +282,8 @@ func setbits(h *hashSet, b []byte, i int, k int) {
 // Test all possible combinations of n blocks from the set s.
 // "permutation" is a bad name here, but it is what Smhasher uses.
 func TestSmhasherPermutation(t *testing.T) {
-	if runtime.GOARCH == "wasm" {
-		t.Skip("Too slow on wasm")
+	if a := runtime.GOARCH; a == "wasm" || a == "wasm32" {
+		t.Skipf("Too slow on %s", a)
 	}
 	if testing.Short() {
 		t.Skip("Skipping in short mode")
@@ -350,8 +350,8 @@ func (k *bytesKey) name() string {

 // Flipping a single bit of a key should flip each output bit with 50% probability.
 func TestSmhasherAvalanche(t *testing.T) {
-	if runtime.GOARCH == "wasm" {
-		t.Skip("Too slow on wasm")
+	if a := runtime.GOARCH; a == "wasm" || a == "wasm32" {
+		t.Skipf("Too slow on %s", a)
 	}
 	if testing.Short() {
 		t.Skip("Skipping in short mode")
@@ -425,8 +425,8 @@ func TestSmhasherWindowed(t *testing.T) {
 	windowed(t, &bytesKey{make([]byte, 128)})
 }
 func windowed(t *testing.T, k key) {
-	if runtime.GOARCH == "wasm" {
-		t.Skip("Too slow on wasm")
+	if a := runtime.GOARCH; a == "wasm" || a == "wasm32" {
+		t.Skipf("Too slow on %s", a)
 	}
 	if testing.Short() {
 		t.Skip("Skipping in short mode")
diff --git a/src/internal/bytealg/indexbyte_wasm.s b/src/internal/bytealg/indexbyte_wasm.s
index d22e90448d..280c96df05 100644
--- a/src/internal/bytealg/indexbyte_wasm.s
+++ b/src/internal/bytealg/indexbyte_wasm.s
@@ -49,147 +49,4 @@ TEXT ·IndexByteString(SB), NOSPLIT, $0-32

 	RET

-// initially compiled with emscripten and then modified over time.
-// params:
-//   R0: s
-//   R1: c
-//   R2: len
-// ret: index
-TEXT memchr<>(SB), NOSPLIT, $0
-	Get R1
-	Set R4
-	Block
-		Block
-			Get R2
-			I32Const $0
-			I32Ne
-			Tee R3
-			Get R0
-			I32Const $3
-			I32And
-			I32Const $0
-			I32Ne
-			I32And
-			If
-				Loop
-					Get R0
-					I32Load8U $0
-					Get R1
-					I32Eq
-					BrIf $2
-					Get R2
-					I32Const $-1
-					I32Add
-					Tee R2
-					I32Const $0
-					I32Ne
-					Tee R3
-					Get R0
-					I32Const $1
-					I32Add
-					Tee R0
-					I32Const $3
-					I32And
-					I32Const $0
-					I32Ne
-					I32And
-					BrIf $0
-				End
-			End
-			Get R3
-			BrIf $0
-			I32Const $0
-			Set R1
-			Br $1
-		End
-		Get R0
-		I32Load8U $0
-		Get R4
-		Tee R3
-		I32Eq
-		If
-			Get R2
-			Set R1
-		Else
-			Get R4
-			I32Const $16843009
-			I32Mul
-			Set R4
-			Block
-				Block
-					Get R2
-					I32Const $3
-					I32GtU
-					If
-						Get R2
-						Set R1
-						Loop
-							Get R0
-							I32Load $0
-							Get R4
-							I32Xor
-							Tee R2
-							I32Const $-2139062144
-							I32And
-							I32Const $-2139062144
-							I32Xor
-							Get R2
-							I32Const $-16843009
-							I32Add
-							I32And
-							I32Eqz
-							If
-								Get R0
-								I32Const $4
-								I32Add
-								Set R0
-								Get R1
-								I32Const $-4
-								I32Add
-								Tee R1
-								I32Const $3
-								I32GtU
-								BrIf $1
-								Br $3
-							End
-						End
-					Else
-						Get R2
-						Set R1
-						Br $1
-					End
-					Br $1
-				End
-				Get R1
-				I32Eqz
-				If
-					I32Const $0
-					Set R1
-					Br $3
-				End
-			End
-			Loop
-				Get R0
-				I32Load8U $0
-				Get R3
-				I32Eq
-				BrIf $2
-				Get R0
-				I32Const $1
-				I32Add
-				Set R0
-				Get R1
-				I32Const $-1
-				I32Add
-				Tee R1
-				BrIf $0
-				I32Const $0
-				Set R1
-			End
-		End
-	End
-	Get R0
-	I32Const $0
-	Get R1
-	Select
-	Return
+#include "indexbyte_wasmx.h"
diff --git a/src/internal/bytealg/indexbyte_wasm32.s b/src/internal/bytealg/indexbyte_wasm32.s
index 595835f3a9..76affc2345 100644
--- a/src/internal/bytealg/indexbyte_wasm32.s
+++ b/src/internal/bytealg/indexbyte_wasm32.s
@@ -49,147 +49,4 @@ TEXT ·IndexByteString(SB), NOSPLIT, $0-16

 	RET

-// initially compiled with emscripten and then modified over time.
-// params:
-//   R0: s
-//   R1: c
-//   R2: len
-// ret: index
-TEXT memchr<>(SB), NOSPLIT, $0
-	Get R1
-	Set R4
-	Block
-		Block
-			Get R2
-			I32Const $0
-			I32Ne
-			Tee R3
-			Get R0
-			I32Const $3
-			I32And
-			I32Const $0
-			I32Ne
-			I32And
-			If
-				Loop
-					Get R0
-					I32Load8U $0
-					Get R1
-					I32Eq
-					BrIf $2
-					Get R2
-					I32Const $-1
-					I32Add
-					Tee R2
-					I32Const $0
-					I32Ne
-					Tee R3
-					Get R0
-					I32Const $1
-					I32Add
-					Tee R0
-					I32Const $3
-					I32And
-					I32Const $0
-					I32Ne
-					I32And
-					BrIf $0
-				End
-			End
-			Get R3
-			BrIf $0
-			I32Const $0
-			Set R1
-			Br $1
-		End
-		Get R0
-		I32Load8U $0
-		Get R4
-		Tee R3
-		I32Eq
-		If
-			Get R2
-			Set R1
-		Else
-			Get R4
-			I32Const $16843009
-			I32Mul
-			Set R4
-			Block
-				Block
-					Get R2
-					I32Const $3
-					I32GtU
-					If
-						Get R2
-						Set R1
-						Loop
-							Get R0
-							I32Load $0
-							Get R4
-							I32Xor
-							Tee R2
-							I32Const $-2139062144
-							I32And
-							I32Const $-2139062144
-							I32Xor
-							Get R2
-							I32Const $-16843009
-							I32Add
-							I32And
-							I32Eqz
-							If
-								Get R0
-								I32Const $4
-								I32Add
-								Set R0
-								Get R1
-								I32Const $-4
-								I32Add
-								Tee R1
-								I32Const $3
-								I32GtU
-								BrIf $1
-								Br $3
-							End
-						End
-					Else
-						Get R2
-						Set R1
-						Br $1
-					End
-					Br $1
-				End
-				Get R1
-				I32Eqz
-				If
-					I32Const $0
-					Set R1
-					Br $3
-				End
-			End
-			Loop
-				Get R0
-				I32Load8U $0
-				Get R3
-				I32Eq
-				BrIf $2
-				Get R0
-				I32Const $1
-				I32Add
-				Set R0
-				Get R1
-				I32Const $-1
-				I32Add
-				Tee R1
-				BrIf $0
-				I32Const $0
-				Set R1
-			End
-		End
-	End
-	Get R0
-	I32Const $0
-	Get R1
-	Select
-	Return
+#include "indexbyte_wasmx.h"
diff --git a/src/internal/bytealg/indexbyte_wasmx.h b/src/internal/bytealg/indexbyte_wasmx.h
new file mode 100644
index 0000000000..d75c0cf00c
--- /dev/null
+++ b/src/internal/bytealg/indexbyte_wasmx.h
@@ -0,0 +1,148 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// initially compiled with emscripten and then modified over time.
+// params:
+//   R0: s
+//   R1: c
+//   R2: len
+// ret: index
+TEXT memchr<>(SB), NOSPLIT, $0
+	Get R1
+	Set R4
+	Block
+		Block
+			Get R2
+			I32Const $0
+			I32Ne
+			Tee R3
+			Get R0
+			I32Const $3
+			I32And
+			I32Const $0
+			I32Ne
+			I32And
+			If
+				Loop
+					Get R0
+					I32Load8U $0
+					Get R1
+					I32Eq
+					BrIf $2
+					Get R2
+					I32Const $-1
+					I32Add
+					Tee R2
+					I32Const $0
+					I32Ne
+					Tee R3
+					Get R0
+					I32Const $1
+					I32Add
+					Tee R0
+					I32Const $3
+					I32And
+					I32Const $0
+					I32Ne
+					I32And
+					BrIf $0
+				End
+			End
+			Get R3
+			BrIf $0
+			I32Const $0
+			Set R1
+			Br $1
+		End
+		Get R0
+		I32Load8U $0
+		Get R4
+		Tee R3
+		I32Eq
+		If
+			Get R2
+			Set R1
+		Else
+			Get R4
+			I32Const $16843009
+			I32Mul
+			Set R4
+			Block
+				Block
+					Get R2
+					I32Const $3
+					I32GtU
+					If
+						Get R2
+						Set R1
+						Loop
+							Get R0
+							I32Load $0
+							Get R4
+							I32Xor
+							Tee R2
+							I32Const $-2139062144
+							I32And
+							I32Const $-2139062144
+							I32Xor
+							Get R2
+							I32Const $-16843009
+							I32Add
+							I32And
+							I32Eqz
+							If
+								Get R0
+								I32Const $4
+								I32Add
+								Set R0
+								Get R1
+								I32Const $-4
+								I32Add
+								Tee R1
+								I32Const $3
+								I32GtU
+								BrIf $1
+								Br $3
+							End
+						End
+					Else
+						Get R2
+						Set R1
+						Br $1
+					End
+					Br $1
+				End
+				Get R1
+				I32Eqz
+				If
+					I32Const $0
+					Set R1
+					Br $3
+				End
+			End
+			Loop
+				Get R0
+				I32Load8U $0
+				Get R3
+				I32Eq
+				BrIf $2
+				Get R0
+				I32Const $1
+				I32Add
+				Set R0
+				Get R1
+				I32Const $-1
+				I32Add
+				Tee R1
+				BrIf $0
+				I32Const $0
+				Set R1
+			End
+		End
+	End
+	Get R0
+	I32Const $0
+	Get R1
+	Select
+	Return
diff --git a/src/internal/platform/supported.go b/src/internal/platform/supported.go
index 7b3e7b0588..17db4cb479 100644
--- a/src/internal/platform/supported.go
+++ b/src/internal/platform/supported.go
@@ -62,9 +62,10 @@ func ASanSupported(goos, goarch string) bool {
 // -asan, or GOEXPERIMENT=boringcrypto.
 // There is a copy of this function in cmd/dist/test.go.
 func FIPS140Supported(goos, goarch string) bool {
-	// Keep this in sync with crypto/internal/fips140.Supported.
+	// Keep this in sync with crypto/internal/fips140.go:Supported.
+	// Keep this in sync with cmd/dist/test.go:fips140Supported.
 	switch {
-	case goarch == "wasm",
+	case goarch == "wasm", goarch == "wasm32",
 		goos == "windows" && goarch == "386",
 		goos == "openbsd",
 		goos == "aix":
diff --git a/src/internal/runtime/maps/runtime_hash32.go b/src/internal/runtime/maps/runtime_hash32.go
index 72ab13d1a9..7b8748175f 100644
--- a/src/internal/runtime/maps/runtime_hash32.go
+++ b/src/internal/runtime/maps/runtime_hash32.go
@@ -5,7 +5,7 @@
 // Hashing algorithm inspired by
 // wyhash: https://github.com/wangyi-fudan/wyhash/blob/ceb019b530e2c1c14d70b79bfa2bc49de7d95bc1/Modern%20Non-Cryptographic%20Hash%20Function%20and%20Pseudorandom%20Number%20Generator.pdf

-//go:build 386 || arm || mips || mipsle || wasm || (gccgo && (ppc || s390))
+//go:build 386 || arm || mips || mipsle || wasm || wasm32 || (gccgo && (ppc || s390))

 package maps

diff --git a/src/internal/runtime/wasitest/nonblock_test.go b/src/internal/runtime/wasitest/nonblock_test.go
index eeb0506a2b..4fd04cd2e7 100644
--- a/src/internal/runtime/wasitest/nonblock_test.go
+++ b/src/internal/runtime/wasitest/nonblock_test.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.

 // Not all systems have syscall.Mkfifo.
-//go:build !aix && !plan9 && !solaris && !wasm && !windows
+//go:build !aix && !plan9 && !solaris && !wasm&& !wasm32 && !windows

 package wasi_test

diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go
index 595669e469..eed19846db 100644
--- a/src/internal/testenv/testenv.go
+++ b/src/internal/testenv/testenv.go
@@ -451,7 +451,7 @@ func SkipFlakyNet(t testing.TB) {
 // CPUIsSlow reports whether the CPU running the test is suspected to be slow.
 func CPUIsSlow() bool {
 	switch runtime.GOARCH {
-	case "arm", "mips", "mipsle", "mips64", "mips64le", "wasm":
+	case "arm", "mips", "mipsle", "mips64", "mips64le", "wasm", "wasm32":
 		return true
 	}
 	return false
diff --git a/src/internal/trace/reader_test.go b/src/internal/trace/reader_test.go
index 264cc51569..c298782179 100644
--- a/src/internal/trace/reader_test.go
+++ b/src/internal/trace/reader_test.go
@@ -106,7 +106,7 @@ func testReader(t *testing.T, tr io.Reader, v *testtrace.Validator, exp *testtra
 			break
 		}
 		v.GoVersion = r.GoVersion()
-		if runtime.GOOS == "windows" || runtime.GOARCH == "wasm" {
+		if runtime.GOOS == "windows" || runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 			v.SkipClockSnapshotChecks()
 		}
 		if err != nil {
diff --git a/src/math/big/arith_wasm.s b/src/math/big/arith_wasmx.s
similarity index 90%
rename from src/math/big/arith_wasm.s
rename to src/math/big/arith_wasmx.s
index 3a9aa4ddcb..8732957cf7 100644
--- a/src/math/big/arith_wasm.s
+++ b/src/math/big/arith_wasmx.s
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build !math_big_pure_go
+//go:build !math_big_pure_go && (wasm || wasm32)

 #include "textflag.h"

@@ -23,4 +23,3 @@ TEXT ·mulAddVWW(SB),NOSPLIT,$0

 TEXT ·addMulVVWW(SB),NOSPLIT,$0
 	JMP ·addMulVVWW_g(SB)
-
diff --git a/src/math/floor_asm.go b/src/math/floor_asm.go
index 1b06b8def9..2728cc7040 100644
--- a/src/math/floor_asm.go
+++ b/src/math/floor_asm.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build 386 || amd64 || arm64 || loong64 || ppc64 || ppc64le || riscv64 || s390x || wasm
+//go:build 386 || amd64 || arm64 || loong64 || ppc64 || ppc64le || riscv64 || s390x || wasm || wasm32

 package math

diff --git a/src/math/floor_noasm.go b/src/math/floor_noasm.go
index 34bd292f0e..0645ca2446 100644
--- a/src/math/floor_noasm.go
+++ b/src/math/floor_noasm.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build !386 && !amd64 && !arm64 && !loong64 && !ppc64 && !ppc64le && !riscv64 && !s390x && !wasm
+//go:build !386 && !amd64 && !arm64 && !loong64 && !ppc64 && !ppc64le && !riscv64 && !s390x && !wasm && !wasm32

 package math

diff --git a/src/math/floor_wasm.s b/src/math/floor_wasmx.s
similarity index 94%
rename from src/math/floor_wasm.s
rename to src/math/floor_wasmx.s
index 3751471574..4250bee2b5 100644
--- a/src/math/floor_wasm.s
+++ b/src/math/floor_wasmx.s
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

+//go:build wasm || wasm32
+
 #include "textflag.h"

 TEXT ·archFloor(SB),NOSPLIT,$0
diff --git a/src/net/http/transport_default_other.go b/src/net/http/transport_default_other.go
index 4f6c5c1271..f7f4ed7a6c 100644
--- a/src/net/http/transport_default_other.go
+++ b/src/net/http/transport_default_other.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build !wasm
+//go:build !wasm && !wasm32

 package http

diff --git a/src/net/http/transport_default_wasm.go b/src/net/http/transport_default_wasmx.go
similarity index 90%
rename from src/net/http/transport_default_wasm.go
rename to src/net/http/transport_default_wasmx.go
index 3946812d74..055fe110f4 100644
--- a/src/net/http/transport_default_wasm.go
+++ b/src/net/http/transport_default_wasmx.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build (js && wasm) || wasip1
+//go:build wasm || wasm32

 package http

diff --git a/src/net/main_wasm_test.go b/src/net/main_wasmx_test.go
similarity index 100%
rename from src/net/main_wasm_test.go
rename to src/net/main_wasmx_test.go
diff --git a/src/os/exec/internal/fdtest/exists_unix.go b/src/os/exec/internal/fdtest/exists_unix.go
index 472a802d7b..afe07c54db 100644
--- a/src/os/exec/internal/fdtest/exists_unix.go
+++ b/src/os/exec/internal/fdtest/exists_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build unix || wasm
+//go:build unix || wasm || wasm32

 // Package fdtest provides test helpers for working with file descriptors across exec.
 package fdtest
diff --git a/src/os/exec/lp_wasm.go b/src/os/exec/lp_wasmx.go
similarity index 97%
rename from src/os/exec/lp_wasm.go
rename to src/os/exec/lp_wasmx.go
index 1de9076e53..dce7e0450a 100644
--- a/src/os/exec/lp_wasm.go
+++ b/src/os/exec/lp_wasmx.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build wasm
+//go:build wasm || wasm32

 package exec

diff --git a/src/os/exec_test.go b/src/os/exec_test.go
index 07a06ec0ff..4ba83b360d 100644
--- a/src/os/exec_test.go
+++ b/src/os/exec_test.go
@@ -18,8 +18,8 @@ func TestProcessLiteral(t *testing.T) {
 	if runtime.GOOS == "windows" {
 		t.Skip("Process literals do not work on Windows. FindProcess/etc must initialize the process handle")
 	}
-	if runtime.GOARCH == "wasm" {
-		t.Skip("Signals send + notify not fully supported om wasm port")
+	if a := runtime.GOARCH; a == "wasm" || a == "wasm32" {
+		t.Skipf("Signals send + notify not fully supported on %s port", a)
 	}

 	c := make(chan os.Signal, 1)
diff --git a/src/os/executable_wasm.go b/src/os/executable_wasmx.go
similarity index 92%
rename from src/os/executable_wasm.go
rename to src/os/executable_wasmx.go
index a88360c16f..11660fb9f3 100644
--- a/src/os/executable_wasm.go
+++ b/src/os/executable_wasmx.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build wasm
+//go:build wasm || wasm32

 package os

diff --git a/src/os/pipe_wasm.go b/src/os/pipe_wasmx.go
similarity index 94%
rename from src/os/pipe_wasm.go
rename to src/os/pipe_wasmx.go
index 87a29b1f71..ccab091024 100644
--- a/src/os/pipe_wasm.go
+++ b/src/os/pipe_wasmx.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build wasm
+//go:build wasm || wasm32

 package os

diff --git a/src/os/root_test.go b/src/os/root_test.go
index 9fedff643d..46100bb1a7 100644
--- a/src/os/root_test.go
+++ b/src/os/root_test.go
@@ -1820,7 +1820,7 @@ func TestRootConcurrentClose(t *testing.T) {
 				first = false
 			}
 			f.Close()
-			if runtime.GOARCH == "wasm" {
+			if runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 				// TODO(go.dev/issue/71134) can lead to goroutine starvation.
 				runtime.Gosched()
 			}
@@ -2045,8 +2045,8 @@ func TestRootName(t *testing.T) {
 // TestRootNoLstat verifies that we do not use lstat (possibly escaping the root)
 // when reading directories in a Root.
 func TestRootNoLstat(t *testing.T) {
-	if runtime.GOARCH == "wasm" {
-		t.Skip("wasm lacks fstatat")
+	if runtime.GOOS == "js" {
+		t.Skip("js lacks fstatat")
 	}

 	dir := makefs(t, []string{
diff --git a/src/sync/atomic/atomic_test.go b/src/sync/atomic/atomic_test.go
index 0617b27aca..1e110eb45e 100644
--- a/src/sync/atomic/atomic_test.go
+++ b/src/sync/atomic/atomic_test.go
@@ -2877,12 +2877,14 @@ func shouldPanic(t *testing.T, name string, f func()) {
 }

 func TestUnaligned64(t *testing.T) {
-	// Unaligned 64-bit atomics on 32-bit systems are
-	// a continual source of pain. Test that on 32-bit systems they crash
-	// instead of failing silently.
+	// Unaligned 64-bit atomics on 32-bit systems are a continual source of pain.
+	// Test that on 32-bit systems (except wasm32) they crash instead of failing silently.
 	if !arch32 {
 		t.Skip("test only runs on 32-bit systems")
 	}
+	if runtime.GOARCH == "wasm32" {
+		t.Skip("wasm32 permits unaligned 64-bit atomic access")
+	}

 	x := make([]uint32, 4)
 	p := (*uint64)(unsafe.Pointer(&x[1])) // misaligned
diff --git a/src/sync/atomic/atomic_wasm32_test.go b/src/sync/atomic/atomic_wasm32_test.go
new file mode 100644
index 0000000000..fbad9e6cce
--- /dev/null
+++ b/src/sync/atomic/atomic_wasm32_test.go
@@ -0,0 +1,72 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package atomic_test
+
+import (
+	. "sync/atomic"
+	"testing"
+	"unsafe"
+)
+
+func TestUnaligned64Wasm32(t *testing.T) {
+	x := [5]uint32{magic32, magic32, magic32, magic32, magic32}
+	i := 1
+	if uintptr(unsafe.Pointer(&x[i]))&7 == 0 {
+		i++
+	}
+	p := (*uint64)(unsafe.Pointer(&x[i]))
+	if uintptr(unsafe.Pointer(p))&7 != 4 {
+		t.Fatal("pointer is not misaligned by 4 bytes")
+	}
+	// The two words at p are inside x, with a guard word on either side.
+	t.Cleanup(func() {
+		if x[i-1] != magic32 || x[i+2] != magic32 {
+			t.Fatalf("wrong magic: %#x _ %#x != %#x _ %#x", x[i-1], x[i+2], magic32, magic32)
+		}
+	})
+	check := func(name string, got, want, value uint64) {
+		t.Helper()
+		if got != want || *p != value {
+			t.Fatalf("%s: got %#x, stored %#x; want %#x, %#x", name, got, *p, want, value)
+		}
+	}
+
+	const initial uint64 = 0x12345678ffffffff
+	const next uint64 = 0x89abcdefffffffff
+	StoreUint64(p, initial)
+	check("StoreUint64", *p, initial, initial)
+	check("LoadUint64", LoadUint64(p), initial, initial)
+	if CompareAndSwapUint64(p, initial^(1<<32), next) || *p != initial {
+		t.Fatal("CompareAndSwapUint64 with mismatched old value succeeded or changed the value")
+	}
+	if !CompareAndSwapUint64(p, initial, next) || *p != next {
+		t.Fatal("CompareAndSwapUint64 failed to replace the value")
+	}
+	check("AddUint64", AddUint64(p, 1), next+1, next+1)
+	check("SwapUint64", SwapUint64(p, 0xffffffff00000000), next+1, 0xffffffff00000000)
+	check("AndUint64", AndUint64(p, 0x8000000080000000), 0xffffffff00000000, 0x8000000000000000)
+	check("OrUint64", OrUint64(p, 0x7fffffff00000001), 0x8000000000000000, 0xffffffff00000001)
+
+	q := (*int64)(unsafe.Pointer(p))
+	checkSigned := func(name string, got, want, value int64) {
+		t.Helper()
+		check(name, uint64(got), uint64(want), uint64(value))
+	}
+	const signedInitial int64 = -0x1234567800000001
+	const signedNext int64 = -1 << 32
+	StoreInt64(q, signedInitial)
+	checkSigned("StoreInt64", *q, signedInitial, signedInitial)
+	checkSigned("LoadInt64", LoadInt64(q), signedInitial, signedInitial)
+	if CompareAndSwapInt64(q, signedInitial^(1<<32), signedNext) || *q != signedInitial {
+		t.Fatal("CompareAndSwapInt64 with mismatched old value succeeded or changed the value")
+	}
+	if !CompareAndSwapInt64(q, signedInitial, signedNext) || *q != signedNext {
+		t.Fatal("CompareAndSwapInt64 failed to replace the value")
+	}
+	checkSigned("AddInt64", AddInt64(q, -1), signedNext-1, signedNext-1)
+	checkSigned("SwapInt64", SwapInt64(q, -1), signedNext-1, -1)
+	checkSigned("AndInt64", AndInt64(q, -1<<32), -1, -1<<32)
+	checkSigned("OrInt64", OrInt64(q, 1<<31), -1<<32, -1<<32|1<<31)
+}
diff --git a/src/sync/counter_stripe_test.go b/src/sync/counter_stripe_test.go
index 6049113516..d55dd09579 100644
--- a/src/sync/counter_stripe_test.go
+++ b/src/sync/counter_stripe_test.go
@@ -33,8 +33,8 @@ func TestStripeShardsOnDistinctCacheLines(t *testing.T) {
 }

 func TestStripeGrow(t *testing.T) {
-	if runtime.GOARCH == "wasm" {
-		t.Skip("skipping on wasm: GOMAXPROCS cannot exceed 1")
+	if a := runtime.GOARCH; a == "wasm" || a == "wasm32" {
+		t.Skipf("skipping on %s: GOMAXPROCS cannot exceed 1", a)
 	}
 	initCap := runtime.GOMAXPROCS(0)
 	t.Cleanup(func() {
diff --git a/src/sync/counter_test.go b/src/sync/counter_test.go
index 7ba9ed1cc3..cae876c05e 100644
--- a/src/sync/counter_test.go
+++ b/src/sync/counter_test.go
@@ -262,8 +262,8 @@ func floatEqual(a, b float64) bool {
 // while Adds are in progress, and that successive Values from the same
 // goroutine never decrease when all deltas are positive.
 func TestCounterValueConcurrentWithAdd(t *testing.T) {
-	if runtime.GOARCH == "wasm" {
-		t.Skip("skipping on wasm: the spinning reader is never preempted")
+	if a := runtime.GOARCH; a == "wasm" || a == "wasm32" {
+		t.Skipf("skipping on %s: the spinning reader is never preempted", a)
 	}
 	const phase = 1000
 	procs := runtime.GOMAXPROCS(0)
diff --git a/src/syscall/fs_wasip1_test.go b/src/syscall/fs_wasip1_test.go
index 10fb56e5b1..3c397f444b 100644
--- a/src/syscall/fs_wasip1_test.go
+++ b/src/syscall/fs_wasip1_test.go
@@ -7,6 +7,7 @@
 package syscall_test

 import (
+	"runtime"
 	"syscall"
 	"testing"
 	"unsafe"
@@ -77,9 +78,13 @@ func BenchmarkJoinPath(b *testing.B) {
 }

 func TestRandomGetOverflow(t *testing.T) {
+	if runtime.GOARCH == "wasm32" {
+		t.Skip("32-bit wasm32 cannot perform fake 4GB allocation for test")
+	}
 	// Use unsafe.Slice to avoid actually allocating ~4GB.
 	var dummy byte
-	b := unsafe.Slice(&dummy, int(1<<32))
+	thirty_two := 32 // cannot be a constant, else it prevents compilation on wasm32
+	b := unsafe.Slice(&dummy, int(1<<thirty_two))
 	if err := syscall.RandomGet(b); err != syscall.EINVAL {
 		t.Errorf("syscall.RandomGet succeeds given a slice that is larger than what random_get supports, want %v", syscall.EINVAL)
 	}
diff --git a/src/testing/run_example_wasm.go b/src/testing/run_example_wasmx.go
similarity index 98%
rename from src/testing/run_example_wasm.go
rename to src/testing/run_example_wasmx.go
index b815fcdbd7..a28a17ae23 100644
--- a/src/testing/run_example_wasm.go
+++ b/src/testing/run_example_wasmx.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.

-//go:build js || wasip1
+//go:build wasm || wasm32

 package testing

diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index 6087bfdb6b..94da31caaf 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -22,7 +22,7 @@ import (
 var maxExecDepth = initMaxExecDepth()

 func initMaxExecDepth() int {
-	if runtime.GOARCH == "wasm" {
+	if runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 		return 1000
 	}
 	return 100000
diff --git a/src/text/template/parse/parse.go b/src/text/template/parse/parse.go
index 7acd220e82..d741542108 100644
--- a/src/text/template/parse/parse.go
+++ b/src/text/template/parse/parse.go
@@ -52,7 +52,7 @@ var maxStackDepth = 10000

 // init reduces maxStackDepth for WebAssembly due to its smaller stack size.
 func init() {
-	if runtime.GOARCH == "wasm" {
+	if runtime.GOARCH == "wasm" || runtime.GOARCH == "wasm32" {
 		maxStackDepth = 1000
 	}
 }