martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
7.35k stars 243 forks source link

Windows binaries require `vcruntime140.dll` to be installed #4005

Open thoughtpolice opened 3 days ago

thoughtpolice commented 3 days ago

Windows .exe files produced by our CI setup have a dynamic requirement on vcruntime140.dll. This is the Visual C++ Runtime, and it comes with Visual Studio. This is used by most Rust-on-Windows developers (because it's a requirement for rustc) and I suspect 99.9% of all people compiling or using Jujutsu on Windows will have it installed (because culturally that's the most popular toolchain.)

But there's no real reason that a developer using Jujutsu needs that. For instance, if you use an interpreted language like Python or PHP, you can install them and program without ever installing Visual Studio; the things you install will include the Visual C++ Redistributables on your behalf so you don't need to install anything else.

Now we could go the route these tools have and produce installers with the redistributables included, because that's ~practically the only real way to do it while complying with vcruntime's (weird and not well understood) license, and in the future that might be a good idea if we distribute more complex apps (like Tauri ones), but that's a significant amount of work and isn't a blocking requirement for this one issue.

This particular problem can be alleviated with the rustc flag -Ctarget-feature=+crt-static which will cause a statically linked copy of the CRT to be included. This is strongly discouraged for .dll/.lib outputs for the obvious reasons, but we aren't providing those (and most of our integration design revolving around jj-as-a-server and jj-as-a-Rust-lib helps mitigate the need to produce dynamically linked objects anyway.)

(I discovered this while doing a bootstrapping build of jj using Buck2 on a Windows Sandbox and realized I need MSVC before I could even run our produced jj.exe binaries. I have also confirmed in the Buck2 branch that the above flag does produce a working binary without the vcruntime140.dll dependency.)

emilazy commented 3 days ago

Could we use the Windows Universal C Runtime thing instead? Did they deprecate that already?

thoughtpolice commented 3 days ago

The UCRT is absolutely still supported[1], but I don't know what kind of shenanigans we need to target it from Rust in a way that's usable with standard .exe files that a user can just download. From my understanding typically apps deployed on the UCRT need to use Wix so that e.g. Windows Update has information about what apps are dependent on it, which it uses as part of updates. Perhaps a Windows Guru can expand more on this, if any of them are around.

[1] And will probably not be deprecated anytime soon, because the major reason they introduced it after 20+ years of holding off on this was because they finally relented and integrated it with Windows Update so that users could get security updates.