-
Notifications
You must be signed in to change notification settings - Fork 570
WIP: Use cmd/go with GopherJS support. #485
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
Conversation
c7fcac1
to
8d6f9ab
Compare
"go/token" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
|
||
gobuild "github.com/gopherjs/gopherjs/go/build" | ||
"github.com/kisielk/gotool" | ||
"github.com/shurcooL/go/importgraphutil" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't fix the issue completely because github.com/shurcooL/go/importgraphutil
package still uses original go/build
, so it's incompatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed completely in a49c2ae.
https://golang.org/cl/23785 has been reviewed and merged, which brings us ever so closely forward, since this PR depended on that change. (See "Upstream or fork required fixes/changes to bundle command" item.) I still have to make and send out another improvement to |
I'm in the process of updating/rebasing on top of Just finished updating the github.com/gopherjs/go repository (which is the source - most things in this PR are generated/copied from that one). There were quite a few minor changes in I've pushed the result to https://github.com/gopherjs/go/commits/go1.7.0-v0.1. See individual commit messages and their changes - each commit should be logically separate and very easy to understand (that's the goal). All of its tests are passing and things are building successfully (with noted limitations):
I'm going to keep reusing this PR, and just squash, rebase, regenerate and force push on top. I'll keep a backup of the history of changes/work on the Go 1.6 branch for reference, in case we need to look something up later. So, this PR will soon become 1 squashed commit that's rebased on latest GopherJS 1.7-1 and github.com/gopherjs/go repository on branch go1.7.0-v0.1. |
Very alpha, much unfinished. Dragons be here. It won't work on your computer yet, unless you're me. But that will be fixed soon, up next. TODO: Split into logical commits, document and explain changes. Update. https://github.com/gopherjs/go/commit/524b8a70b6b558603ceca9144d36e7113f0d37b9 Use own go/build replacement. Update. https://github.com/gopherjs/go/commit/4254365d55f5a069526e73d904ba1b04f4e52709 WIP: Use embedded js, nosync packages. For now, try to use pre-built js.a and nosync.a until we can figure out a good way to build them in a normal way. Try to do this in order to make progress in CI and see what next steps need to be taken. Don't use own go/build replacement for importgraph. It's needed for GopherJS compiler, but we can't use it for importgraph package since they're 3rd party and rely on "go/build".Package. WIP: Try a fix for issue 10332. WIP: Work on disabling cgo, filling custom files during test package builds.
@shurcooL Do you have any plan on how we want to continue on this? |
Yep, I've been meaning to post an update here. I will be closing this PR and abandoning this effort. I may choose to revisit the effort later, but until further notice, I won't be actively working on this. There are 2 reasons I'll close the PR:
Here's a little postmortem and explanations why this effort did not work out. When I first prototyped this idea, I had early success. I was able to make a relatively easy-to-maintain go-gettable fork of At the time, I thought that was the hardest part, and once we'd gotten past that, we would be able to take advantage of the complicated logic that cmd/go has internally to resolve all the package build order, the logic for figuring out where to place built libraries, reusing non-stale built libraries, etc., etc. I also thought it'd be easier to simplify However, it turned out that cmd/go internal code was actually very complicated, messy, and contained many hacks/weird fixes that are specific to So, I gave up on it because the effort and difficulty and time needed were much higher than originally anticipated, and the benefits are not worth it. There may be another opportunity to consider this in the future, given the cmd/go split into packages, and, for example, there were changes to make it possible to |
@neelance I will also delete the https://github.com/gopherjs/go WIP repository. It was created to support this PR, and is no longer needed. Edit: Done. |
All right. It was worth a try. Thanks for investigating. |
DO NOT MERGE.
This is a very early unfinished WIP PR to use cmd/go with GopherJS support instead of own build tool (#388).
Don't try it on your computer yet! It won't work, because there are hardcoded paths specific to my setup. But that will be fixed soon, up next. I will update this when it's ready for first other people to try it.
Large parts of the code here are generated from https://github.com/gopherjs/go repository, go1.6.2-v0.1 or whatever's latest branch. That repo is used for development purposes as a cmd/go base with cherry-picked GopherJS changes on top.
Resolves #388.
Fixes #470.
Fixes #443.
Fixes #414.
Fixes #382.
TODO
Get rid of hardcoded paths in code, resolve remaining critical TODOs in code.
Figure out a way to bootstrap (install) the
github.com/gopherjs/gopherjs/js
andgithub.com/gopherjs/gopherjs/nosync
packages.GOARCH=js go get -compiler=gopherjs github.com/goxjs/websocket
should work.The issue was missing "netgo" build tag. Need to fix that.
Verify all "cmd/go would not have this issue" issues.
Implement a linker flag to control minify/not minify. Currently it always minifies by default.
Figure out a way to deal with sourcemap files. Right now they're not generated at all. Generating a 2nd file is kinda difficult and very different from all other Go compilers... maybe it should be embedded in to the same file? As a debug flag/option? Figure this out.
Implement and test .inc.js stuff.
Take care of 2 items in Setup section.
Upstream or fork required fixes/changes to bundle command:
Document the complicated source package locations (and generated package locations). Explain why it's needed.
Fix
/usr/local/go/test/fixedbugs/issue10332.go
which is currently failing becausereflect.ValueOf(foo{}).Type().Field(0).PkgPath
is being "command-line-arguments" instead of "main" for some reason.gopherjs test fmt
should work, need to fix support for external tests.There may be an issue with _test.go files being built for normal packages.
This turned out to be Any package that imports "encoding/json" will needlessly import "testing" package and its deps. #481.
cmd/go would not have this issue
https://github.com/gopherjs/gopherjs/issues?q=is%3Aissue+is%3Aopen+label%3A%22cmd%2Fgo+would+not+have+this+issue%22
gopherjs test
support running and verifying example code. #239Setup
Where
darwin
is your GOOS.Otherwise you get this when installing first package (which tries to install stdlib with GOARCH=js for first time, starting with runtime/internal/sys package):