[PATCH] Add support for building for windows on aarch64

Martin Storsjö martin at martin.st
Wed Apr 18 19:11:24 UTC 2018

On Wed, 18 Apr 2018, Niels Möller wrote:

> Martin Storsjö <martin at martin.st> writes:
>> The attached patch fixes building GMP for windows on aarch64 using the
>> llvm-mingw toolchain (clang with a mingw sdk, built on top of llvm
>> tools).
> Looks good to me, just a few questions.

Thanks for taking a look!

> What machines run windows on aarch64, windows phones or also more
> general computers? Are you cross compiling only, or can you compile
> natively on these machines?

It's mostly general computers; HP and ASUS have announced devices running 
this, that are more or less out for sale now, e.g. 

IIRC, it's also supposed to come to servers, but I don't have any 
references handy for that right now.

I'm mainly cross compiling (with clang, and with MSVC although I haven't 
tested building GMP with that), but clang itself can also be built to run 
directly on such a device.

> I imagine the change isn't really compiler specific, you'd need the same
> to cross compile using gcc (if gcc and mingw support this target?).

Indeed, all windows variants on 64 bit have kept long at 32 bit, so it 
would be the same for all of them.

In practice, gcc doesn't support windows on arm or arm64 (yet) though, 
while llvm/clang does now (arm since a couple years and arm64 since the 
last 9 months or so).

>> The main issue is, just like on x86_64, "long" still is 32 bit, while
>> the current configure check on arm/aarch64 checks that sizeof(long) ==
>> 8 in order to use a 64 bit ABI. (On x86_64, no such check is
>> executed.) The patch changes the check to test sizeof(void*) instead.
> I'm a bit curious as to why it's different on x86_64; there we only have
> a test of $host matching *-*-mingw or *-*-cygwin, and set
> limb64=longlong in that case.

I'm also not quite sure about this. This was introduced in 
https://gmplib.org/repo/gmp/rev/a20eda8bdd36, but I'm not so familiar to 
all the details of this configure script and GMP, and how the situation on 
arm differs from x86.

> On arm, do we rely on the compiler's default abi, so we need the
> any_*_testlist to detect that? I see no use of -m32/-m64 in the arm
> section, but I may be missing something.

In general, arm vs aarch64 is much more seen as two different 
architectures, so e.g. a build of gcc (for the OSes that gcc supports) 
don't have -m32/-m64 for switching, but you need a completely different 
build of gcc for each of them.

// Martin

More information about the gmp-devel mailing list