EmulatorPkg: Enable CLANG9 tool chain
authorLiming Gao <liming.gao@intel.com>
Thu, 17 Oct 2019 06:55:54 +0000 (14:55 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 24 Oct 2019 01:41:34 +0000 (09:41 +0800)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
1. Add WIN_HOST_BUILD macro check for CLANG9 tool chain
build -p EmulatorPkg\EmulatorPkg.dsc -a IA32 -DWIN_HOST_BUILD=TRUE -t CLANG9
build -p EmulatorPkg\EmulatorPkg.dsc -a X64 -DWIN_HOST_BUILD=TRUE -t CLANG9
2. Append CLANG CC and LINK flags to generate windows HOST.
3. Fix WinHost issue to call GetProcessAffinityMask() API.
   The input parameter should be UINTN pointer instead of UINT32 pointer.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
EmulatorPkg/EmulatorPkg.dsc
EmulatorPkg/Win/Host/WinHost.c
EmulatorPkg/Win/Host/WinHost.inf

index 20f1187..109685b 100644 (file)
 \r
 [Components]\r
 !if "IA32" in $(ARCH) || "X64" in $(ARCH)\r
-  !if "MSFT" in $(FAMILY)\r
+  !if "MSFT" in $(FAMILY) || $(WIN_HOST_BUILD) == TRUE\r
     ##\r
     #  Emulator, OS WIN application\r
+    #  CLANG9 is cross OS tool chain. It depends on WIN_HOST_BUILD flag\r
+    #  to build WinHost application.\r
     ##\r
     EmulatorPkg/Win/Host/WinHost.inf\r
   !else\r
 \r
   MSFT:DEBUG_*_*_CC_FLAGS = /Od /Oy-\r
   MSFT:NOOPT_*_*_CC_FLAGS = /Od /Oy-\r
+  GCC:DEBUG_CLANG9_*_CC_FLAGS =-O0 -Wno-unused-command-line-argument -Wno-incompatible-pointer-types -Wno-enum-conversion -Wno-incompatible-pointer-types -Wno-sometimes-uninitialized -Wno-constant-conversion -Wno-main-return-type\r
 \r
   MSFT:*_*_*_DLINK_FLAGS     = /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE\r
   MSFT:DEBUG_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000\r
   MSFT:NOOPT_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000\r
+\r
+!if $(WIN_HOST_BUILD) == TRUE\r
+  #\r
+  # CLANG9 tool chain depends on WIN_HOST_BUILD flag to generate the windows application.\r
+  #\r
+  GCC:*_CLANG9_*_DLINK_FLAGS     = /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE\r
+  GCC:DEBUG_CLANG9_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000\r
+  GCC:NOOPT_CLANG9_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000\r
+!endif\r
index 9aba3c8..62a89f7 100644 (file)
@@ -356,7 +356,7 @@ Returns:
 INTN\r
 EFIAPI\r
 main (\r
-  IN  INTN  Argc,\r
+  IN  INT  Argc,\r
   IN  CHAR8 **Argv,\r
   IN  CHAR8 **Envp\r
   )\r
@@ -391,8 +391,8 @@ Returns:
   VOID                  *SecFile;\r
   CHAR16                *MemorySizeStr;\r
   CHAR16                *FirmwareVolumesStr;\r
-  UINT32                ProcessAffinityMask;\r
-  UINT32                SystemAffinityMask;\r
+  UINT                ProcessAffinityMask;\r
+  UINT                SystemAffinityMask;\r
   INT32                 LowBit;\r
 \r
   //\r
@@ -414,7 +414,7 @@ Returns:
   // Determine the first thread available to this process.\r
   //\r
   if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask, &SystemAffinityMask)) {\r
-    LowBit = (INT32)LowBitSet32 (ProcessAffinityMask);\r
+    LowBit = (INT32)LowBitSet32 ((UINT32)ProcessAffinityMask);\r
     if (LowBit != -1) {\r
       //\r
       // Force the system to bind the process to a single thread to work\r
index 631d5a6..1adca10 100644 (file)
@@ -95,3 +95,9 @@
   MSFT:*_VS2017_X64_DLINK_FLAGS      = /LIBPATH:"%VCToolsInstallDir%lib\x64" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib\r
   MSFT:*_*_X64_ASM_FLAGS            == /nologo /W3 /WX /c /Cx /Zd /W0 /Zi\r
   MSFT:*_*_X64_ASMLINK_FLAGS        == /link /nologo\r
+\r
+  GCC:*_CLANG9_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\$(BASE_NAME).exe" /base:0x10000000 /pdb:"$(BIN_DIR)\$(BASE_NAME).pdb"  /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /LIBPATH:"%VCToolsInstallDir%lib\x64"   /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086  /OPT:REF /DEBUG /MACHINE:AMD64 Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib /lldmap  /EXPORT:InitializeDriver=_ModuleEntryPoint\r
+  GCC:*_CLANG9_X64_CC_FLAGS == -m64 -g -fshort-wchar -fno-strict-aliasing -Wall -c -include AutoGen.h -D _CRT_SECURE_NO_WARNINGS -Wnonportable-include-path  -D UNICODE -D _CRT_SECURE_NO_DEPRECATE\r
+\r
+  GCC:*_CLANG9_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\$(BASE_NAME).exe" /base:0x10000000 /pdb:"$(BIN_DIR)\$(BASE_NAME).pdb" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x86" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x86" /LIBPATH:"%VCToolsInstallDir%ib\x86"   /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086  /OPT:REF /DEBUG /MACHINE:I386 Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib /lldmap  /EXPORT:InitializeDriver=_ModuleEntryPoint\r
+  GCC:*_CLANG9_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -c -include AutoGen.h -D _CRT_SECURE_NO_WARNINGS -Wnonportable-include-path  -D UNICODE -D _CRT_SECURE_NO_DEPRECATE\r