Martin Storsjö martin@martin.st writes:
- Rebuild the surrounding host environment (the whole linux
distribution) with -ffixed-x18. This would be the perfect solution, but is highly impractical for general use of Wine by regular users in their existing setups. (Convincing major distributions to start configuring their compilers in this way also doesn't seem to be happening.)
Any chance that this could be made the compiler default, so that distros wouldn't need to do anything?
- Enclose every callback call in Wine with a wrapper/thunk that sets
up the register correctly. This would be a perfect solution, but is practically unfeasible. As far as I know, this is the approach that was used for Win16 back in the day, calling WOWCallback16Ex every time Wine code should call back into Win16 code. Given the size of Wine today and the number of different places where callbacks are made (where the function pointers are called without any extra wrapping), this is unfeasible (and I have a very hard time seeing such a patch accepted into Wine).
I don't think it's feasible to do this at the Windows/Wine boundary, but with the PE cross-compilation support, we could conceivably build most of Wine as PE and add wrappers at the PE/Unix boundary.
The wrappers could then be generated, or we could use a variant of your option 4) that would have the compiler save/restore x18 when calling a non-ms_abi function from an ms_abi one.