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

Martin Storsjo martin at martin.st
Wed Jun 21 04:41:31 CDT 2017


On aarch64/arm64, clang/LLVM feels free to use x18 for normal code
generation on linux (while the register is reserved on iOS/darwin).
For windows/arm64, this register must not be clobbered.

If targeting arm64, check for the clang cflags that allows this
register to be left untouched.

This makes sure that wine for aarch64 built with clang doesn't
crash immediately on startup.
---
Not sure if this is the neatest way autoconf-wise to test whether
the compiler supports the flags and adding them to CFLAGS if they can
be used, but it seems to work for me at least.
---
 configure.ac | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index 7ae29f7..5b5a1d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -179,6 +179,11 @@ case $host in
     CFLAGS="$CFLAGS -marm"
     AC_SUBST(TARGETFLAGS,"-marm")
     ;;
+  aarch64*)
+    # Clang needs these flags in order not to clobber the x18 register
+    WINE_TRY_CFLAGS([-Xclang -target-feature -Xclang +reserve-x18],
+                    [CFLAGS="$CFLAGS -Xclang -target-feature -Xclang +reserve-x18"])
+    ;;
   i[[3456789]]86*)
     enable_win16=${enable_win16:-yes}
     ;;
-- 
2.7.4




More information about the wine-patches mailing list