I was under impression that mingw-win64 can be used for X64 AND IA32 builds.
On Fri, Oct 3, 2014 at 9:19 AM, Scott Duplichan <sc...@notabs.org> wrote: > Here is a work in progress patch for those building X64 or IA32 targets > from Windows. It allows building with gcc instead of a Microsoft compiler. > Building has been tested with Windows 7 x64 using MINGW archives from > http://www.drangon.org/mingw/ or > http://sourceforge.net/projects/mingw-w64-dgn/files/mingw-w64/ > > Unpack mingw-w32-bin-i686-20140425.7z and set environment variable > mingw32 to its path. > > Unpack mingw-w64-bin-x86_64-20140425.7z and set environment variable > mingw64 to its path. > > Apply the patch then build using -t MINGW. It's that easy. No unix > shell port is involved. Just build from a cmd.exe prompt as normal. > Because mingw requires no install or setup, your registry, path and > other environment variables are unaffected. > > The MINGW port of gcc brings C99 support to those using Windows to > develop EDK2 code. Wouldn't it be nice if one day UEFI could drop > support for non-C99 compilers so that C99 features could be used in > the code? There is actually a lot of work to be done before gcc could > replace Microsoft tools. One problem is that some UEFI source level > debuggers understand only Microsoft debug information. Another > problem is that right now gcc is producing bigger code. Getting gcc link > time optimization working may solve this problem. Build speed with MINGW > is not quite as fast as with Microsoft tools, but it is reasonable. > For example, a test of 18 builds that takes 523 seconds using VS2008 > takes 694 seconds using MINGW. > > Here are build test results. Failing builds: > build.exe -p D:\uefi\buildtest-011\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t > MINGW -n 16 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB > build.exe -p D:\uefi\buildtest-011\edk2\OvmfPkg\OvmfPkgIA32X64.dsc -b DEBUG > -t MINGW -n 16 -a IA32 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB > These fail because 'the required fv image size 0x80ce50 exceeds the set fv > image size 0x800000' > > Here are passing results: > build.exe -p D:\uefi\buildtest-011\edk2\OvmfPkg\OvmfPkgX64.dsc -b RELEASE -t > MINGW -n 16 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB > build.exe -p D:\uefi\buildtest-011\edk2\OvmfPkg\OvmfPkgIA32.dsc -b DEBUG -t > MINGW -n 16 -a IA32 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB > build.exe -p D:\uefi\buildtest-011\edk2\OvmfPkg\OvmfPkgIA32.dsc -b RELEASE -t > MINGW -n 16 -a IA32 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB > build.exe -p D:\uefi\buildtest-011\edk2\OvmfPkg\OvmfPkgIA32X64.dsc -b RELEASE > -t MINGW -n 16 -a IA32 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB > build.exe -p D:\uefi\buildtest-011\edk2\AppPkg\AppPkg.dsc -b DEBUG -t MINGW > -n 16 -a X64 > build.exe -p D:\uefi\buildtest-011\edk2\AppPkg\AppPkg.dsc -b RELEASE -t MINGW > -n 16 -a X64 > build.exe -p D:\uefi\buildtest-011\edk2\AppPkg\AppPkg.dsc -b DEBUG -t MINGW > -n 16 -a IA32 > build.exe -p D:\uefi\buildtest-011\edk2\AppPkg\AppPkg.dsc -b RELEASE -t MINGW > -n 16 -a IA32 > build.exe -p D:\uefi\buildtest-011\edk2\IntelFspPkg\IntelFspPkg.dsc -b DEBUG > -t MINGW -n 16 -a IA32 > build.exe -p D:\uefi\buildtest-011\edk2\IntelFspPkg\IntelFspPkg.dsc -b > RELEASE -t MINGW -n 16 -a IA32 > build.exe -p D:\uefi\buildtest-011\edk2\DuetPkg\DuetPkgX64.dsc -b DEBUG -t > MINGW -n 16 -a X64 > build.exe -p D:\uefi\buildtest-011\edk2\DuetPkg\DuetPkgIA32.dsc -b DEBUG -t > MINGW -n 16 -a IA32 > build.exe -p D:\uefi\buildtest-011\edk2\ShellPkg\ShellPkg.dsc -b DEBUG -t > MINGW -n 16 -a X64 > build.exe -p D:\uefi\buildtest-011\edk2\ShellPkg\ShellPkg.dsc -b RELEASE -t > MINGW -n 16 -a X64 > build.exe -p D:\uefi\buildtest-011\edk2\ShellPkg\ShellPkg.dsc -b DEBUG -t > MINGW -n 16 -a IA32 > build.exe -p D:\uefi\buildtest-011\edk2\ShellPkg\ShellPkg.dsc -b RELEASE -t > MINGW -n 16 -a IA32 > > For a test using real hardware, I used the Duet project and ASRock E350M1 > motherboard. A > modified Duet was used (http://notabs.org/coreboot/duet-payload/index.htm) > because the > standard Duet has some problems on real hardware, and because the code size > is too big > when gcc is used. This test passes. > > Here are some notes about the patch: > 1) IPF is not supported. > 2) 32-bit target code builds, but has not been tested. > 3) Code size is a little big, causing problems with projects such as Duet. > Getting the gcc -flto option to work might make the code size similar to > that of the Microsoft tools. > 4) GenMake.py had to be patched to fix a back/forward slash issue. > 5) Lack of weak external support made the EfiSocketLib build fail. The > patch works around the problem. > 6) The new Thunk16.nasm causes ld to crash. The patch reverts back to > Thunk16.S > for now. A better solution to this problem must be found. > 7) StdLib\Include\X64\machine\limits.h assumes long int has 64 bits any time > __GNUC__ is defined. The patch fixes this for the MINGW case. > > > > Index: BaseTools/Conf/tools_def.template > =================================================================== > --- BaseTools/Conf/tools_def.template (revision 16190) > +++ BaseTools/Conf/tools_def.template (working copy) > @@ -4815,6 +4815,99 @@ > > > #################################################################################### > # > +# Mingw GCC And Intel ACPI Compiler > +# > +#################################################################################### > +# MINGW - MINGW GCC > +# ASL - Intel ACPI Source Language Compiler (iasl.exe) > +*_MINGW_*_*_FAMILY = GCC > + > +DEFINE MINGW_BINIA32 = ENV(MINGW32)\bin\ > +DEFINE MINGW_BINX64 = ENV(MINGW64)\bin\ > + > +*_MINGW_*_MAKE_PATH = ENV(MS_MISC_BIN)\nmake.exe > +*_MINGW_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN) > +*_MINGW_IA32_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry > _$(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20 -Map > $(DEST_DIR_DEBUG)/$(BASE_NAME).map --image-base=0 --strip-all > +*_MINGW_X64_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry > $(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20 -Map > $(DEST_DIR_DEBUG)/$(BASE_NAME).map --image-base=0 --strip-all > +*_MINGW_IA32_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry > _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) --strip-all > +*_MINGW_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry > ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) --strip-all > + > +*_MINGW_*_MAKE_FLAGS = /nologo > +*_MINGW_*_ASM_FLAGS = DEF(GCC_ASM_FLAGS) > +*_MINGW_*_PP_FLAGS = DEF(GCC_PP_FLAGS) > +*_MINGW_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) > +*_MINGW_*_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) > +*_MINGW_*_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) > +*_MINGW_*_APP_FLAGS = > +*_MINGW_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS) > +*_MINGW_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS) > + > +################## > +# IA32 definitions > +################## > +*_MINGW_IA32_CC_PATH = DEF(MINGW_BINIA32)gcc > +*_MINGW_IA32_SLINK_PATH = DEF(MINGW_BINIA32)ar > +*_MINGW_IA32_DLINK_PATH = DEF(MINGW_BINIA32)ld > +*_MINGW_IA32_ASM_PATH = DEF(MINGW_BINIA32)gcc > +*_MINGW_IA32_PP_PATH = DEF(MINGW_BINIA32)gcc > +*_MINGW_IA32_APP_PATH = DEF(MINGW_BINIA32)gcc > +*_MINGW_IA32_VFRPP_PATH = DEF(MINGW_BINIA32)gcc > +*_MINGW_IA32_ASLCC_PATH = DEF(MINGW_BINIA32)gcc > +*_MINGW_IA32_ASLPP_PATH = DEF(MINGW_BINIA32)gcc > +*_MINGW_IA32_ASLDLINK_PATH = DEF(MINGW_BINIA32)ld > +*_MINGW_IA32_RC_PATH = ENV(MS_MISC_BIN)\rc.exe > +*_MINGW_IA32_OBJCOPY_PATH = DEF(MINGW_BINIA32)objcopy > + > +###*_MINGW_*_SYMRENAME_PATH = rem > +*_MINGW_IA32_SYMRENAME_PATH = DEF(MINGW_BINIA32)objcopy > + > +*_MINGW_IA32_OBJCOPY_FLAGS = --remove-section .idata --remove-section > .edata > +*_MINGW_IA32_SYMRENAME_FLAGS = --remove-section .idata --remove-section > .edata > + > +*_MINGW_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -Os -m32 > -malign-double -mno-stack-arg-probe -fomit-frame-pointer -Wno-error > +*_MINGW_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS) > +*_MINGW_IA32_NASM_FLAGS = -f elf32 > + > +################## > +# X64 definitions > +################## > +*_MINGW_X64_CC_PATH = DEF(MINGW_BINX64)gcc > +*_MINGW_X64_SLINK_PATH = DEF(MINGW_BINX64)ar > +*_MINGW_X64_DLINK_PATH = DEF(MINGW_BINX64)ld > +*_MINGW_X64_ASM_PATH = DEF(MINGW_BINX64)gcc > +*_MINGW_X64_PP_PATH = DEF(MINGW_BINX64)gcc > +*_MINGW_X64_APP_PATH = DEF(MINGW_BINX64)gcc > +*_MINGW_X64_VFRPP_PATH = DEF(MINGW_BINX64)gcc > +*_MINGW_X64_ASLCC_PATH = DEF(MINGW_BINX64)gcc > +*_MINGW_X64_ASLPP_PATH = DEF(MINGW_BINX64)gcc > +*_MINGW_X64_ASLDLINK_PATH = DEF(MINGW_BINX64)ld > +*_MINGW_IA32_RC_PATH = ENV(MS_MISC_BIN)\rc.exe > +*_MINGW_X64_OBJCOPY_PATH = DEF(MINGW_BINX64)objcopy > + > +*_MINGW_X64_CC_FLAGS = DEF(GCC_X64_CC_FLAGS) -Wno-error > +*_MINGW_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS) > +*_MINGW_X64_OBJCOPY_FLAGS = --remove-section .pdata --remove-section > .xdata > +*_MINGW_X64_*_SYMRENAME_FLAGS = --remove-section .pdata --remove-section > .xdata > +*_MINGW_X64_NASM_FLAGS = -f elf64 > + > +################## > +# EBC definitions > +################## > +*_MINGW_EBC_*_FAMILY = INTEL > + > +*_MINGW_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe > +*_MINGW_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe > +*_MINGW_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe > +*_MINGW_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe > +*_MINGW_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe > +*_MINGW_EBC_RC_PATH = ENV(MS_MISC_BIN)\rc.exe > + > +*_MINGW_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h > /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT) > +*_MINGW_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC > +*_MINGW_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" > /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) > /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /ALIGN:32 /DRIVER > + > +#################################################################################### > +# > # Elf GCC - This configuration is used to compile on Linux boxes to produce > elf > # binaries. > # > Index: BaseTools/Source/Python/AutoGen/GenMake.py > =================================================================== > --- BaseTools/Source/Python/AutoGen/GenMake.py (revision 16190) > +++ BaseTools/Source/Python/AutoGen/GenMake.py (working copy) > @@ -679,7 +679,11 @@ > NewFile = self.PlaceMacro(str(F), self.Macros) > # In order to use file list macro as dependency > if T.GenListFile: > - self.ListFileMacros[T.ListFileMacro].append(str(F)) > + # gnu tools need forward slash path separater, even > on Windows > + if self.PlatformInfo.ToolChainFamily in ('GCC'): > + > self.ListFileMacros[T.ListFileMacro].append(str(F).replace ('\\', '/')) > + else: > + > self.ListFileMacros[T.ListFileMacro].append(str(F)) > self.FileListMacros[T.FileListMacro].append(NewFile) > elif T.GenFileListMacro: > self.FileListMacros[T.FileListMacro].append(NewFile) > Index: MdePkg/Library/BaseLib/BaseLib.inf > =================================================================== > --- MdePkg/Library/BaseLib/BaseLib.inf (revision 16190) > +++ MdePkg/Library/BaseLib/BaseLib.inf (working copy) > @@ -252,7 +252,7 @@ > Ia32/DisableCache.asm | INTEL > > Ia32/GccInline.c | GCC > - Ia32/Thunk16.nasm | GCC > + Ia32/Thunk16.S | GCC > Ia32/EnableDisableInterrupts.S | GCC > Ia32/EnablePaging64.S | GCC > Ia32/DisablePaging32.S | GCC > @@ -405,7 +405,7 @@ > X86DisablePaging64.c > X86DisablePaging32.c > X64/GccInline.c | GCC > - X64/Thunk16.nasm | GCC > + X64/Thunk16.S | GCC > X64/SwitchStack.S | GCC > X64/SetJump.S | GCC > X64/LongJump.S | GCC > Index: StdLib/EfiSocketLib/EfiSocketLib.inf > =================================================================== > --- StdLib/EfiSocketLib/EfiSocketLib.inf (revision 16190) > +++ StdLib/EfiSocketLib/EfiSocketLib.inf (working copy) > @@ -68,3 +68,6 @@ > gEfiUdp6ServiceBindingProtocolGuid > gEfiSocketProtocolGuid > gEfiSocketServiceBindingProtocolGuid > + > +[BuildOptions] > + GCC:*_MINGW_*_CC_FLAGS = -D__attribute__(weak)= > Index: StdLib/Include/X64/machine/limits.h > =================================================================== > --- StdLib/Include/X64/machine/limits.h (revision 16190) > +++ StdLib/Include/X64/machine/limits.h (working copy) > @@ -2,7 +2,7 @@ > > #define __POINTER_BIT 64 > > -#if defined(__GNUC__) > +#if defined(__GNUC__) && !defined(_WIN32) > #if __GNUC_PREREQ__(4,4) > #define __LONG_BIT 64 > > -- > Thanks, > Scott > > > ------------------------------------------------------------------------------ > Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer > Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports > Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper > Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer > http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/edk2-devel > ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel