Re: [edk2-devel] [PATCH v3] ArmVirtPkg: increase FD/FV size for NOOPT builds

2019-09-13 Thread Ard Biesheuvel
On Fri, 13 Sep 2019 at 13:44, Laszlo Ersek  wrote:
>
> On 09/12/19 18:58, Ard Biesheuvel wrote:
> > After upgrading the CI system we use for building the ArmVirtPkg
> > targets, we started seeing failures due to the NOOPT build running
> > out of space when using the CLANG38 toolchain definition combined
> > with clang 7.
> >
> > We really don't want to increase the FD/FV sizes in general to
> > accommodate this, so parameterize the relevant quantities and
> > increase them by 50% for NOOPT builds.
> >
> > Signed-off-by: Ard Biesheuvel 
> > ---
> > v3: - don't rely on fragile ordering of DEFINEs for the target dependent
> >   default value, but instead, use a single FD_SIZE_IN_MB macro whose
> >   default is DEFINEd either to 2 or 3 depend on the build target. That
> >   permits switching back to 2 MB for NOOPT builds if desired while
> >   changing the default to 3 MB
> > - fix a few image header definitions that I missed for ARM32 + Xen
> >
> > v2: implement suggestions by Laszlo on 1) how to parameterize this further,
> > and b) to avoid adding another .inc file
> > update kernel header field, as pointed out by Philippe
> >
> >
> >  ArmVirtPkg/ArmVirt.dsc.inc   | 15 
> >  ArmVirtPkg/ArmVirtQemu.fdf   | 14 +---
> >  ArmVirtPkg/ArmVirtQemuKernel.fdf | 24 +---
> >  ArmVirtPkg/ArmVirtXen.fdf| 24 +---
> >  4 files changed, 68 insertions(+), 9 deletions(-)
> >
> > diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> > index a4ae25d982a2..10037c938eb8 100644
> > --- a/ArmVirtPkg/ArmVirt.dsc.inc
> > +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> > @@ -10,6 +10,21 @@
> >  [Defines]
> >DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x804F
> >
> > +!if $(TARGET) != NOOPT
> > +  DEFINE FD_SIZE_IN_MB= 2
> > +!else
> > +  DEFINE FD_SIZE_IN_MB= 3
> > +!endif
> > +
> > +!if $(FD_SIZE_IN_MB) == 2
> > +  DEFINE FD_SIZE  = 0x20
> > +  DEFINE FD_NUM_BLOCKS= 0x200
> > +!endif
> > +!if $(FD_SIZE_IN_MB) == 3
> > +  DEFINE FD_SIZE  = 0x30
> > +  DEFINE FD_NUM_BLOCKS= 0x300
> > +!endif
> > +
> >  
> > [BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION]
> >GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> >
> > diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf
> > index c2169cb7964b..2c8936a1ae15 100644
> > --- a/ArmVirtPkg/ArmVirtQemu.fdf
> > +++ b/ArmVirtPkg/ArmVirtQemu.fdf
> > @@ -20,14 +20,22 @@
> >  #
> >  
> > 
> >
> > +[Defines]
> > +!if $(FD_SIZE_IN_MB) == 2
> > +  DEFINE FVMAIN_COMPACT_SIZE  = 0x1ff000
> > +!endif
> > +!if $(FD_SIZE_IN_MB) == 3
> > +  DEFINE FVMAIN_COMPACT_SIZE  = 0x2ff000
> > +!endif
> > +
> >  [FD.QEMU_EFI]
> >  BaseAddress   = 0x|gArmTokenSpaceGuid.PcdFdBaseAddress  # QEMU 
> > assigns 0 - 0x800 for a BootROM
> > -Size  = 0x0020|gArmTokenSpaceGuid.PcdFdSize # The size 
> > in bytes of the FLASH Device
> > +Size  = $(FD_SIZE)|gArmTokenSpaceGuid.PcdFdSize # The size 
> > in bytes of the FLASH Device
> >  ErasePolarity = 1
> >
> >  # This one is tricky, it must be: BlockSize * NumBlocks = Size
> >  BlockSize = 0x1000
> > -NumBlocks = 0x200
> > +NumBlocks = $(FD_NUM_BLOCKS)
> >
> >  
> > 
> >  #
> > @@ -59,7 +67,7 @@ DATA = {
> >  !endif
> >  }
> >
> > -0x1000|0x001ff000
> > +0x1000|$(FVMAIN_COMPACT_SIZE)
> >  gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
> >  FV = FVMAIN_COMPACT
> >
> > diff --git a/ArmVirtPkg/ArmVirtQemuKernel.fdf 
> > b/ArmVirtPkg/ArmVirtQemuKernel.fdf
> > index f675b6d65ee1..72fc8dd698f8 100644
> > --- a/ArmVirtPkg/ArmVirtQemuKernel.fdf
> > +++ b/ArmVirtPkg/ArmVirtQemuKernel.fdf
> > @@ -20,14 +20,22 @@
> >  #
> >  
> > 
> >
> > +[Defines]
> > +!if $(FD_SIZE_IN_MB) == 2
> > +  DEFINE FVMAIN_COMPACT_SIZE  = 0x1f8000
> > +!endif
> > +!if $(FD_SIZE_IN_MB) == 3
> > +  DEFINE FVMAIN_COMPACT_SIZE  = 0x2f8000
> > +!endif
> > +
> >  [FD.QEMU_EFI]
> >  BaseAddress   = 0x|gArmTokenSpaceGuid.PcdFdBaseAddress  # QEMU 
> > assigns 0 - 0x800 for a BootROM
> > -Size  = 0x0020|gArmTokenSpaceGuid.PcdFdSize # The size 
> > in bytes of the FLASH Device
> > +Size  = $(FD_SIZE)|gArmTokenSpaceGuid.PcdFdSize # The size 
> > in bytes of the FLASH Device
> >  ErasePolarity = 1
> >
> >  # This one is tricky, it must be: BlockSize * NumBlocks = Size
> >  BlockSize = 0x1000
> > -NumBlocks = 0x200
> > +NumBlocks = $(FD_NUM_BLOCKS)
> >
> >  
> > 
> >  #
> > @@ -56,7 +64,12 @@ DATA = {
> 

Re: [edk2-devel] [PATCH v3] ArmVirtPkg: increase FD/FV size for NOOPT builds

2019-09-13 Thread Laszlo Ersek
On 09/12/19 18:58, Ard Biesheuvel wrote:
> After upgrading the CI system we use for building the ArmVirtPkg
> targets, we started seeing failures due to the NOOPT build running
> out of space when using the CLANG38 toolchain definition combined
> with clang 7.
> 
> We really don't want to increase the FD/FV sizes in general to
> accommodate this, so parameterize the relevant quantities and
> increase them by 50% for NOOPT builds.
> 
> Signed-off-by: Ard Biesheuvel 
> ---
> v3: - don't rely on fragile ordering of DEFINEs for the target dependent
>   default value, but instead, use a single FD_SIZE_IN_MB macro whose
>   default is DEFINEd either to 2 or 3 depend on the build target. That
>   permits switching back to 2 MB for NOOPT builds if desired while
>   changing the default to 3 MB
> - fix a few image header definitions that I missed for ARM32 + Xen
> 
> v2: implement suggestions by Laszlo on 1) how to parameterize this further,
> and b) to avoid adding another .inc file
> update kernel header field, as pointed out by Philippe
> 
> 
>  ArmVirtPkg/ArmVirt.dsc.inc   | 15 
>  ArmVirtPkg/ArmVirtQemu.fdf   | 14 +---
>  ArmVirtPkg/ArmVirtQemuKernel.fdf | 24 +---
>  ArmVirtPkg/ArmVirtXen.fdf| 24 +---
>  4 files changed, 68 insertions(+), 9 deletions(-)
> 
> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> index a4ae25d982a2..10037c938eb8 100644
> --- a/ArmVirtPkg/ArmVirt.dsc.inc
> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> @@ -10,6 +10,21 @@
>  [Defines]
>DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x804F
>  
> +!if $(TARGET) != NOOPT
> +  DEFINE FD_SIZE_IN_MB= 2
> +!else
> +  DEFINE FD_SIZE_IN_MB= 3
> +!endif
> +
> +!if $(FD_SIZE_IN_MB) == 2
> +  DEFINE FD_SIZE  = 0x20
> +  DEFINE FD_NUM_BLOCKS= 0x200
> +!endif
> +!if $(FD_SIZE_IN_MB) == 3
> +  DEFINE FD_SIZE  = 0x30
> +  DEFINE FD_NUM_BLOCKS= 0x300
> +!endif
> +
>  
> [BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>  
> diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf
> index c2169cb7964b..2c8936a1ae15 100644
> --- a/ArmVirtPkg/ArmVirtQemu.fdf
> +++ b/ArmVirtPkg/ArmVirtQemu.fdf
> @@ -20,14 +20,22 @@
>  #
>  
> 
>  
> +[Defines]
> +!if $(FD_SIZE_IN_MB) == 2
> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x1ff000
> +!endif
> +!if $(FD_SIZE_IN_MB) == 3
> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x2ff000
> +!endif
> +
>  [FD.QEMU_EFI]
>  BaseAddress   = 0x|gArmTokenSpaceGuid.PcdFdBaseAddress  # QEMU 
> assigns 0 - 0x800 for a BootROM
> -Size  = 0x0020|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
> +Size  = $(FD_SIZE)|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
>  ErasePolarity = 1
>  
>  # This one is tricky, it must be: BlockSize * NumBlocks = Size
>  BlockSize = 0x1000
> -NumBlocks = 0x200
> +NumBlocks = $(FD_NUM_BLOCKS)
>  
>  
> 
>  #
> @@ -59,7 +67,7 @@ DATA = {
>  !endif
>  }
>  
> -0x1000|0x001ff000
> +0x1000|$(FVMAIN_COMPACT_SIZE)
>  gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
>  FV = FVMAIN_COMPACT
>  
> diff --git a/ArmVirtPkg/ArmVirtQemuKernel.fdf 
> b/ArmVirtPkg/ArmVirtQemuKernel.fdf
> index f675b6d65ee1..72fc8dd698f8 100644
> --- a/ArmVirtPkg/ArmVirtQemuKernel.fdf
> +++ b/ArmVirtPkg/ArmVirtQemuKernel.fdf
> @@ -20,14 +20,22 @@
>  #
>  
> 
>  
> +[Defines]
> +!if $(FD_SIZE_IN_MB) == 2
> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x1f8000
> +!endif
> +!if $(FD_SIZE_IN_MB) == 3
> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x2f8000
> +!endif
> +
>  [FD.QEMU_EFI]
>  BaseAddress   = 0x|gArmTokenSpaceGuid.PcdFdBaseAddress  # QEMU 
> assigns 0 - 0x800 for a BootROM
> -Size  = 0x0020|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
> +Size  = $(FD_SIZE)|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
>  ErasePolarity = 1
>  
>  # This one is tricky, it must be: BlockSize * NumBlocks = Size
>  BlockSize = 0x1000
> -NumBlocks = 0x200
> +NumBlocks = $(FD_NUM_BLOCKS)
>  
>  
> 
>  #
> @@ -56,7 +64,12 @@ DATA = {
>0x01, 0x00, 0x00, 0x10, # code0: adr x1, .
>0xff, 0x1f, 0x00, 0x14, # code1: b 0x8000
>0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, # text_offset: 512 KB
> +!if $(FD_SIZE_IN_MB) == 2
>0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, # 

Re: [edk2-devel] [PATCH v3] ArmVirtPkg: increase FD/FV size for NOOPT builds

2019-09-12 Thread Philippe Mathieu-Daudé
On 9/12/19 6:58 PM, Ard Biesheuvel wrote:
> After upgrading the CI system we use for building the ArmVirtPkg
> targets, we started seeing failures due to the NOOPT build running
> out of space when using the CLANG38 toolchain definition combined
> with clang 7.
> 
> We really don't want to increase the FD/FV sizes in general to
> accommodate this, so parameterize the relevant quantities and
> increase them by 50% for NOOPT builds.
> 
> Signed-off-by: Ard Biesheuvel 
> ---
> v3: - don't rely on fragile ordering of DEFINEs for the target dependent
>   default value, but instead, use a single FD_SIZE_IN_MB macro whose
>   default is DEFINEd either to 2 or 3 depend on the build target. That
>   permits switching back to 2 MB for NOOPT builds if desired while
>   changing the default to 3 MB
> - fix a few image header definitions that I missed for ARM32 + Xen
> 
> v2: implement suggestions by Laszlo on 1) how to parameterize this further,
> and b) to avoid adding another .inc file
> update kernel header field, as pointed out by Philippe
> 
> 
>  ArmVirtPkg/ArmVirt.dsc.inc   | 15 
>  ArmVirtPkg/ArmVirtQemu.fdf   | 14 +---
>  ArmVirtPkg/ArmVirtQemuKernel.fdf | 24 +---
>  ArmVirtPkg/ArmVirtXen.fdf| 24 +---
>  4 files changed, 68 insertions(+), 9 deletions(-)
> 
> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> index a4ae25d982a2..10037c938eb8 100644
> --- a/ArmVirtPkg/ArmVirt.dsc.inc
> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> @@ -10,6 +10,21 @@
>  [Defines]
>DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x804F
>  
> +!if $(TARGET) != NOOPT
> +  DEFINE FD_SIZE_IN_MB= 2
> +!else
> +  DEFINE FD_SIZE_IN_MB= 3
> +!endif
> +
> +!if $(FD_SIZE_IN_MB) == 2
> +  DEFINE FD_SIZE  = 0x20
> +  DEFINE FD_NUM_BLOCKS= 0x200
> +!endif
> +!if $(FD_SIZE_IN_MB) == 3
> +  DEFINE FD_SIZE  = 0x30
> +  DEFINE FD_NUM_BLOCKS= 0x300
> +!endif
> +
>  
> [BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION]
>GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
>  
> diff --git a/ArmVirtPkg/ArmVirtQemu.fdf b/ArmVirtPkg/ArmVirtQemu.fdf
> index c2169cb7964b..2c8936a1ae15 100644
> --- a/ArmVirtPkg/ArmVirtQemu.fdf
> +++ b/ArmVirtPkg/ArmVirtQemu.fdf
> @@ -20,14 +20,22 @@
>  #
>  
> 
>  
> +[Defines]
> +!if $(FD_SIZE_IN_MB) == 2
> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x1ff000
> +!endif
> +!if $(FD_SIZE_IN_MB) == 3
> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x2ff000
> +!endif
> +
>  [FD.QEMU_EFI]
>  BaseAddress   = 0x|gArmTokenSpaceGuid.PcdFdBaseAddress  # QEMU 
> assigns 0 - 0x800 for a BootROM
> -Size  = 0x0020|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
> +Size  = $(FD_SIZE)|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
>  ErasePolarity = 1
>  
>  # This one is tricky, it must be: BlockSize * NumBlocks = Size
>  BlockSize = 0x1000
> -NumBlocks = 0x200
> +NumBlocks = $(FD_NUM_BLOCKS)
>  
>  
> 
>  #
> @@ -59,7 +67,7 @@ DATA = {
>  !endif
>  }
>  
> -0x1000|0x001ff000
> +0x1000|$(FVMAIN_COMPACT_SIZE)
>  gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
>  FV = FVMAIN_COMPACT
>  
> diff --git a/ArmVirtPkg/ArmVirtQemuKernel.fdf 
> b/ArmVirtPkg/ArmVirtQemuKernel.fdf
> index f675b6d65ee1..72fc8dd698f8 100644
> --- a/ArmVirtPkg/ArmVirtQemuKernel.fdf
> +++ b/ArmVirtPkg/ArmVirtQemuKernel.fdf
> @@ -20,14 +20,22 @@
>  #
>  
> 
>  
> +[Defines]
> +!if $(FD_SIZE_IN_MB) == 2
> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x1f8000
> +!endif
> +!if $(FD_SIZE_IN_MB) == 3
> +  DEFINE FVMAIN_COMPACT_SIZE  = 0x2f8000
> +!endif
> +
>  [FD.QEMU_EFI]
>  BaseAddress   = 0x|gArmTokenSpaceGuid.PcdFdBaseAddress  # QEMU 
> assigns 0 - 0x800 for a BootROM
> -Size  = 0x0020|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
> +Size  = $(FD_SIZE)|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
>  ErasePolarity = 1
>  
>  # This one is tricky, it must be: BlockSize * NumBlocks = Size
>  BlockSize = 0x1000
> -NumBlocks = 0x200
> +NumBlocks = $(FD_NUM_BLOCKS)
>  
>  
> 
>  #
> @@ -56,7 +64,12 @@ DATA = {
>0x01, 0x00, 0x00, 0x10, # code0: adr x1, .
>0xff, 0x1f, 0x00, 0x14, # code1: b 0x8000
>0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, # text_offset: 512 KB
> +!if $(FD_SIZE_IN_MB) == 2
>0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,