Skip to content

playground: Update for Go 1.9. #67

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

Closed
dmitshur opened this issue Aug 25, 2017 · 5 comments
Closed

playground: Update for Go 1.9. #67

dmitshur opened this issue Aug 25, 2017 · 5 comments
Assignees

Comments

@dmitshur
Copy link
Member

This should be done with GopherJS version 1.9-1.

@dmitshur dmitshur self-assigned this Aug 25, 2017
@dmitshur
Copy link
Member Author

I'm investigating this right now.

Everything seems to work okay, except that something causes unsafe package to get loaded, and that fails, because it's not one of the installed packages:

unicode \
unicode/utf16 \
unicode/utf8

I tried adding it to that list, and that fixes the problem:

diff --git a/playground/update.sh b/playground/update.sh
index 5d62c70..578a5fa 100755
--- a/playground/update.sh
+++ b/playground/update.sh
@@ -134,7 +135,8 @@ gopherjs install -m \
          time \
          unicode \
          unicode/utf16 \
-         unicode/utf8
+         unicode/utf8 \
+         unsafe
 
 cp -a "$GOROOT"/pkg/*_js_min/* pkg/
 cp -a "$GOROOT"/pkg/*_amd64_js_min/* pkg/

However, I want to look around first to see if there's a better fix, and whether this is indicative of a problem somewhere in GopherJS 1.9-1.

@dmitshur
Copy link
Member Author

The "unsafe" package is special-cased here:

https://github.com/gopherjs/gopherjs/blob/95deb33d587c9f6e24b494ea9bdf9648c48f9a60/compiler/package.go#L105-L107

I want to see what changed related to that causing it to be included as part of a build, where previously it wasn't.

@dmitshur
Copy link
Member Author

dmitshur commented Aug 25, 2017

This is the generated code for the unsafe package:

$packages["unsafe"] = (function() {
	var $pkg = {}, $init;
	$init = function() {
		$pkg.$init = function() {};
		/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
		/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
	};
	$pkg.$init = $init;
	return $pkg;
})();

It's basically empty (aside from bookkeeping related to goroutines and blocking calls). It contains an empty init function, and that's the only thing that gets called by other packages.

@dmitshur
Copy link
Member Author

dmitshur commented Aug 25, 2017

Figured it out. It's due to an API change in go/types package (golang/go#21622).

"go/types".Package.Imports used to exclude package unsafe in Go 1.8, but no longer does in 1.9.

image

Compare https://gotools.org/go/types?rev=go1.8.3#package.go-L54-L55 vs https://gotools.org/go/types?rev=go1.9#package.go-L50-L51.

dmitshur added a commit to gopherjs/gopherjs that referenced this issue Aug 25, 2017
If its code were to be generated, package unsafe ends up largely empty:

	$packages["unsafe"] = (function() {
		var $pkg = {}, $init;
		$init = function() {
			$pkg.$init = function() {};
			...
		};
		$pkg.$init = $init;
		return $pkg;
	})();

It contains an empty (aside from goroutine/blocking bookkeeping code) init
function, and that's the only thing that gets called by other packages.

So, we don't want to start including it. This change restores the previous
behavior (with Go 1.8) of skipping it.

Helps gopherjs/gopherjs.github.io#67 (comment).
Related to https://golang.org/cl/37694.
@dmitshur
Copy link
Member Author

I might need to make additional changes, so I've undone the deploy of 8bcc3f3 for now.

@dmitshur dmitshur reopened this Aug 25, 2017
dmitshur added a commit to gopherjs/gopherjs that referenced this issue Aug 26, 2017
If its code were to be generated, package unsafe ends up largely empty:

	$packages["unsafe"] = (function() {
		var $pkg = {}, $init;
		$init = function() {
			$pkg.$init = function() {};
			...
		};
		$pkg.$init = $init;
		return $pkg;
	})();

It contains an empty (aside from goroutine/blocking bookkeeping code) init
function, and that's the only thing that gets called by other packages.

So, we don't want to start including it. This change restores the previous
behavior (with Go 1.8) of skipping it.

Helps gopherjs/gopherjs.github.io#67 (comment).
Related to https://golang.org/cl/37694.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant