-
-
Notifications
You must be signed in to change notification settings - Fork 746
Add scope decorations to std.socket #8438
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
|
Thanks for your pull request, @schveiguy! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#8438" |
|
Is there a way to check if dip1000 compiles phobos? We must be checking this somewhere... |
|
Worth noting that this is a breaking change so it will need to be called out in the documentation, but the transition is easy so it is surely worth the minor hassle. |
I think it adds the flag automatically already: https://github.com/dlang/phobos/blob/master/posix.mak#L138 |
|
For reference, I discovered this when trying to build mysql-native with my new safe patch with dip1000 turned on. Adam is right that this is a breaking change. I have it in draft until I can think about how to properly do the deprecation (if it's even possible). |
|
Why is it a breaking change? Without dip1000 |
|
Because if you derive from Socket (e.g. to make a SSL socket), then you have to repeat the scope attributes, or it breaks. So if you haven't already done that, then your code won't compile with this version. And there is actually a buildkite project that breaks for this exact reason: https://buildkite.com/dlang/phobos/builds/6817#314ce653-7c99-423b-83dc-a28ac09cfc32 |
|
On Fri, Apr 22, 2022 at 01:58:45PM -0700, Steven Schveighoffer wrote:
Because if you derive from Socket (e.g. to make a SSL socket), then you have to repeat the scope attributes, or it breaks. So if you haven't already done that, then your code won't compile with this version.
Worth noting this is quite minor breakage that you can probably just rip
the band-aid off.
|
|
cc @ikod |
Thanks! Sorry if this is wrong place to ask. If I understand correctly I only have to change 'override' Socket calls and this should work? |
|
On Sat, Apr 23, 2022 at 12:36:49AM -0700, ikod wrote:
Sorry if this is wrong place to ask. If I understand correctly I only have to change overrided Socket calls and this should work?
Yes, and it should compile now, even without the phobos pr, meaning you
can make the change any time without breaking old compiler
compatibility.
I gotta do the same thing to my lib.
|
fixed in v2.0.5 |
Thanks for the quick response! |
|
Damn, still broken, I think some functions got missed. @ikod I'll see if I can make a PR. |
sorry! merged, released 2.0.6 |
|
Thanks @ikod for your help! Hopefully all done. I had to force push, as buildkite seemed to be stalled. |
|
should be green now (dlang-requests now passing). I need either a bug report or a changelog now... |
RazvanN7
left a comment
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.
Looks good! A changelog will suffice.
|
Please review changelog entry before merging. |
CyberShadow
left a comment
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.
Flagging just to make sure we're on the same page, thanks @schveiguy .
We've previously rejected pull requests which cause breakage of this type. In particular TestSocket is considered "holy" and may not be changed, as the need of doing so signals that the rest of the changes are likely to be breaking.
Is there anything special about this case that's different from the previous ones, or is it time to reconsider those decisions too?
|
If making the interface defined by |
|
Wait, so we can just merge this as-is? I was going to put in the template check, but would rather not... |
See the comment at the top of the file: Lines 3 to 5 in 3443e00
|
|
FYI, the hunt-labs socket which would be affected is no more, they removed it in 2019. So we can take that off the list of affected projects. |
Well, the reason that CI is succeeding is because this PR changes the test code which should not be changed (because then it's not testing for what it is supposed to be testing for). |
|
OK, I think that test would not pass if compiled with dip1000. I think that's a coincidence, since the debug switch was added 2 years ago (probably long before dip1000 testing was added to phobos). |
|
OK, so give me a path forward. My current plan was to change the virtual functions to skinny wrappers with the "correct" attributes around the real implementation, based on detection of dip1000. I'd have to do that to the unittest wrapper socket as well. Is that satisfactory? |
Without looking at the specifics, I think the intention of Looking at the specifics, it looks a lot like the second case. Sending a single byte is a common pattern to e.g. wake up an event loop, and a static array makes sense for that.
I can't picture how this would look like and work. Could you make a simple example with one method? The idea of the I can do the same for my proposal in #8438 (comment) if you want. |
|
I think we should change all |
|
OK, can you re-instate your request changes so this doesn't get accidentally merged while meddling with it? It won't let me put it back in draft or "request changes" on my own PR. |
CyberShadow
left a comment
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.
OK, here it is. (It's forcing me to enter a comment.)
|
Will see if it builds, but checkout second commit. If it works, I'll do it to all them. I have issues testing phobos locally, so relying on CI here. |
|
It does work, but not if I revert the changes done to |
|
Wait, I don't think this is going to work. Scope is in the mangling. So if Phobos is compiled with dip1000, but when you compile against it, you have dip1000 off, it won't link. So that idea is no good... damn. |
|
And overloading on scope doesn't work. So it has to be a new class, or we break code, as already discussed. |
Rereading that comment, I'm not loving this idea. If It also would break any code that accepts a |
I don't know that However |
Yes. But that simultaneously gives us the freedom to keep tightening the
Yes, I mentioned this as well in my comment above. The benefit is that this breaking change will happen once.
This is a good point. If we don't foresee many other necessary changes to There is also #5496, which tried to add |
It does make sense, and it also doesn't. But not because of Address (all methods have a Overloads based on const are possible, but of course, you'd have to overload both, so it still breaks using that path. But I'm not sure it's important to do. If not for that single |
|
I think it's much more likely that |
|
yeah, good point. Perhaps worth doing now, which means we would have to have the current derivers update their types again. |
|
Good points about breakage and what got rejected earlier, but adding |
CyberShadow
left a comment
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.
Right, so I think this is good to go as-is.
|
Thanks for the thoughtful discussion. This really opened my eyes as to what is coming when dip1000 becomes the default, we need to tread cautiously! |
This is to fix issues with compiling projects with dip1000.
I'm not sure how to add appropriate tests, since dip1000 is a compiler switch.