-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add win32-aarch64 support #1264
Conversation
One CI failure seem to be related to what was described as "flaky Travis behavior" on the mailing list, specifically Another failure appears to be a missing tool, |
I did not yet really check, but I managed to get the build for aarch64 going. I have now three different dlls for windows, for two of these the Unittests for x86-64 come back clean, but unittests for x86 result in an error:
In the dicussion for #1259, some patches were mentioned, that match this: #1259 (comment). You can run the build + unittests by invoking:
On x86-64 you can switch between 32bit and 64bit by switching the building JDK. When run on aarch64 this should also be possible to run through the build and check the unittests. Thank you for the work. It is great, that you took this on. |
AppVeyor steps for x86, arm64 added via 0ae7234. x86 is failing at the same spot as identified in #1264 (comment). Logs: https://ci.appveyor.com/project/tresf/jna/builds/36266553 |
For the texinfo problem on travis this should fix it: matthiasblaesing@b698710 (test on travis-ci on amd64 are currently dog-slow, so this is deduced from the successful run on arm64) |
Thanks, added. |
Done. Please see test results: Detailed logs can be found here: https://gist.githubusercontent.com/tresf/dab4ebf5459f3370a33c0c0c659e5d4e/raw/788512b93e2a58eb7cc18aa171d5da972fdcdbec/win32-aarch64-jna-tests.log @matthiasblaesing thoughts? Some updates to the original build instructions:
|
For the arguments marshal tests, this should be the relevant commit, that fixed it in the past:
For the test failure in "GetModuleHandleEx(fptr) failed": If I remember correctly you disabled that code for arm64 didn't you? If so it needs to be recorded in HAS_DLL_CALLBACKS = osType == WINDOWS; For the crash in The error in testLoadFromUnicodePath is more or less expected - it works only on the "right" OS encoding. |
I tried
Perfect, thanks. Patched e3ad29d.
Thanks, patched via 2ff29eb.
Here's the crash log: https://gist.githubusercontent.com/tresf/caca6d16bfde240c87d17d72194564c2/raw/43d9c8552dc627894b877206e11229ad68bec3f8/hs_err_pid19056.log If I need to rebuild with debug symbols, I'd be happy to. I'm not very familiar with this process, but I'd be happy to try. New report: |
Update. The unit tests are in better shape after updating to the latest win32-aarch64 snapshot from Microsoft, now called
... more release notes are available in the releases area. Note, at the time of writing this the newest release is for macOS (notice the New results attached. The only test that seems to be failing now is the unicode one. Logs: https://gist.github.com/tresf/07c4de8cbbf17d87997da261dae40d7b |
Note, the following upstream issues/PRs seem to be very similar to the x86 issues we see in the Listed as a code block to avoid a bunch of crosslinking.
I adapted/cherry-picked what I think is the same x86 guard. The diff is below. With this applied, diff --git a/lib/native/win32-x86.jar b/lib/native/win32-x86.jar
index 54fab71e8..025ca3e89 100644
Binary files a/lib/native/win32-x86.jar and b/lib/native/win32-x86.jar differ
diff --git a/native/libffi/src/x86/ffi.c b/native/libffi/src/x86/ffi.c
index 5f7fd81d9..98c09ba6a 100644
--- a/native/libffi/src/x86/ffi.c
+++ b/native/libffi/src/x86/ffi.c
@@ -181,6 +181,9 @@ ffi_prep_cif_machdep(ffi_cif *cif)
{
ffi_type *t = cif->arg_types[i];
+#if defined(_M_IX86)
+ if (cif->abi != FFI_STDCALL)
+#endif
bytes = FFI_ALIGN (bytes, t->alignment);
bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG);
} |
The above patch seems to work with both mingw and msvc builds, I'm going to add it to this PR. Next, I'll rebase and cleanup the commits slightly. |
0e2295f
to
9f0775b
Compare
@matthiasblaesing some questions:
|
I assume, that you mean
I use that file as my base to rebuild the native binaries. If I understood correctly, the build works in cross-platform mode and thus it would be great to add a description. At some point someone needs to rebuild the native parts and then these notes. It is best if the binary is rebuild on the target platform itself, but my experience is, that this is not always possible.
Sorry, I'm also more at home on the java side. I can fix obvious problems and spot problems, but here I'm out. It would indeed be great if you could help with upstreaming @twall. In general the current state looks sane to me and I'm inclined to move take it. I did a diff against upstream master and there is some movement in the ARM64/windows area, so it might be worth updating while its hot :-).
If people want to do it in the JNA repository, ok, but then the question needs to be answered how sustainable that is. If we have changes separated out, documented and covered with tests, that are run as part of the build, all is well. If not I think it is better to push changes to go through upstream. I like the debian approach, where upstream is augemented with seperated patches, which can be reviewed/exchanged individually. I tested this branch on windows-x86-64, windows-x86 and linux-x86-64. Build runs clean and unittests run clean (that means the unittests that fail on master also fail on this PR, no new failures are reported). I have a few nitpicks for the commits: bd672b9: It would be great if the version/commit of libffi could be mentioned that was used to create that update. That might be helpful if future developers try to do an update. cef2d76 + 9f0775b: Please squash. It should not matter, as the win32-aarch64.jar only contains native code, so should be save anyway. Please update your author information for the commits, to contain your fullname. The email part is already spells it out, but I'd like to keep the author information correct. Please add an entry to CHANGES.md about the update of libffi and more importantly the added platform support. |
Since Microsoft doesn't offer a native ARM64 version of Visual Studio, the target platform uses near-identical build tools. The major difference is the Since..
... then I'm inclined to keep the tutorial for 64-bit systems. Do you agree? If not, we get into some differentiating steps between That said, the binary provided was built on an Intel machine. That's purely for convenience and Edit: Done. (Rebuilt on ARM, re-uploaded, squashed).
Edit: Found it using In regards to libffi/upstream would jna consider having their own fork? I can help setup the submodule, but developers would need to do Regardless of that decision, in the interim, I'll reword the commit to include the specific versioning information and address the other requests as well. |
Initial rewrite of the readme is here: https://gist.github.com/tresf/9182a81d7c41a9425ae8ad8f626773e1 Please let me know if this is in the right direction, or if you'd prefer to keep the |
d809496
to
8eac2a5
Compare
I believe all request have been addressed with exception of an updated Windows procedure. When I have direction on that, I'm happy to commit or squash. |
Ok - I think the wait is long enough - maybe it is time to consider just cherry picking the fix into our tree and be done with it. @tresf what do you think? |
Since the last commits the following ARM64 changes have landed publicly...
This gives me a unique opportunity to rebuild my system from scratch to match the Windows build tutorial (64-bit toolchain) but this introduces a minor, unforeseen issue with cygwin documented here: 2714a01. I've reported this issue to the cygwin developers. Sorry for the TL;DR, but at time of writing this, I'm still encountering build failures with this setup. When they're resolved, I'll get back to bumping libffi with the aforementioned (unmerged) patch and move forward. |
As it turns out, The list of tools which are reported as missing: The symptom is unobvious at first, the compile begins as expected, but the Anyway, I wanted to document this somewhere, as other projects relying on libffi and Edit: Done via 387920b. |
Cherry-pick of libffi/libffi#600 See also java-native-access#1264 (comment)
5c63b46 (v3.3 + 64 commits)
Cherry-pick of libffi/libffi#606
Cherry-pick of libffi/libffi#600 See also java-native-access#1264 (comment)
Squashed, fast-forwarded, cherry-picked, ready for final review. The multiple force-pushes were needed to ensure a clean clone can still build binaries between changes, and then a final force push to bring the resulting As an aside, I grew tired of the |
I rebuild all native libraries with the new version, only skipping mac OS as that will be tackled with the alreay open PR, I also followed the notes about the windows build instructions and managed to rebuild all three windows native libraries. While doing this I slightly updated the documentation with my oberservation of the procedure. Please have a look at this: https://github.com/matthiasblaesing/jna/tree/pr-1264. If you agree, I plan to merge that. The native libraries can be found in the I plan to run the jna-platform tests with the updated base library, but I have yet to setup the necessary software. |
I have and although cosmetic changes with the documentation seem sane, the |
@tsref as discussed on the commit itself, I updated the branch with an updated suggestion for the wording of the windows instructions. The TL;DR version: I left you paths in place, but added a note that paths need to be updated depending on the exact software installed (I also removed the exact Java version, as long as JDK 8 is used, we are save). I ran the platform tests on windows for 32 and 64bit. These came back clean, which is not surprising given, that appveyor is happy, in addition to the tests covered by appveyor on my machine (any machine that has Office installed) COM checks are run. Please ensure, that the resulting binary can be run on aarch64, as I could only verify, that If you agree, I'll merge once Appveyor is happy. |
QEMU can run the full blown Windows ARM64 OS, but I've read it's tremendously slow. I also believe Microsoft offers a Windows 10X emulator, but it's been a very long time since I've fired it up and I'm unsure as to if the underlying OS is ARM64 or not. I'll see if I have one around still. It wasn't a very good OS for Desktop tasks last I tried (uses a weird Desktop sandbox) and the OS was too buggy for daily use, but that was about a year ago. From what I can find most other emulators offered by Microsoft were old ARM32 layers, mostly for the phones. I'll see what I can dig up.
Would you like me to try the same on ARM64? |
Hehe, this reminds me about the pain when linux-mips64el and linux-ppc64el were build with full system emulation in Qemu.... Not fun :-)
I have some fear here. My gut feeling is, that we could hit some hard assumptions, that don't hold anymore. Anyway - if can, it would be interesting, the final report would be great to see. |
In regards to Microsoft Office ARM64 integration... Office seems to use predominantly x86 binaries still, so that didn't add any more unit tests the ARM64 tests. In regards to ARM64 emulation.... Windows 10X was a bust. I'm unsure of the underlying architecture it's using, but what was very clear is that opening a command prompt on this OS isn't possible. The Desktop emulation wouldn't even start the 7zip installer. Microsoft claims Hyper-V will do architecture emulation when needed and there's evidence of this, such as the work from Xamarin team to port Android with hardware acceleration over to Hyper-V, but at time of writing this, the |
I merged this in now - appveyor is happy, local tests with linux-x64, windows x86 and windows x64 came back clean. Thank you! |
Cherry-pick of libffi/libffi#600 See also java-native-access#1264 (comment)
Just an FYI on fast-forwarding/upstream status...
|
TODO
testSyncronizedAccess
unit test). (Upstream regression: aarch64: Allow FFI_WIN64 for winelib libffi/libffi#593 (comment). Reverted.)native/libffi/libtool-ldflags
(97a66a7)Changes
native/libffi
to latest version, adding Windows arm64 support 2bf1593win43-aarch
viaASMFN_OFF
(no mingw support)win32-aarch64
2ff29ebwin32-aarch64
e3ad29dmsvcc.sh
to handle the following scenarios/regressions:cygpath
calculation forcl.exe
112d76d-I
) files with spaces (e.g.-I"C:\Program Files\AdoptOpenJDK11\...\include
) 112d76deval
for assembly files 112d76dwin32-aarch64
native build option${make.ARCH}=aarch64
, reusing Android's propertylib/native/win32-aarch64.jar
MSVC v142 - VS 2019 C++ ARM64 build tools (v14.27)
on Windows 10 x86_64openjdk-aarch64
from MicrosoftSteps
See the updated
www/WindowsDevelopmentEnvironment.md
Hidden, outdated
BumpNo, per Add win32-aarch64 support #1264 (comment)jna.jar
Install and configure
ant
for your systemInstall cygwin per Windows steps
Install Visual Studio 2019 with ARM build tools (other versions should also work).
Disable CRLF globally for git (use with caution, this will affect all projects. Alternately, you can skip this step and use
dos2unix
on each failing file)Clone this PR
git clone -b win-arm64 https://github.com/tresf/jna --depth 10 cd jna
From a Command Prompt, configure MSVC to build using arm64
Append cygwin to your path (Append, DO NOT prepend, if you prepend,
link.exe
will fail!)Fire the build:
⚠️ Note: Windows Defender real-time protection makes this very, very slow. Consider disabling or adding an exception to the
jna
directory.ant native -Dos.prefix=win32-aarch64 # or on native aarch64, just type "ant"
Clean between errors:
Optionally, enable debugging
verbose=
toverbose=1
innative/libffi/msvcc.sh
-DEXTRA_MAKE_OPTS="--debug=v"
to ant command