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

Start support for MSYSTEM=ARM64 #321

Merged
merged 1 commit into from
Jan 27, 2021

Conversation

dscho
Copy link
Member

@dscho dscho commented Jan 22, 2021

This teaches /etc/profile to handle the special value MSYSTEM=ARM64 to set up the environment such that PATH prefers executables in /arm64/bin/ but also falls back to /mingw32/bin/.

The basis is still an i686 version of MSYS2: there is currently no toolchain support in MSYS2 to build executables targeting Windows/ARM64, but there is a built-in i686 emulator in WIndows/ARM64.

@dscho
Copy link
Member Author

dscho commented Jan 22, 2021

@dennisameling I am slightly worried that we're using MINGW_PREFIX so extensively in that case arm: we might need to edit more than just PATH to force more things to fall back to the /mingw32/ universe.

@dennisameling
Copy link
Contributor

@dscho could you give me a bit more guidance as to how I can test this? I followed the steps in git-for-windows/git-sdk-32#6 (comment) and pacman -U git-extra-1.1.513.20ab9a5-1-x86_64.pkg.tar.xz works, but where does it actually install the package? I'm completely new to pacman etc 😊 thanks!

@dscho
Copy link
Member Author

dscho commented Jan 22, 2021

I followed the steps in git-for-windows/git-sdk-32#6 (comment) and pacman -U git-extra-1.1.513.20ab9a5-1-x86_64.pkg.tar.xz works, but where does it actually install the package?

The git-extra package contains a bunch of files, but in the context of this PR, that's totally uninteresting.

What the git-extra package does also is to edit a couple of files in its post-install script. In the context of this PR, the most interesting such file is /etc/profile.

If you have just cloned your 32-bit Git for Windows SDK, or if you pulled from it recently, you should be able to see via git -C / diff etc/profile whether the post-install script made the appropriate edits or not.

Once verified that those edits are there, it would be good if you could verify on a Windows/ARM64 machine that the MINGW_PREFIX is set as expected when opening a new Git SDK Bash, likewise the PATH, and that common things still work such as syntax highlighting in vim, cursor key navigation through Bash's history, git.exe, etc.

@dscho
Copy link
Member Author

dscho commented Jan 22, 2021

Oh, and please also test whether installing git-extra multiple times adds new case arms multiple times 😊

# Allow an i686 version of Git for Windows, augmented by `/arm64/*`, to serve
# as sort of an ARM64 version of Git for Windows (because Windows/ARM64 can run
# i686 executables via a built-in emulator).
test i686 != "$arch" ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about this line. Using the 64-bit SDK on another machine and then it doesn't work. When I remove this line, /etc/profile is updated correctly in the SDK root folder 🚀 Benefit of removing this line is that this patch will be applied both to git-sdk-32 and git-sdk-64, so then it doesn't matter which SDK folks use to build Git. This shouldn't hurt anyone unless their MSYSTEM is set to ARM64 😊

Will do some more tests later today, but at least for now /etc/profile is updated correctly 🎉

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about this line. Using the 64-bit SDK on another machine and then it doesn't work.

That's on purpose, actually: you will not find the case statement in the 64-bit SDK. Instead, it was moved to /etc/msystem there.

The reason why the 32-bit SDK has a different /etc/profile is that its MSYS part hasn't been updated in a long time. In other words, it does not reflect the newest filesystems package definition.

When I remove this line, /etc/profile is updated correctly in the SDK root folder 🚀 Benefit of removing this line is that this patch will be applied both to git-sdk-32 and git-sdk-64, so then it doesn't matter which SDK folks use to build Git.

For the moment, I would rather leave out the complication of dealing with both git-sdk-32 and git-sdk-64, but focus on getting it working correctly only in the git-sdk-32 case.

Copy link
Member Author

Choose a reason for hiding this comment

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

for now /etc/profile is updated correctly

🎉

My one concern is that the MANPATH is now set exclusively to /arm64/{local,share}/man, but there is nothing there...

Copy link
Contributor

Choose a reason for hiding this comment

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

So if I understand it correctly, MANPATH is for the Git for Windows manual files (https://git-scm.com/docs/git#Documentation/git.txt---man-path)? When is this variable actually being used?

Copy link
Contributor

@dennisameling dennisameling Jan 22, 2021

Choose a reason for hiding this comment

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

I created a portable installer and it correctly includes the updated /etc/profile 🚀

What would be the correct order of steps to build a portable installer with the arm64 binaries? Something like this?

  • sdk build mingw-w64-git
  • pacman -U mingw-w64-i686-git-2.30.0.2.f8cbc844b8-1-any.pkg.tar.xz
  • sdk build git-extra (so that /etc/profile gets overwritten to include ARM64)
  • pacman -U git-extra-1.1.513.20ab9a5-1-i686.pkg.tar.xz
  • (create the arm64 binaries now and output to C:\git-sdk-32\arm64)
  • Build the portable installer with the --cross-compile-arm64 option, see portable: add arm64 artifact option #323 for details

Copy link
Member Author

Choose a reason for hiding this comment

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

So if I understand it correctly, MANPATH is for the Git for Windows manual files (https://git-scm.com/docs/git#Documentation/git.txt---man-path)? When is this variable actually being used?

When you call something like man bash in the SDK. This issue is not that important given that we ship Git for Windows without man.exe, but still...

Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we leave it as-is for now then?

Just to confirm, this is the updated section in /etc/profile after running sdk build git-extra:

MINGW32)
  MINGW_MOUNT_POINT="${MINGW_PREFIX}"
  PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
  PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
  ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
  MANPATH="${MINGW_MOUNT_POINT}/local/man:${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
  ;;
MINGW64)
  MINGW_MOUNT_POINT="${MINGW_PREFIX}"
  PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
  PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
  ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
  MANPATH="${MINGW_MOUNT_POINT}/local/man:${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
  ;;
ARM64)
  MINGW_MOUNT_POINT="/arm64"
  PATH="${MINGW_MOUNT_POINT}/bin:/mingw32/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
  PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
  ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
  MANPATH="${MINGW_MOUNT_POINT}/local/man:${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
  ;;

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't happy leaving it as-is, in particular the rather non-intuitive sed invocation. @dennisameling could you please test again, and also sanity-check the new revision (it should be eminently more readable than before)?

Copy link
Contributor

@dennisameling dennisameling Jan 26, 2021

Choose a reason for hiding this comment

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

@dscho just tested again, the results:

✔️ Running sdk build git-extra and then pacman -U git-extra-...-tar.xz correctly updates /etc/profile in git-sdk-32:

ARM64)
  MINGW_MOUNT_POINT="/arm64"
  PATH="${MINGW_MOUNT_POINT}/bin:/mingw32/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
  PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig:/mingw32/lib/pkgconfig:/mingw32/share/pkgconfig"
  ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/mingw32/share/aclocal:/usr/share/aclocal"
  MANPATH="${MINGW_MOUNT_POINT}/local/man:${MINGW_MOUNT_POINT}/share/man:/mingw32/local/man:/mingw32/share/man:${MANPATH}"
  ;;

✔️ Things are looking good in ARM64 Git:

image

Thanks! And yes, the code is much easier to understand now, thank you 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Perfect. Time to merge, then.

Windows/ARM64 can run i686 executables via a built-in emulator. Since it
is currently not possible to build much of anything in MSYS2 for
Windows/ARM64, let's sort of support Windows/ARM64 via starting with an
i686 version of Git for Windows' SDK, then augmenting it by Git
artifacts built via Visual Studio and installed into `/arm64/*`.

To allow for that, we now handle the special value `MSYSTEM=ARM64` to
set up the environment accordingly.

Signed-off-by: Johannes Schindelin <[email protected]>
@tommyvct
Copy link

Just a quick headup, x64 emulation is coming soon. In fact, it's available now on the Windows Insider Dev channel. Once the x64 emulation is out in production, people are going to download the x64 version onto their arm64 machines.

@dscho
Copy link
Member Author

dscho commented Jan 27, 2021

Just a quick headup, x64 emulation is coming soon. In fact, it's available now on the Windows Insider Dev channel. Once the x64 emulation is out in production, people are going to download the x64 version onto their arm64 machines.

Yep, but I don't expect the emulator to be shipped "out of band", i.e. outside the twice-a-year feature updates. And it would be too late for the spring update, so it'll be fall.

In any case, let's hammer it out with the i686 version and then work on x86_64.

@dscho dscho merged commit 10dc059 into git-for-windows:main Jan 27, 2021
@dscho dscho deleted the etc-profile-for-arm64 branch January 27, 2021 07:35
@dscho
Copy link
Member Author

dscho commented Jan 27, 2021

The build succeded in building and publishing git-extra. Another automated build will integrate it into git-sdk-32 (and into git-sdk-64) tomorrow early morning (European time).

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.

3 participants