Skip to content

Commit 49ee3df

Browse files
committed
compiler/natives/src/math/big: Use math_big_pure_go build tag.
Give the *build.Context variable a shorter, more common name "bctx". Resolves the following TODO comment: // TODO: Consider using math_big_pure_go build tag for this package, instead of // defining all these pure Go low level operators ourselves.
1 parent 99fd1ff commit 49ee3df

File tree

2 files changed

+12
-44
lines changed

2 files changed

+12
-44
lines changed

build/build.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,20 @@ func Import(path string, mode build.ImportMode, installSuffix string, buildTags
7373
}
7474

7575
func importWithSrcDir(path string, srcDir string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) {
76-
buildContext := NewBuildContext(installSuffix, buildTags)
77-
if path == "syscall" { // syscall needs to use a typical GOARCH like amd64 to pick up definitions for _Socklen, BpfInsn, IFNAMSIZ, Timeval, BpfStat, SYS_FCNTL, Flock_t, etc.
78-
buildContext.GOARCH = runtime.GOARCH
79-
buildContext.InstallSuffix = "js"
76+
bctx := NewBuildContext(installSuffix, buildTags)
77+
switch path {
78+
case "syscall":
79+
// syscall needs to use a typical GOARCH like amd64 to pick up definitions for _Socklen, BpfInsn, IFNAMSIZ, Timeval, BpfStat, SYS_FCNTL, Flock_t, etc.
80+
bctx.GOARCH = runtime.GOARCH
81+
bctx.InstallSuffix = "js"
8082
if installSuffix != "" {
81-
buildContext.InstallSuffix += "_" + installSuffix
83+
bctx.InstallSuffix += "_" + installSuffix
8284
}
85+
case "math/big":
86+
// Use pure Go version of math/big; we don't want non-Go assembly versions.
87+
bctx.BuildTags = append(bctx.BuildTags, "math_big_pure_go")
8388
}
84-
pkg, err := buildContext.Import(path, srcDir, mode)
89+
pkg, err := bctx.Import(path, srcDir, mode)
8590
if err != nil {
8691
return nil, err
8792
}
@@ -97,7 +102,7 @@ func importWithSrcDir(path string, srcDir string, mode build.ImportMode, install
97102
case "runtime":
98103
pkg.GoFiles = []string{"error.go"}
99104
case "runtime/internal/sys":
100-
pkg.GoFiles = []string{fmt.Sprintf("zgoos_%s.go", buildContext.GOOS), "zversion.go"}
105+
pkg.GoFiles = []string{fmt.Sprintf("zgoos_%s.go", bctx.GOOS), "zversion.go"}
101106
case "runtime/pprof":
102107
pkg.GoFiles = nil
103108
case "internal/poll":

compiler/natives/src/math/big/big.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,3 @@ package big
55
// TODO: This is a workaround for https://github.com/gopherjs/gopherjs/issues/652.
66
// Remove after that issue is resolved.
77
type Word uintptr
8-
9-
// TODO: Consider using math_big_pure_go build tag for this package, instead of
10-
// defining all these pure Go low level operators ourselves.
11-
12-
func mulWW(x, y Word) (z1, z0 Word) {
13-
return mulWW_g(x, y)
14-
}
15-
func divWW(x1, x0, y Word) (q, r Word) {
16-
return divWW_g(x1, x0, y)
17-
}
18-
func addVV(z, x, y []Word) (c Word) {
19-
return addVV_g(z, x, y)
20-
}
21-
func subVV(z, x, y []Word) (c Word) {
22-
return subVV_g(z, x, y)
23-
}
24-
func addVW(z, x []Word, y Word) (c Word) {
25-
return addVW_g(z, x, y)
26-
}
27-
func subVW(z, x []Word, y Word) (c Word) {
28-
return subVW_g(z, x, y)
29-
}
30-
func shlVU(z, x []Word, s uint) (c Word) {
31-
return shlVU_g(z, x, s)
32-
}
33-
func shrVU(z, x []Word, s uint) (c Word) {
34-
return shrVU_g(z, x, s)
35-
}
36-
func mulAddVWW(z, x []Word, y, r Word) (c Word) {
37-
return mulAddVWW_g(z, x, y, r)
38-
}
39-
func addMulVVW(z, x []Word, y Word) (c Word) {
40-
return addMulVVW_g(z, x, y)
41-
}
42-
func divWVW(z []Word, xn Word, x []Word, y Word) (r Word) {
43-
return divWVW_g(z, xn, x, y)
44-
}

0 commit comments

Comments
 (0)