Skip to content
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 arm64 support to git-wrapper #44

Merged
merged 1 commit into from
Jan 22, 2021

Conversation

dennisameling
Copy link

@dennisameling dennisameling commented Dec 28, 2020

CC @dscho

Builds further on #43

Some of the logic in this PR comes from https://www.rudyhuyn.com/blog/2017/12/13/how-to-detect-that-your-x86-application-runs-on-windows-on-arm/

This PR allows users to build mingw32 but with a special git-wrapper that supports arm64 on Windows. This way, the regular mingw32 packages can be used, while Git itself (e.g. git clone) runs natively on arm64.

MSYSTEM is set correctly to ARM64, and after manually adding /arm64/bin to the PATH (should be done automatically when git-for-windows/git-sdk-32#6 is merged), the native Git executable is used as well:

104065043-5769e480-51ff-11eb-81a2-8c9fd8d27b35

Here you can see that the wrapper git.exe is still 32-bit, but the actual git commands are handled by the native ARM64 binary:

image

The folder structure is as follows in that case:

image

Build steps for mingw-w64-i686-git

  1. Checkout this PR in C:\git-sdk-64\usr\src\MINGW-packages
  2. Open Git SDK bash
  3. cd /usr/src/mingw-packages/mingw-w64-git
  4. MINGW_INSTALLS=mingw32 makepkg-mingw -sLf
  5. Open pkg/mingw-w64-i686-git, you'll find the generated binaries here

Build steps for native Git arm64 binaries

Follow the steps mentioned here: git-for-windows/git#2915 (comment)

Putting everything together on the arm64 device

  1. Download Git for Windows portable 32-bit
  2. Create an arm64 folder and copy the native Git arm64 binaries from the previous step into it:

image

@dennisameling dennisameling marked this pull request as ready for review December 28, 2020 11:22
@dennisameling dennisameling mentioned this pull request Dec 28, 2020
mingw-w64-git/PKGBUILD Outdated Show resolved Hide resolved
mingw-w64-git/git-wrapper.c Outdated Show resolved Hide resolved
mingw-w64-git/git-wrapper.c Outdated Show resolved Hide resolved
@dennisameling
Copy link
Author

dennisameling commented Jan 8, 2021

@dscho it works with IsWow64Process2! 🚀

It actually works on Windows 8.1 as well, so I assume that the logic I got from here is enough to dynamically load IsWow64Process2.

I just had to manually copy the DLLs for the generated native ARM64 binaries. Created a separate issue for that: git-for-windows/git#2970

I double-checked and both the git.exe triggered from Git Bash and from the Windows cmd line (see below) are the native git.exe binaries 👍🏼

image

Windows 10 ARM64:

image

image

Windows 8.1 VM x64:

image

image

@dennisameling dennisameling requested a review from dscho January 8, 2021 21:22
@dennisameling dennisameling changed the title [WIP] Add arm64 support to git-wrapper Add arm64 support to git-wrapper Jan 8, 2021
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for working on this!

I suggested a couple changes, nothing big, should be pretty close to being done now. Oh, and one more suggestion: could you squash your commits into a single one?

mingw-w64-git/git-wrapper.c Outdated Show resolved Hide resolved
mingw-w64-git/git-wrapper.c Show resolved Hide resolved
mingw-w64-git/git-wrapper.c Outdated Show resolved Hide resolved
mingw-w64-git/git-wrapper.c Outdated Show resolved Hide resolved
mingw-w64-git/git-wrapper.c Outdated Show resolved Hide resolved
mingw-w64-git/git-wrapper.c Outdated Show resolved Hide resolved
mingw-w64-git/mingw-w64-git.mak Outdated Show resolved Hide resolved
In order to support native Git for Windows ARM64 binaries,
this commit introduces ARM64 runtime detection. Git-wrapper itself will
remain an i686 or x86_64 executable for now, but since Windows on ARM
has built-in i686 emulation, it can run the file.

If an ARM64 system is detected, we set MSYSTEM=ARM64. Next to that,
because many binaries like curl aren't available natively for ARM64 yet,
we add /mingw32/bin to the path, so that we'll fallback to i686
executables in that case.

Signed-off-by: Tommy Vercetti <7903172+tommyvct@users.noreply.github.com>
Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
@dennisameling
Copy link
Author

dennisameling commented Jan 22, 2021

@dscho just implemented the feedback and squashed everything into a single commit 🚀

Can confirm things still work on my ARM64 device as well as in my Windows 8.1 VM (which of course doesn't have IsWow64Process2, so at least things don't crash or anything).

UPDATE here's a screenshot from ARM64, all looks good as far as I can see:

image

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From your comments, I gather that you tested this, and since everything looks pretty and neat, I will merge it. Thank you so much!

mingw-w64-git/git-wrapper.c Show resolved Hide resolved
@dscho dscho merged commit eca72dc into git-for-windows:main Jan 22, 2021
@dscho
Copy link
Member

dscho commented Feb 12, 2021

@dennisameling I got a report that the 32-bit version of Git for Windows v2.30.1 is completely broken on ARM64 (fork bomb). Could you verify that? I suspect that this PR is responsible for that issue.

@dscho
Copy link
Member

dscho commented Feb 12, 2021

@dennisameling I got a report that the 32-bit version of Git for Windows v2.30.1 is completely broken on ARM64 (fork bomb). Could you verify that? I suspect that this PR is responsible for that issue.

Here is my attempt to help: #46. But I cannot test (I don't have access to any Windows/ARM64 system).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants