-
Notifications
You must be signed in to change notification settings - Fork 0
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
[WIP] compiler: upgrade to Go 1.13 #50
base: master
Are you sure you want to change the base?
Conversation
8c0a568
to
c90d25a
Compare
The main outstanding work here:
type ImportContext struct {
Packages map[string]*types.Package
Import func(path string) (*Archive, error)
}
type ImportContext struct {
Packages map[string]*types.Package
Import func(path, dir string) (*Archive, error)
}
|
25f2f08
to
572a8fd
Compare
This is an initial cut of 1.13 support. internal/reflectlite is a new package in Go 1.13 that presents a subset of the API of reflect. internal/reflectlite support has been added according to the following steps: * in the build step, override the .GoFiles for internal/reflectlite to be empty, i.e. we will only take the native (GopherJS) implementation and won't augment any GOROOT definitions * taking the current native (GopherJS) implementation of reflect * taking the Go 1.13 implementation of reflect * adding all files into natives/src/internal/reflectlite (marking the Go 1.13 reflect files as _original.go) * progressively removing definitions from the *_original.go files until we get back to a package that compiles. This involves removing certain superfluous definitions (that only exist in the API of reflect) that bring in unwanted imports, e.g. strconv). We also then special case internal/reflectlite in the same places that reflect is special-cased. To handle the new core vendor of golang.org/x/net/dns/dnsmessage and friends, we use .ImportMap from the output of go list to resolve the correct package for any given import within a package. WIP - we still need to fix the handling of import paths at test time.
I'm starting figuring out what's broken and what needs fixing. What I did so far:
I suppose this is what you were referring to when saying that the test subcommand is broken. I have a couple of questions to ask, in case you've figured answers out already.
|
It also seems that https://godoc.org/golang.org/x/tools/go/packages would give us modules support for free. The only unclear aspect is how to plug in gopherjs-specific augmentations, but it doesn't seem impossible. |
@nevkontakte thanks for taking a look. In response to your points: FWIW, I'm using
Exactly.
You're absolutely correct. The main reason I didn't use Also, it's somewhat overkill for what we need. We could happily and easily use it, but accessing the transitive imports would then require us to walk the result of
I'm not totally clear on this point. To be honest, the GopherJS code has been rather aggressively patched up over the last few years, so it's not exactly in the cleanest state 😄 At this stage I'm in two minds:
The stage I've currently reached with approach 2 is close; I'm just debugging where and why the external test package is getting some incorrect I'll try and find a bit of time to dig a bit further then push any updates with comments. |
@myitcv thanks for your answers! I was actually thinking to take a shot at rewriting I have an extra hidden interest in that, since at work I maintain integration between GopherJS and our build system and I had to resort to some inelegant patches and workarounds to achieve that. Do you think it would be worth for me to try the option # 1 in parallel to you, or try to focus on # 2 together? |
Very much so. Please feel free to ping any questions you might have here, and I'll do my best at answering them.
I'd be interested in hearing more about this. Please drop me an email (in my bio) if you'd prefer not sharing details about that here. |
My English parser has encountered an "undefined behavior" error :) To double check: do you prefer me attempting to switch to |
Ha! Sorry, I only read the first part of the sentence 😄 So just to clarify: please do attempt to switch to |
Gotcha :) I'll give it a shot and report back if I find it promising or not. |
FYI. I followed this thread this morning and then found gopherjs#959 which includes code for module handling (via a fastmod package) and a gopherjs implementation of reflectlite. I built from that pull request and can confirm that building gopherjs with go1.13.7, the gopherjs tests pass as do the go1.13.7 "bytes" package unit tests, up to the same point as the gopherjs1.12 was able to, where system calls are required to continue. |
This is an initial cut of 1.13 support. internal/reflectlite is a new
package in Go 1.13 that presents a subset of the API of reflect.
internal/reflectlite support has been added by:
be empty, i.e. we will only take the native (GopherJS) implementation
and won't augment any GOROOT definitions
1.13 reflect files as _original.go)
we get back to a package that compiles. This involves removing certain
superfluous definitions (that only exist in the API of reflect) that
bring in unwanted imports, e.g. strconv).