Skip to content

Commit 0cc212b

Browse files
authored
Revert "Handle GOARCH env var similarly to cmd/go." (#605)
This reverts commit 62bca28. We've originally discussed two possible fixes in issue #594: > The gopherjs tool does not use the GOARCH environment variable > in any way. Internally, GopherJS always uses js as GOARCH value > when compiling user code, but it does other internal stuff when > compiling standard library. > > 1. One fix is to make the gopherjs tool really ignore GOARCH env > var. In other words, setting it to any value should have no effect; > it shouldn't cause this failure. > > 2. We could also consider making it use the value of GOARCH, and > error out if it's set to anything other than js (which is the > default and the only supported value). Since gopherjs can't compile > for any other architectures. Upon further consideration, after seeing issue #601 and gopherjs/gopherjs.github.io#66, we've decided (see discussion in gopherjs/gopherjs.github.io#66 (comment)) to revisit this issue and change gopherjs to completely ignore GOARCH environment variable, instead of requiring it to be unset or equal to js. Closes #601. Updates #594.
1 parent d911b80 commit 0cc212b

File tree

2 files changed

+1
-40
lines changed

2 files changed

+1
-40
lines changed

tests/run.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,7 @@ func (t *test) run() {
620620
os.Setenv("GOOS", runtime.GOOS)
621621
}
622622
if os.Getenv("GOARCH") == "" {
623-
//os.Setenv("GOARCH", runtime.GOARCH)
624-
// GOPHERJS.
625-
os.Setenv("GOARCH", "js") // We're running this script natively, but the tests are executed with js architecture.
623+
os.Setenv("GOARCH", runtime.GOARCH)
626624
}
627625

628626
useTmp := true

tool.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ func main() {
9191
cmdBuild.Flags().AddFlag(flagTags)
9292
cmdBuild.Flags().AddFlag(flagLocalMap)
9393
cmdBuild.Run = func(cmd *cobra.Command, args []string) {
94-
if err := verifyGOARCH(); err != nil {
95-
printError(err, options, nil)
96-
os.Exit(2)
97-
}
9894
options.BuildTags = strings.Fields(*tags)
9995
for {
10096
s := gbuild.NewSession(options)
@@ -177,10 +173,6 @@ func main() {
177173
cmdInstall.Flags().AddFlag(flagTags)
178174
cmdInstall.Flags().AddFlag(flagLocalMap)
179175
cmdInstall.Run = func(cmd *cobra.Command, args []string) {
180-
if err := verifyGOARCH(); err != nil {
181-
printError(err, options, nil)
182-
os.Exit(2)
183-
}
184176
options.BuildTags = strings.Fields(*tags)
185177
for {
186178
s := gbuild.NewSession(options)
@@ -248,10 +240,6 @@ func main() {
248240
Short: "display documentation for the requested, package, method or symbol",
249241
}
250242
cmdDoc.Run = func(cmd *cobra.Command, args []string) {
251-
if err := verifyGOARCH(); err != nil {
252-
printError(err, options, nil)
253-
os.Exit(2)
254-
}
255243
goDoc := exec.Command("go", append([]string{"doc"}, args...)...)
256244
goDoc.Stdout = os.Stdout
257245
goDoc.Stderr = os.Stderr
@@ -279,10 +267,6 @@ func main() {
279267
Short: "compile and run Go program",
280268
}
281269
cmdRun.Run = func(cmd *cobra.Command, args []string) {
282-
if err := verifyGOARCH(); err != nil {
283-
printError(err, options, nil)
284-
os.Exit(2)
285-
}
286270
err := func() error {
287271
lastSourceArg := 0
288272
for {
@@ -337,10 +321,6 @@ func main() {
337321
cmdTest.Flags().AddFlag(flagTags)
338322
cmdTest.Flags().AddFlag(flagLocalMap)
339323
cmdTest.Run = func(cmd *cobra.Command, args []string) {
340-
if err := verifyGOARCH(); err != nil {
341-
printError(err, options, nil)
342-
os.Exit(2)
343-
}
344324
options.BuildTags = strings.Fields(*tags)
345325
err := func() error {
346326
pkgs := make([]*gbuild.PackageData, len(args))
@@ -536,10 +516,6 @@ func main() {
536516
var addr string
537517
cmdServe.Flags().StringVarP(&addr, "http", "", ":8080", "HTTP bind address to serve")
538518
cmdServe.Run = func(cmd *cobra.Command, args []string) {
539-
if err := verifyGOARCH(); err != nil {
540-
printError(err, options, nil)
541-
os.Exit(2)
542-
}
543519
options.BuildTags = strings.Fields(*tags)
544520
dirs := append(filepath.SplitList(build.Default.GOPATH), build.Default.GOROOT)
545521
var root string
@@ -801,19 +777,6 @@ func sprintError(err error) string {
801777
}
802778
}
803779

804-
// verifyGOARCH verifies that GOARCH environment value is not set to
805-
// an unsupported value.
806-
func verifyGOARCH() error {
807-
goarch, ok := os.LookupEnv("GOARCH")
808-
if !ok {
809-
return nil
810-
}
811-
if goarch != "js" {
812-
return fmt.Errorf("gopherjs: unsupported GOOS/GOARCH pair %s/%s", build.Default.GOOS, goarch)
813-
}
814-
return nil
815-
}
816-
817780
func runNode(script string, args []string, dir string, quiet bool) error {
818781
var allArgs []string
819782
if b, _ := strconv.ParseBool(os.Getenv("SOURCE_MAP_SUPPORT")); os.Getenv("SOURCE_MAP_SUPPORT") == "" || b {

0 commit comments

Comments
 (0)