[PATCH v2] configure: Avoid clobbering x18 on arm64 when building with clang

André Hentschel nerv at dawncrow.de
Fri Jun 23 11:13:50 CDT 2017


Am 23.06.2017 um 11:38 schrieb Martin Storsjö:
> On Fri, 23 Jun 2017, Alexandre Julliard wrote:
> 
>> Martin Storsjö <martin at martin.st> writes:
>>
>>> I agree this would be an issue with clang built system libraries on
>>> linux though. Is it still worthwhile to add to configure, for cases
>>> where system libraries have been built with gcc? If not, I'll just
>>> keep on adding it manually to my cflags when configuring, while
>>> experimenting with this.
>>
>> I don't think it's worthwhile adding it, particularly if the compiler
>> doesn't work anyway because of va_list. Hopefully you can fix both
>> issues while you're at it ;-)
> 
> GCC also doesn't work due to va_list - the __builtin_ms_va_list is only implemented on x86_64 at the moment, not on aarch64.
> 
> Well, I'm not sure how much the x18 register issue really can be fixed - the AAPCS calling convention says that it's a temporary register that the compiler can use freely, unless the platform has reserved it (like on darwin, and apparently also on windows). So I don't think clang/llvm would be interested in a patch to disable use of this on linux in general.
> 
> Apparently André talked to GCC about the issue a few years ago: https://gcc.gnu.org/ml/gcc/2015-07/msg00106.html

Hi,

yes, this went nowhere...
One idea is to set x18 to the TEB after a function call. That could be done by some new mechanism based on our relay functionality (and AJ already said no to it), or by using the thunks Wine generates for its dlls, which would be done in import.c from winebuild...
The problem here is how to get the TEB from assembler (and possibly performance...)? There are some steps involved until someone can call NtCurrentTeb I guess. Maybe can try to preserve it in the thunks, then we need to assume that it's correct on entry...
And then there are callbacks...

> I'm not sure if that discussion resulted in something else somewhere - if I'm just lucky that it has happened to work for me so far (but could break randomly if gcc would happen to use x18 anywhere in the called system libraries, and just clang seems to be using it more often so I only ran into it with clang?), or if something really was changed elsewhere with respect to this. André, can you fill us in on this matter?

So your Wine build crashes even when running Wines cmd/winecfg/...? Is that fixed by removing the assembler line in dlls/ntdll/signal_arm64.c:signal_init_thread ?
As you already mentioned, if x18 is not treated special it should be a normal scratch register and one should be able to write to it nearly always without producing a crash...

> In any case, thanks for the attention so far, I'll return once __builtin_ms_va_list is implemented in either of the compilers, and I'll keep using these flags locally for the time being.

Thanks for your work on it! I'm also interested in doing the ARM64 work in mingw-w64 again (as soon as clang is ready for that)


See also:
https://bugs.winehq.org/show_bug.cgi?id=38780
https://bugs.winehq.org/show_bug.cgi?id=38886



More information about the wine-devel mailing list