Open LunarLambda opened 1 year ago
Always fun when you search for something and the only matching result is your own year old GitHub issue 😅
Somebody is working on it and was able to build ripgrep with it: https://github.com/ookiineko-cygport/rust You can find short progress report at MSYS2 Discord sever.
tl;dr: Is it possible, and if not, how much work would be necessary, to compile Rust programs for MSYS2's emulated POSIX environment (i.e. programs that link against
msys-2.0.dll
)?MSYS2 is not merely useful as a build environment for cross-compiling on Windows, but also as a portable development environment and alternative to WSL.
So, it would be quite useful to compile some unix-y Rust tools for that environment. I've gotten some crates like bat, ripgrep, and fd-find to work, by building for
x86_64-pc-windows-gnu
, and letting MSYS2's automatic command line path conversion do its magic, but some, especially those dealing with file metadata, terminals, or IPC, don't interoperate very well, since they only talk to the Windows APIs, not the 'emulated' POSIX APIs.For example, currently,
exa
doesn't build for Windows at all, since it expects some "POSIX-ly" libc extensions.As my understanding is, at minimum, a custom target would be needed, similar to
x86_64-pc-windows-gnu
, but withtarget_family = "unix"
, and which uses the MSYS2-native GCC toolchain, and links against the MSYS2 runtime libraries.I don't believe this would require building Rust itself for MSYS2, the regular, windows-native rustc and cargo should be fine there, however, it would require building
std
et al. for MSYS2.I haven't experimented with writing my own targets before, so I'd appreciate any advice and directions, as well as hearing if the Rust team is interested in or already looking into supporting MSYS2 as a target "platform".
I understand it's a niche use case, but given MSYS2's value as both a build and development environment on Windows platforms, and its relative portability compared to things like WSL or other forms of virtualization, I believe it could be useful for many people besides myself.