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 cross compilation support to makepkg-mingw (experimental) #2283

Conversation

dennisameling
Copy link

@dennisameling dennisameling commented Dec 27, 2020

Currently, Windows arm64 isn't supported natively by msys2 (refs #1888 #1276 #1787).

In the meantime, we added support for native arm64 Git for Windows (spoiler: it's ~2x as fast as the emulated 32-bit version on arm64). Our main goal currently is to get a Git executable that is native for arm64, but that falls back to mingw32 packages in case a native arm64 version isn't available (yet) for any of those packages (Windows arm64 supports 32-bit/i686/x86 emulation).

An important step is to be able to detect arm64 in mingw-w64-git and cross-compile from an x86_64 host. However, makepkg-mingw currently only supports MINGW_INSTALLS=mingw32 and MINGW_INSTALLS=mingw64, which sets the CARCH to either i686 or x86_64.

In order to support the cross-compilation scenario, this PR adds support for MINGW_INSTALLS=arm64, which sets the CARCH to arm64 on a x86_64 host. Please note that this PR does not add support for native compilation on arm64.

It goes without saying that this PR only lays the fundamental groundwork for arm64 cross-compilation support, after which we can make a start with native arm64 packages. Example:

Dennis@DESKTOP-0RP8NC0 MINGW64 /usr/src/mingw-packages/mingw-w64-git (pr/42)
$ MINGW_INSTALLS=arm64 /c/msys64/usr/src/msys2-packages/pacman/makepkg-mingw -sLf
==> Making package: mingw-w64-git 2.29.2.3.d054eb1fc4-1 (Sun Dec 27 23:30:15 2020)
==> Checking runtime dependencies...
==> Installing missing dependencies...
error: target not found: mingw-w64-arm64-curl
error: target not found: mingw-w64-arm64-ca-certificates
error: target not found: mingw-w64-arm64-expat>=2.0
error: target not found: mingw-w64-arm64-openssl
error: target not found: mingw-w64-arm64-pcre2
error: target not found: mingw-w64-arm64-tcl
error: target not found: mingw-w64-arm64-tk
==> ERROR: 'pacman' failed to install missing dependencies.
==> Missing dependencies:
  -> mingw-w64-arm64-curl
  -> mingw-w64-arm64-ca-certificates
  -> mingw-w64-arm64-expat>=2.0
  -> mingw-w64-arm64-openssl
  -> mingw-w64-arm64-pcre2
  -> mingw-w64-arm64-tcl
  -> mingw-w64-arm64-tk
==> Checking buildtime dependencies...
==> Installing missing dependencies...
error: target not found: mingw-w64-arm64-asciidoctor-extensions
error: target not found: mingw-w64-arm64-cv2pdb
==> ERROR: 'pacman' failed to install missing dependencies.
==> Missing dependencies:
  -> mingw-w64-arm64-asciidoctor-extensions
  -> mingw-w64-arm64-cv2pdb
==> ERROR: Could not resolve all dependencies.

Please let me know if there's anything I overlooked or whether you think a different approach should be taken.

CC @dscho

@dennisameling dennisameling changed the title Add arm64 cross compilation support (experimental) Add arm64 cross compilation support to makepkg-mingw (experimental) Dec 27, 2020
# Currently, arm64 is only supported through cross-compilation from mingw32
if [ "${_mingw}" = "arm64" -a -f "/mingw32/bin/gcc.exe" ]; then
MSYSTEM=${_msystem} \
PATH=/mingw32/bin:$(echo $PATH | tr ':' '\n' | awk '$0 != "/opt/bin"' | paste -sd:) \
Copy link
Author

Choose a reason for hiding this comment

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

Something like PATH=/arm64/bin:mingw32/bin:$(echo .... might also work, but I'm currently not sure what the implications of this would be. I assume it would first look for a native binary in /arm64/bin, and if that fails, look at /mingw32/bin instead.

@jeremyd2019
Copy link
Member

My understanding was that Windows arm64 (aarch64-w64-mingw32) was not supported by gcc, but is by clang. There is a project underway to add entirely clang-based prefixes (like /clang64) and I was kind of hoping this might make building armv7/aarch64 prefixes possible as well. #2278 (comment).

I did a quick brain-dead test adding armv7/aarch64 to the start of building the clang infrastructure (jeremyd2019@b1362de), but it failed to build libc++.

@dennisameling
Copy link
Author

Interesting - thanks for your comment. We'll try to focus on using mingw32 packages on arm64 for now (through emulation), with the only exception of git-wrapper which will find the native git.exe from the Git for Windows project. PR: git-for-windows/MINGW-packages#44

I'll keep an eye on your progress with Clang and will close this PR for now. Thanks again and let's keep each other posted on our progress 🚀

@Biswa96
Copy link
Member

Biswa96 commented Dec 28, 2020

It is possible to compile for aarch64-w64-mingw32 target using this llvm-mingw toolchain https://github.com/mstorsjo/llvm-mingw. I have already used that to compile some mingw packages (e.g. mesa-demos in Windows 10 ARM). I have suggested to use a separate folder (e.g. mingwarm64) in Gitter but maintainers are not happy with it @lazka

@jeremyd2019
Copy link
Member

I think a new folder/prefix is going to be the only way to go, but naming is always an issue.

@pokemon973
Copy link

pokemon973 commented Jan 8, 2021

It is possible to compile for aarch64-w64-mingw32 target using this llvm-mingw toolchain https://github.com/mstorsjo/llvm-mingw. I have already used that to compile some mingw packages (e.g. mesa-demos in Windows 10 ARM). I have suggested to use a separate folder (e.g. mingwarm64) in Gitter but maintainers are not happy with it @lazka

@Biswa96 How would i build the package??
From the "PKGBUILD"??
What should change in the "PKGBUILD" for "ARM64"?
(sorry for bad english)

Thanks you!

@Biswa96
Copy link
Member

Biswa96 commented Jan 8, 2021

It is not possible right now as I have not added my experiments here. Also my thoughts are not compatible with the cross-compilation methodology in msys2 environment.

@pokemon973
Copy link

pokemon973 commented Jan 8, 2021

So it is not possible currently?
What are the changes that you did?

@Biswa96
Copy link
Member

Biswa96 commented Jan 8, 2021

Maybe. @jeremyd2019 is doing the work so he has better info. If you want to compile Windows ARM64 binaries you still can with llvm-mingw but it'll be not is packaged format. e.g. VLC uses llvm-mingw for that.

@pokemon973
Copy link

OK, thank you very much for the help!

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