-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
interop: enable preserveArgvZero #84
Conversation
As a simple way to test this, enable |
Update: great. This change breaks stable and fixes Preview. Will need a thonk. |
Update: it seems to be impossible to actually detect the WSL version from inside the VM. This is just great. |
As of now, it is still working for me like before, however I am only in the Release Preview ring on this machine. Even if we could detect the WSL version, we'd need to do that at build time (or register WSLInterop using a custom systemd service instead of systemd-binfmt, but that'd be more of a workaround than a solution) |
You need WSL Preview from the Microsoft Store to get the new behavior. Also, we can register a shim that just reexecs /init with the right args, but that still needs to somehow know the version... |
Let's just ask upstream: microsoft/WSL#8315 |
Also, here's the upstream update that contains the change: https://github.com/microsoft/WSL/releases/tag/0.58.0 |
So turns out upstream has a solution: torvalds/linux@2347961. Yay! Except it's only in kernel 5.12 and up, and WSL2 ships 5.10. Boo. So I guess we have to figure something out still, or coerce upstream into fixing this correctly? |
That does work, but it relies on interop being enabled again. If we just assume interop is enabled in wsl.conf, we can just read the flags from sysfs on startup. |
This is with wsl.interop.register enabled. We could move the register process to a custom systemd service, then register using the old method. If we can run |
That's not the problem, the problem is getting the PATH on the VM side. Though I guess we could use a custom executable in the store as a test... |
How ist the PATH a problem? The path seems to be set correctly in WSL Preview. Also, the path to powershell.exe is well-known ( |
PATH is only set if interop is enabled, which it might not be, and Windows doesn't have to live on C:. I think we can make a custom executable work though - it can totally run things stored on the VM side over 9p. |
I haven't considered that... I know that it can, that's what I did in #83. We could use a small binary in a language that can be cross-compiled on Linux for Windows (I think go would work) |
So I've just made a very simple Rust shim that prints
This led me to a more interesting discovery: |
So, this is very ugly and we really need upstream's help here, but it might work for now? |
Pushed a shorter version with a better comment. |
This looks at least usable for the time being. Once WSL 0.58 (or later) gets included in a stable windows build, the hack could be moved behind an option (something like |
Another option would be to add a tristate null (autodetect)/true/false option for this, just to save the overhead of the extra /init call. I'm not sure it's worth it though... |
I guess this is fundamentally a hack, so there's no real reason to attempt to unhack it. |
+1 from me, I think this is a good solution. Let's not get too caught up in whether things are "hacks", WSL is moving too fast and these things will be irrelevant in a few hundred days. |
I sincerely hope so. |
they've indicated that they're willing to backport anything that has landed in master if it's relevant, so it might be worth sending an email directly. Their issue tracker is a mess, just the way it goes when they have as many new-to-linux users as they have. |
The problem is that even if they backport it, we already know how the new version behaves anyway. |
As in the backport will ship in a future release that already has consistent behavior. |
I did a little benchmark of the autodetect wrapper (starting a small binary that just exits immediately, repeated 10000 times, times in seconds). It effectively doubles the invocation time. That probably won't be noticeable, but to ensure backward compatibility, we should probably leave the hack in here as an option even when the new WSL version becomes stable. I like the idea with the tristate option. For the moment the default will be null (autodetect) and later we change it to false by default |
I'd rather remove the hack, default to preserveArgvZero, and let people on old WSLs use the wrapper. Also, if this ever becomes performance critical, we can always move to detecting the behavior in an activation script or whatever. |
The more I think about it the more I feel like this should be an option still, and we can just default it to true when the update ships. |
I'll set this to WIP and try to make the option tomorrow. |
The legacy registration should definitely be an option for compatibility reasons. The only question is whether or not we should keep Auto-detection as an option (which I think could be useful in some cases, for example of you have a config you want to deploy to multiple machines running different versions of WSL) |
I was thinking about just putting the hack in now, then making it optional when the update ships. But that doesn't really make sense, does it... |
Why not, I mean with the autodetection enabled it works for now. I could merge now and you open a new PR where you add the option tomorrow or whenever you have time for it. When the update ships, we just have to change the default |
I'm trying to add the option now... |
Still need to test this with different versions, give me a bit. |
Fixes interop with latest WSL versions
OK, tested on my end, seems good. |
Fixes interop with latest WSL versions. Would appreciate some testing on pre-Store versions of WSL.