Skip to content

[go1.20] Removing generic overrides that are no longer needed #1294

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

Conversation

grantnelson-wf
Copy link
Collaborator

@grantnelson-wf grantnelson-wf commented Apr 18, 2024

We'll hold off removing the overrides until generics is further along
and we can assess the impact of removing individual overrides


With the amazing updates made to master for generics, many of the generics overrides for go1.19 and go1.20 are no longer needed. There are a few that I have not removed because they hit some strange bugs that we can look into in another ticket.

We're getting closer, it was really cool to see go1.20.14 install -v && gopherjs build -v net/http pass without issue. gopherjs test -v fmt log still fails but that's because of other go1.20 changes that's I'm working through.

This is part of #1270

@nevkontakte
Copy link
Member

I think we may have to hold off on that one until generics are no longer guarded by the GOPHERJS_EXPERIMENT flag. Otherwise the standard library would no longer build for those who don't have the experiment enabled.

@grantnelson-wf
Copy link
Collaborator Author

@nevkontakte In the go1.20 branch, the standard libraries don't built without the experiment flag as is. I have a bunch of overrides for a generic-less go1.20 in my WIP for g1.20. If you want to, I could pull those out and get them a PR for the go1.20 branch. I was getting close to a generic-less go1.20 (with the exception of that var _ = &Pointer[int]{} from go1.20.14/src/sync/atomic/type.go:40 that has to be manually removed right now). I wasn't PR'ing them since it felt like we were close enough to target a generic capable go1.20.

So, would you like me to cut some PR's for an almost generic-less go1.20, I could do that? Or I could just hold off on removing these for now but also not add more generic-less overrides, whatever helps the most.

@grantnelson-wf grantnelson-wf marked this pull request as draft April 29, 2024 14:50
@grantnelson-wf
Copy link
Collaborator Author

We'll hold off on these changes until generics and go1.20 is further along.

@nevkontakte
Copy link
Member

The rule of thumb is that master branch must be usable by the general population at all times, even between releases. As such, we have two options:

  • Implement a generic-less 1.20, which can be merged into master and released as another beta.
  • Assume that we are okay holding off on 1.20 until generics are done. Then we can go all-in on using generics as much as we can in the 1.20 branch, but won't be able to merge it into master as soon.

I don't think I have a strong preference one way or another. It really depends on how deeply embedded generics are in the 1.20 version, and you probably have a better grasp on this than me :)

@grantnelson-wf
Copy link
Collaborator Author

grantnelson-wf commented May 1, 2024

I was thinking we'd hold off on 1.20 until generics are done.

The big thing is the var _ = &Pointer[int]{} from go1.20.14/src/sync/atomic/type.go:40 that has to be manually removed right now. If we were going to target a generic-less 1.20, we'd have to figure out a way to delete that line from the natives. Since that line doesn't have a unique id for the augmenter to match, we'd either:

  • match it by line number (which is not future resilient)
  • find it by comparing specifications (which seems like it'd be slow)
  • have something that looks for _ on lhs and checks that the rhs has no function body or anything which can have a side effect, e.g. var _ = func() int { /* do thing that has side effects */ }()
  • make a PR into go's repo to remove that check

I'm not fond of any of those, so we'll just have to hold off on 1.20 until generics are done and make go1.20 branch a "needs generics enabled" branch until then.

@grantnelson-wf grantnelson-wf marked this pull request as ready for review May 1, 2024 18:20
@nevkontakte
Copy link
Member

I was thinking we'd hold off on 1.20 until generics are done.

Alright, I have no objections in this case. I'll take another look at this PR when I have a bit more time, and see if we can merge it.

Copy link
Member

@nevkontakte nevkontakte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please double-check that this PR doesn't actually introduce any regressions? I am pretty sure atomic.Pointer overrides are still necessary, and I suspect that at least some of the overrides in the nistec package need to stay.

files []*File

// replaced atomic.Pointer[File] for go1.19 without generics.
last atomicFilePointer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this override may be premature, since in their current state generics don't support instantiations across package boundaries.

Copy link
Collaborator Author

@grantnelson-wf grantnelson-wf May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't seem to, but I'm still working through the errors for go1.20 in my WIP PR. There seems to be a few that may be related to removing the crypto overrides (nistec, like you said above) and at least one that looks like it may be related to atomic.Pointer. (I haven't gotten very far into figuring those out yet so I'm not 100% sure if they are related or not)

I was just so excited that generics worked for so many issues that I probably am just being preemptive on this. Like we discussed before, we can hold off on this. We'll still try for a go1.20 with generics, but until then I don't want to add problems while generics is being worked on.

I'll put this back into Draft and later when you think it is a better time, we can the try it again 😄

@grantnelson-wf grantnelson-wf marked this pull request as draft May 6, 2024 20:53
@grantnelson-wf
Copy link
Collaborator Author

We'll try to remove the overrides later in smaller chunks once the generics are further along.

go1.20 branch will still need GOPHERJS_EXPERIMENT="generics" since the go1.20.14 repo has stuff in it which won't compile without it and we can't (without a lot of effort) override that stuff.

@grantnelson-wf grantnelson-wf deleted the cleanGenericsOverrides branch May 8, 2024 16:46
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

Successfully merging this pull request may close these issues.

2 participants