summaryrefslogtreecommitdiff
path: root/configure.host
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2021-04-07 05:42:10 +0300
committerGitHub <noreply@github.com>2021-04-06 22:42:10 -0400
commitdd5bd03075149d7cf8441875c1a344e8beb57dde (patch)
tree3a119b5e06927287cd2cf2bd38879617461aa815 /configure.host
parent95ef857d5c6ed15c6c6ba5f8a5b26c0a38b417ab (diff)
downloadlibffi-dd5bd03075149d7cf8441875c1a344e8beb57dde.tar.gz
Fix building for arm windows with mingw toolchains (#631)
* arm: Check _WIN32 instead of _M_ARM or _MSC_VER for detecting windows This matches what was done for ARM64 in c06468fa6674d3783a0edb1d0fae9afc8bc28513. * arm: Only use armasm source when building with MSVC When building for windows/arm with clang, the normal gas style .S source works fine (if fixed up to support thumb and other windows specifics). This matches what was done for ARM64 in c06468fa6674d3783a0edb1d0fae9afc8bc28513. * arm: Fix sysv.S to work in thumb mode Align cases in jump tables (adding nop padding to make sure each case starts where expected). Rewrite instructions that add directly to the pc register. For ffi_closure_ret, factor out a call_epilogue subroutine that restores both sp and pc from the stack; the thumb version of ldm can't load into the sp register. To avoid excessive ifdeffing, keep using call_epilogue in arm mode, but keep the shorter "ldm sp, {sp, pc}" epilogue in that case. * arm: Add win32 version of trampoline to sysv.S This matches the version of it in sysv_msvc_arm32.S. The calling C code expects a specific form of the trampoline on windows; make sure these work the same on windows regardless of the form of assembly used. * arm: Avoid optimizing out clearing the thumb bit of ffi_arm_trampoline We clear the thumb bit of ffi_arm_trampoline with a bitmask before memcpying its instructions into closure->tramp. If the bit isn't cleared, the memcpy of the trampoline function copies the wrong instructions. If the ffi_arm_trampoline symbol is declared as an array of int, the compiler can assume that it is aligned to a 4 byte boundary and the bitmask operation is a no-op, and optimize it out. See https://godbolt.org/z/dE3jE1WTz; both Clang and GCC optimize out the bitmask as it is, while MSVC doesn't. By declaring the trampoline as an array of unsigned char, the bitmask works as intended.
Diffstat (limited to 'configure.host')
-rw-r--r--configure.host10
1 files changed, 8 insertions, 2 deletions
diff --git a/configure.host b/configure.host
index 257b784..2682671 100644
--- a/configure.host
+++ b/configure.host
@@ -32,7 +32,9 @@ case "${host}" in
arm*-*-cygwin* | arm*-*-mingw* | arm*-*-win* )
TARGET=ARM_WIN32; TARGETDIR=arm
- MSVC=1
+ if test "${ax_cv_c_compiler_vendor}" = "microsoft"; then
+ MSVC=1
+ fi
;;
arm*-*-*)
@@ -264,7 +266,11 @@ esac
# ... but some of the cases above share configury.
case "${TARGET}" in
ARM_WIN32)
- SOURCES="ffi.c sysv_msvc_arm32.S"
+ if test "$MSVC" = 1; then
+ SOURCES="ffi.c sysv_msvc_arm32.S"
+ else
+ SOURCES="ffi.c sysv.S"
+ fi
;;
ARM_WIN64)
if test "$MSVC" = 1; then