From 37aca556cece1d6ab7f1405c92f157cdb65d8555 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 30 May 2018 19:10:07 +0100 Subject: [PATCH] Makefile.clangcl: permit building for Windows on Arm. Now we don't have to worry about which windres we're using (or whether another target architecture's windres will do just as well), this is very easy - just test for a couple of extra values of $(Platform). To build on Arm with VS2017 includes and libraries, various blog posts and websites explain that you have to #define a cumbersome macro called _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE, without which the headers will #error at you. But if you do that, then everything seems to compile fine and I actually tested it on an Arm Windows machine today. Also, I had to disable stack protection (/GS-), because clang-cl doesn't yet support the particular form of it for which the VS2017 Arm C library provides the runtime support. Unfortunate in a security application, of course, but there we go. --- mkfiles.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mkfiles.pl b/mkfiles.pl index 1845945a..79ecf9d0 100755 --- a/mkfiles.pl +++ b/mkfiles.pl @@ -526,8 +526,16 @@ if (defined $makefiles{'clangcl'}) { "RCCMD = llvm-rc\n". "ifeq (\$(Platform),x64)\n". "CCTARGET = x86_64-pc-windows-msvc18.0.0\n". + "PLATFORMCFLAGS =\n". + "else ifeq (\$(Platform),arm)\n". + "CCTARGET = arm-pc-windows-msvc18.0.0\n". + "PLATFORMCFLAGS = /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /GS-\n". + "else ifeq (\$(Platform),arm64)\n". + "CCTARGET = arm64-pc-windows-msvc18.0.0\n". + "PLATFORMCFLAGS = /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /GS-\n". "else\n". "CCTARGET = i386-pc-windows-msvc18.0.0\n". + "PLATFORMCFLAGS =\n". "endif\n". "CC = \$(CCCMD) --target=\$(CCTARGET)\n". "RC = \$(RCCMD) /c 1252 \n". @@ -539,7 +547,7 @@ if (defined $makefiles{'clangcl'}) { (join " ", map {"-I$dirpfx$_"} @srcdirs) . " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500 ". "/D_CRT_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS"). - "\n". + " \$(PLATFORMCFLAGS)\n". "LFLAGS = /incremental:no /dynamicbase /nxcompat\n". &splitline("RCPPFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs). " -DWIN32 -D_WIN32 -DWINVER=0x0400")." \$(RCFL)\n".