[llvm-dev] Showcase of the Windows/ARM64/MinGW target

201 views
Skip to first unread message

Martin Storsjö via llvm-dev

unread,
May 21, 2018, 5:34:18 AM5/21/18
to llvm...@lists.llvm.org
Hi,

At the Build conference recently, Microsoft had a session about Windows on
ARM(64), [1]. As case example of a large, nontrivial app rebuilt for this
arch, they demonstrated VLC.

The presentation claimed that this was built with MSVC, with zero changes
to the source.

This actually isn't true; the app that was demonstrated was actually built
with Clang and LLD with mingw-w64 as SDK (and there had been quite a few
minor fixes throughout the codebase to make it all build both with
clang/libc++ for windows, and for windows on non x86 targets).

Despite the pretty drastic miscommunication, I think it was nice to have
at least the output from these tools demonstrated. (The presenter was
reminded about how it actually was built after the presentation;
apparently this information had been lost somewhere along the chain.)

And as a fun fact, it can be mentioned that a large amout of the
windows/arm64 support in LLVM/LLD was developed before I even had access
to this OS for testing, or even MSVC for reference - most of it was
developed and tested just with wine (bootstrapped from a handful of
reference windows/arm64 binaries).

Thanks to everybody who have helped make this happen!

// Martin

[1] https://www.youtube.com/watch?v=vdYIaUeZnqc

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Hayden Livingston via llvm-dev

unread,
May 21, 2018, 6:15:30 AM5/21/18
to Martin Storsjö, LLVM Developers Mailing List
So are you saying that LLVM can be built as ARM64 on Windows now?
CMake doesn't show me an option for ARM64 when using MSVC on Windows.
I have the latest CMake.

Martin Storsjö via llvm-dev

unread,
May 21, 2018, 6:38:12 AM5/21/18
to Hayden Livingston, LLVM Developers Mailing List
On Mon, 21 May 2018, Hayden Livingston wrote:

> So are you saying that LLVM can be built as ARM64 on Windows now?
> CMake doesn't show me an option for ARM64 when using MSVC on Windows.
> I have the latest CMake.

I'm saying that LLVM can produce code for the Windows/ARM64 target.

As for compiling LLVM itself to run on ARM64 on Windows, I don't know how
to configure MSVC to do that; MSVC doesn't install the ARM64 compiler by
default but you manually need to check a box in the installer (available
since 15.4, and more intended for actual public use since the 15.8
preview). No idea how you configure that in CMake.

You can build LLVM+Clang for ARM64 with Clang/mingw-w64/libcxx though,
with the same toolchain used to build VLC in that demo.

// Martin

Hayden Livingston via llvm-dev

unread,
May 21, 2018, 6:40:41 AM5/21/18
to Martin Storsjö, LLVM Developers Mailing List
Ok. How much work was it to enable ARM64 codegen? Is it is
significantly more work than for Linux targets? Are there any special
relocations in ARM64 land?

Martin Storsjö via llvm-dev

unread,
May 21, 2018, 6:53:57 AM5/21/18
to Hayden Livingston, LLVM Developers Mailing List
On Mon, 21 May 2018, Hayden Livingston wrote:

> Ok. How much work was it to enable ARM64 codegen? Is it is
> significantly more work than for Linux targets? Are there any special
> relocations in ARM64 land?

It was surprisingly little work, I'd say. Yes, Windows uses COFF, and
there's a separate set of relocations for each architecture. Probably not
more work than for Linux targets, but just new things to implement.

The initial commits for ARM64 in COFF were done by Mandeep Singh Grang,
and after that, there were a few details to fill in about how the
relocations are supposed to behave. The public documentation only names
them, but luckily link.exe supported those relocations since long ago, so
I was able to use llvm-mc together with link.exe to figure out how e.g.
the IMAGE_REL_ARM64_REL21/IMAGE_REL_ARM64_PAGEOFFSET_12A relocation pairs
are supposed to handle overflow/carry.

Other than relocations, the main bits were varargs handling, hooking up
small flags and bits here and there as you find what's missing, minor
windows/coff specific details like linker directives and dllimport
handling, and slightly larger things such as stack probing and TLS.

Reid Kleckner via llvm-dev

unread,
May 21, 2018, 1:17:12 PM5/21/18
to Martin Storsjö, llvm-dev
On Mon, May 21, 2018 at 3:54 AM Martin Storsjö via llvm-dev <llvm...@lists.llvm.org> wrote:
Other than relocations, the main bits were varargs handling, hooking up
small flags and bits here and there as you find what's missing, minor
windows/coff specific details like linker directives and dllimport
handling, and slightly larger things such as stack probing and TLS.

Or, you know, just all the things. :)

Congrats on the demo! 

Martin Storsjö via llvm-dev

unread,
May 21, 2018, 2:21:50 PM5/21/18
to Reid Kleckner, llvm-dev
Hah, well, at least the non-vararg calling convention is (as far as I know
this far) the same as on other platforms - unlike on x86_64, where
everything differs.

Or maybe put another way; the ARM64 related bits wasn't all that much
work, compared to everything related to MinGW.

> Congrats on the demo! 

Thanks!

// Martin
Reply all
Reply to author
Forward
0 new messages