Skip to content

Update go1.19 native overrides #1386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ jobs:
run: go mod tidy && git diff --exit-code
- name: Check natives build tags
working-directory: ${{ env.GOPHERJS_PATH }}
# All those packages should have // +build js.
run: diff -u <(echo -n) <(go list ./compiler/natives/src/...)
run: |
echo "Any following packages have at least one file that is missing //go:build js"
diff -u <(echo -n) <(go list ./compiler/natives/src/...)

go_tests:
name: Go Tests
Expand Down
4 changes: 1 addition & 3 deletions compiler/gopherjspkg/fs.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package gopherjspkg

import (
"net/http"
)
import "net/http"

// FS is a virtual filesystem that contains core GopherJS packages.
var FS http.FileSystem
Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/bufio/bufio_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package bufio_test

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/bytes/bytes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package bytes

Expand Down
5 changes: 1 addition & 4 deletions compiler/natives/src/bytes/bytes_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//go:build js
// +build js

package bytes_test

import (
"testing"
)
import "testing"

func dangerousSlice(t *testing.T) []byte {
t.Skip("dangerousSlice relies on syscall.Getpagesize, which GopherJS doesn't implement")
Expand Down
5 changes: 1 addition & 4 deletions compiler/natives/src/compress/gzip/example_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//go:build js && wasm
// +build js,wasm

package gzip_test

import (
"fmt"
)
import "fmt"

// The test relies on a local HTTP server, which is not supported under NodeJS.
func Example_compressingReader() {
Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/crypto/elliptic/nistec.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package elliptic

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/crypto/internal/boring/bbig/big.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package bbig

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package bcache

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package bcache

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/crypto/internal/boring/sig/sig.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package sig

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/crypto/internal/nistec/nistec_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package nistec_test

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/crypto/internal/nistec/wrapper.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package nistec

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/crypto/internal/subtle/aliasing.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package subtle

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/crypto/rand/rand.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package rand

Expand Down
5 changes: 2 additions & 3 deletions compiler/natives/src/database/sql/driver/driver_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package driver

Expand All @@ -24,10 +23,10 @@ var valueConverterTests = []valueConverterTest{
{DefaultParameterConverter, (*int64)(nil), nil, ""},
{DefaultParameterConverter, &answer, answer, ""},
{DefaultParameterConverter, &now, now, ""},
//{DefaultParameterConverter, i(9), int64(9), ""}, // TODO: Fix.
//{DefaultParameterConverter, i(9), int64(9), ""}, // TODO: Fix. Errors with `driver.defaultConverter(driver.i(9)) = 9 (driver.i); want 9 (int64)`
{DefaultParameterConverter, f(0.1), float64(0.1), ""},
{DefaultParameterConverter, b(true), true, ""},
//{DefaultParameterConverter, bs{1}, []byte{1}, ""}, // TODO: Fix.
//{DefaultParameterConverter, bs{1}, []byte{1}, ""}, // TODO: Fix. Errors with `driver.defaultConverter(driver.bs([1])) = [1] (driver.bs); want [1] ([]uint8)`
{DefaultParameterConverter, s("a"), "a", ""},
{DefaultParameterConverter, is{1}, nil, "unsupported type driver.is, a slice of int"},
}
1 change: 0 additions & 1 deletion compiler/natives/src/debug/pe/symbol.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package pe

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/embed/embed.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package embed

Expand Down
5 changes: 4 additions & 1 deletion compiler/natives/src/encoding/gob/gob_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package gob

Expand Down Expand Up @@ -105,3 +104,7 @@ func TestTypeRace(t *testing.T) {
// cannot succeed when nosync is used.
t.Skip("using nosync")
}

func TestCountDecodeMallocs(t *testing.T) {
t.Skip("testing.AllocsPerRun not supported in GopherJS")
}
1 change: 0 additions & 1 deletion compiler/natives/src/encoding/json/stream_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package json

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/fmt/fmt_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package fmt_test

Expand Down
4 changes: 1 addition & 3 deletions compiler/natives/src/go/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

package parser

import (
"testing"
)
import "testing"

func TestParseDepthLimit(t *testing.T) {
t.Skip("causes call stack exhaustion on js/ecmascript")
Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/go/token/position.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package token

Expand Down
7 changes: 2 additions & 5 deletions compiler/natives/src/go/token/token_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
//go:build js
// +build js

package token

import (
"testing"
)
import "testing"

func TestFileSetRace(t *testing.T) {
t.Skip()
t.Skip("Fails with: WaitGroup counter not zero")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package alias

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package subtle

Expand Down
5 changes: 1 addition & 4 deletions compiler/natives/src/hash/maphash/maphash.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//go:build js
// +build js

package maphash

import (
_ "unsafe" // for linkname
)
import _ "unsafe" // for linkname

// hashkey is similar how it is defined in runtime/alg.go for Go 1.19
// to be used in hash{32,64}.go to seed the hash function as part of
Expand Down
53 changes: 53 additions & 0 deletions compiler/natives/src/hash/maphash/maphash_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//go:build js

package maphash

import "testing"

//gopherjs:keep-original
func TestSmhasherSmallKeys(t *testing.T) {
if !testing.Short() {
t.Skip("Causes a heap overflow in GopherJS when not --short")
// This test adds a lot of uint64 hashes into a map,
// (16,843,008 for long tests, 65,792 for short tests)
// inside `(s *hashSet) add(h uint64)` with `s.m[h] = struct{}{}`.
// This is to check the number of collisions in the hash function.
}
_gopherjs_original_TestSmhasherSmallKeys(t)
}

//gopherjs:keep-original
func TestSmhasherZeros(t *testing.T) {
if !testing.Short() {
t.Skip("Too slow when not --short")
// This test creates a byte slice with 262,144 bytes for long tests
// and 1,024 for short tests filled by defualt with zeroes.
// Then it adds [:1], [:2], and so on upto the full slice.
}
_gopherjs_original_TestSmhasherZeros(t)
}

func TestSmhasherTwoNonzero(t *testing.T) {
// The original skips if `runtime.GOARCH == "wasm"` which means we should skip too.
t.Skip("Too slow on wasm and JS")
}

func TestSmhasherSparse(t *testing.T) {
// The original skips if `runtime.GOARCH == "wasm"` which means we should skip too.
t.Skip("Too slow on wasm and JS")
}

func TestSmhasherPermutation(t *testing.T) {
// The original skips if `runtime.GOARCH == "wasm"` which means we should skip too.
t.Skip("Too slow on wasm and JS")
}

func TestSmhasherAvalanche(t *testing.T) {
// The original skips if `runtime.GOARCH == "wasm"` which means we should skip too.
t.Skip("Too slow on wasm and JS")
}

func TestSmhasherWindowed(t *testing.T) {
// The original skips if `runtime.GOARCH == "wasm"` which means we should skip too.
t.Skip("Too slow on wasm and JS")
}
1 change: 0 additions & 1 deletion compiler/natives/src/internal/bytealg/bytealg.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package bytealg

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/internal/cpu/cpu.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package cpu

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/internal/fmtsort/fmtsort_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package fmtsort_test

Expand Down
5 changes: 1 addition & 4 deletions compiler/natives/src/internal/poll/semaphore.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//go:build js
// +build js

package poll

import (
_ "unsafe" // For go:linkname
)
import _ "unsafe" // For go:linkname

//go:linkname runtime_Semacquire sync.runtime_Semacquire
func runtime_Semacquire(s *uint32)
Expand Down
20 changes: 0 additions & 20 deletions compiler/natives/src/internal/reflectlite/all_test.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
//go:build js
// +build js

package reflectlite_test

import (
"testing"

. "internal/reflectlite"
)

func TestTypes(t *testing.T) {
for i, tt := range typeTests {
if i == 30 {
continue
}
testReflectType(t, i, Field(ValueOf(tt.i), 0).Type(), tt.s)
}
}

func TestNameBytesAreAligned(t *testing.T) {
t.Skip("TestNameBytesAreAligned")
}

// `A` is used with `B[T any]` and is otherwise not needed.
//
//gopherjs:purge for go1.19 without generics
Expand Down
5 changes: 1 addition & 4 deletions compiler/natives/src/internal/reflectlite/export_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//go:build js
// +build js

package reflectlite

import (
"unsafe"
)
import "unsafe"

// Field returns the i'th field of the struct v.
// It panics if v's Kind is not Struct or i is out of range.
Expand Down
12 changes: 0 additions & 12 deletions compiler/natives/src/internal/reflectlite/reflect_mirror_test.go

This file was deleted.

1 change: 0 additions & 1 deletion compiler/natives/src/internal/reflectlite/reflectlite.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package reflectlite

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/internal/reflectlite/swapper.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package reflectlite

Expand Down
1 change: 0 additions & 1 deletion compiler/natives/src/internal/reflectlite/type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build js
// +build js

package reflectlite

Expand Down
5 changes: 1 addition & 4 deletions compiler/natives/src/internal/reflectlite/utils.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
//go:build js
// +build js

package reflectlite

import (
"unsafe"
)
import "unsafe"

type ChanDir int

Expand Down
Loading
Loading