add support for 32-bit ARM on Windows#477
Conversation
|
Is there any possibility that this could be merged soon? |
atgreen
left a comment
There was a problem hiding this comment.
Thanks for your patch. Please fix the README -- otherwise, I think it's good to merge.
README.md
Outdated
| GNU compiler uses 80 bits (128 in memory) FFI_GNUW64 ABI. | ||
| Many new tests cases and bug fixes. | ||
|
|
||
| 3.3 Mar-05-19 |
There was a problem hiding this comment.
Please don't make a new release number. We'll try to get the long overdue 3.3 out soon.
There was a problem hiding this comment.
Sorry. It should be fixed now.
* add support for 32-bit ARM on Windows * fix mismatched brace in appveyor.yml * remove arm platform from appveyor.yml for now * fix arm build * fix typo * fix assembler names * try Visual Studio 2017 * add windows arm32 to .appveyor.yml * update README.md
…o master Reviewed-by: Mike Ash <[email protected]> Reviewed-by: Matt Reda <[email protected]> * commit '2284bfc111229c3af01722d9aab23056025a8e01': (22 commits) darwin arm64e: libunwind requires that the CFA match the value used to sign LR arm64e: Fix frame size to 40b to match earlier change in aarch64/ffi.c Add missing arch guards around ffi_find_closure_for_code_np fix mingw build and crashing bugs for Python Windows ARM64 (libffi#496) Clear the apt cache More debugging output Debug moxie builds in travis libffi: added ARM64 support for Windows (libffi#486) uuencode compressed log files for travis hppa: avoid TEXTREL in .eh_frame section (libffi#447) fix x86/x64 MSVC build (libffi#487) add support for 32-bit ARM on Windows (libffi#477) fix check for Linux/aarch64 Cleanup symbol exports on darwin and add architecture preprocessor checks to assist in building fat binaries (eg: i386+x86_64 on macOS or arm+aarch64 on iOS) (libffi#450) Fix cfi checks for old compiler (libffi#453) changes for win32 on windows (libffi#468) aarch64: Flush code mapping in addition to data mapping (libffi#471) Remove -Os testing. No ABI impact, and helps trim log lengths. fix(configure): Correctly detect visibility("hidden") support on Darwin Fix Q registers parameter passing on ARM64 ...
@paulmon Does python use the "closures" feature of libffi? When testing libffi for Windows on 32 bit ARM, I notice that all tests regarding closures (in the testsuite) fail. This is because it fails to set the thumb bit in the trampolines. Locally I've worked around it with a change like this (on top of latest master): diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index ae7c0d7..16a93b2 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -607,6 +607,10 @@ ffi_prep_closure_loc (ffi_closure * closure,
{
void (*closure_func) (void) = ffi_closure_SYSV;
+#ifdef _WIN32
+ codeloc = (void*)((uintptr_t)codeloc & 0xFFFFFE);
+#endif
+
if (cif->abi == FFI_VFP)
{
/* We only need take the vfp path if there are vfp arguments. */
diff --git a/src/closures.c b/src/closures.c
index f7bead6..d6e35e1 100644
--- a/src/closures.c
+++ b/src/closures.c
@@ -405,6 +405,7 @@ ffi_closure_free (void *ptr)
#include <unistd.h>
#endif
#include <string.h>
+#include <stdint.h>
#include <stdio.h>
#if !defined(_WIN32)
#ifdef HAVE_MNTENT
@@ -969,6 +970,9 @@ ffi_closure_alloc (size_t size, void **code)
msegmentptr seg = segment_holding (gm, ptr);
*code = add_segment_exec_offset (ptr, seg);
+#if (defined(__arm__) || defined(_M_ARM)) && defined(_WIN32)
+ *code = (void*)((uintptr_t)*code | 1);
+#endif
if (!ffi_tramp_is_supported ())
return ptr;
@@ -979,6 +983,9 @@ ffi_closure_alloc (size_t size, void **code)
return NULL;
}
*code = ffi_tramp_get_addr (ftramp);
+#if (defined(__arm__) || defined(_M_ARM)) && defined(_WIN32)
+ *code = (void*)((uintptr_t)*code | 1);
+#endif
((ffi_closure *) ptr)->ftramp = ftramp;
}
@atgreen What would you think of such a change? |
These changes have been tested with CPython's ctypes test on Windows IoT Core running on ARM32.