mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.56k stars 1.61k forks source link

Native winelib support? #8709

Open cwabbott0 opened 3 years ago

cwabbott0 commented 3 years ago

As part of an adventure to get DXVK working with Hangover (https://github.com/AndreRH/hangover) I ran against the fact that there are no readily available aarch64 mingw toolchains, so the only way to build the host DLL's is as a winelib library, and for performance reasons we want DXVK to be built as a host library. DXVK used to have some support for being built as a winelib, but it was removed because it was a maintenance burden and was frequently broken. I have some hacks to get it to work again, but I think that some of the hackiness could be reduced by adding support for winelib builds in meson directly. Some of the differences compared to vanilla mingw-gcc I ran into are:

Some of this could, and maybe should, be worked around with patches to wine instead. But at least the last one probably needs to be handled in meson. DXVK doesn't actually require building the dll, because no one is linking against DXVK directly and wine can load the .dll.so directly, so the old winelib support in DXVK had a hack to change the shared library suffix to .dll.so and ignore the wrapper. That works enough for our use-case, but obviously isn't great.

Are there opinions about how this should be added? Should there be a winelib platform or should this be auto-detected somehow based on the compiler name?

tristan957 commented 3 years ago

@cwabbott0 this sounds like you need to create a new Compiler class that inherits off of one of the already-existing compilers, since you only have a couple of issues to fix.

That last bullet kind of sounds like a module would be the way to attack the problem. I think your module could be akin to the GNOME module. Specific behaviors for working with WINE-based projects just the GNOME module is specific behaviors for working with GNOME-based projects.

dcbaker commented 3 years ago

I suppose conceptually winelib based outputs really aren't that different than cygwin or msys. I think it's doable, and it's probably worth solving for dxvk if nothing else. I might be able to spend some time looking at it in the future, though I've got a pretty fully plate at the moment.

cwabbott0 commented 3 years ago

As an update, my wine patches fixing the first two bullets have now landed and are in Wine 6.12.

Revisiting this again, I don't think a module is the right solution. The issue is that both the executable wrapper and .so ELF file are created at the same time, so it really needs to be something the compiler aware of - a single invocation of the linker with -o foo.dll will produce foo.dll.so, foo.dll.a, and foo.dll.fake and then foo.dll.fake needs to be installed as foo.dll. So in other words the executable wrapper needs to be plumbed though everywhere the implib currently is. We could create a new compiler class, but would it be possible to then propagate all that information up to the installer, or would we need to make a new platform?

guijan commented 2 years ago

Is this still being worked on?

I can't help with development because I don't know Python, but here's a project and branch with automated CI for it: https://github.com/guijan/libobsd/tree/add-winelib Here's a CI run: https://github.com/guijan/libobsd/runs/5644921927?check_suite_focus=true

The current winelib support in Meson can compile a hello world, but Meson doesn't understand that winegcc adds a suffix to the executables and libraries it creates as pointed out above. This makes tests and custom targets (if their command is an executable produced by Meson) fail with a "file not found" error.