Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]: BaseTools: BaseTools changes for RISC-V platform.

2019-09-17 Thread Leif Lindholm
On Tue, Sep 17, 2019 at 02:08:53PM +0100, Leif Lindholm wrote:
> > > Please add the requisite support to the GCC5 profile instead. (Which
> > > is not actually for gcc 5, but is effectively GCC5+ - we are still
> > > successfully using it with gcc 9.)
> > 
> > I can try to use GCC5 profile but the toolchain still has to be
> > stick on https://github.com/riscv/riscv-gnu-toolchain @64879b24. We
> > got problem on the version higher than this, system hangs at SEC to
> > PEI transition if use GCC version higher than @64879b24.
> >
> > We will figure it out later.
> 
> I suppose this is fine as long as this is specifically on the
> edk2-staging branch. We will need to resolve it before we bring the
> port to edk2 master.
> 
> I would still like this support to be tweaked to the point where I can
> build with either the Fedora or the Debian packaged cross compiler.
> 
> > So how can I mention this restrictions in tool_def?
> 
> I would suggest the following:
> - The above information in the top-level Readme.md on the staging branch.
> - A single line in the "GCC5 RISCV64 definitions" comment block.
> - Adding the above to the commit message.

Oh, and please add information to that Readme.md on which toolchains
have successfully built this toolchain. Debian's gcc8 fails.

Best Regards,

Leif

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#47375): https://edk2.groups.io/g/devel/message/47375
Mute This Topic: https://groups.io/mt/33137137/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]: BaseTools: BaseTools changes for RISC-V platform.

2019-09-16 Thread Abner Chang



> -Original Message-
> From: Leif Lindholm [mailto:leif.lindh...@linaro.org]
> Sent: Monday, September 9, 2019 7:37 PM
> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> 
> Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]:
> BaseTools: BaseTools changes for RISC-V platform.
> 
> Hi Abner,
> 
> Having actually tried to build things, I have come across a bunch of
> issues with this patch I missed on my (very cursory) ocular review.
> 
> On Wed, Sep 04, 2019 at 06:43:06PM +0800, Abner Chang wrote:
> > BaseTools changes for building EDK2 RISC-V platform.
> > The changes made to build_rule.template is to avoid build errors cause by
> GCC711RISCV tool chain.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Abner Chang 
> > ---
> >  BaseTools/Conf/build_rule.template |   23 +-
> >  BaseTools/Conf/tools_def.template  |  108 +-
> >  BaseTools/Source/C/Common/BasePeCoff.c |   19 +-
> >  BaseTools/Source/C/Common/PeCoffLoaderEx.c |   96 ++
> >  BaseTools/Source/C/GenFv/GenFvInternalLib.c|  281 -
> >  BaseTools/Source/C/GenFw/Elf32Convert.c|6 +-
> >  BaseTools/Source/C/GenFw/Elf64Convert.c|  273 -
> >  BaseTools/Source/C/GenFw/elf_common.h  |   63 ++
> >  .../Source/C/Include/IndustryStandard/PeImage.h|   10 +
> >  BaseTools/Source/Python/Common/DataType.py | 1075
> ++--
> >  10 files changed, 1393 insertions(+), 561 deletions(-)
> >
> > diff --git a/BaseTools/Conf/build_rule.template
> b/BaseTools/Conf/build_rule.template
> > index db06d3a..8e7f6e0 100755
> > --- a/BaseTools/Conf/build_rule.template
> > +++ b/BaseTools/Conf/build_rule.template
> > @@ -145,14 +145,6 @@
> >  
> >  "$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
> >
> > -[C-Header-File]
> > -
> > -*.h, *.H
> > -
> > -
> > -
> > -
> > -
> >  [Assembly-Code-File.COMMON.COMMON]
> >  
> >  ?.asm, ?.Asm, ?.ASM
> > @@ -321,6 +313,21 @@
> >  "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
> >
> >
> > +[Static-Library-File.COMMON.RISCV64, Static-Library-
> File.COMMON.RISCV32]
> > +
> > +*.lib
> > +
> > +
> > +$(MAKE_FILE)
> > +
> > +
> > +$(DEBUG_DIR)(+)$(MODULE_NAME).dll
> > +
> > +
> > +"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH)
> @$(STATIC_LIBRARY_FILES_LIST) --end-group $(DLINK2_FLAGS)
> > +"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
> > +
> > +
> >  [Static-Library-File.USER_DEFINED, Static-Library-File.HOST_APPLICATION]
> >  
> >  *.lib
> > diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> > index 8f0e6cb..36a301a 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -3,7 +3,7 @@
> >  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> >  #  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
> >  #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
> > -#  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> > +#  (C) Copyright 2016-2019 Hewlett Packard Enterprise Development
> LP
> >  #
> >  #  SPDX-License-Identifier: BSD-2-Clause-Patent
> >  #
> > @@ -114,6 +114,12 @@ DEFINE GCC49_X64_PREFIX= ENV(GCC49_BIN)
> >  DEFINE GCC5_IA32_PREFIX= ENV(GCC5_BIN)
> >  DEFINE GCC5_X64_PREFIX = ENV(GCC5_BIN)
> >  DEFINE GCC_HOST_PREFIX = ENV(GCC_HOST_BIN)
> > +#
> > +# RISC-V GCC toolchain
> > +# This is the default directory used when install official riscv-tools.
> > +#
> > +DEFINE GCCRISCV_RISCV32_PREFIX = ENV(GCC_RISCV32_BIN)
> > +DEFINE GCCRISCV_RISCV64_PREFIX = ENV(GCC_RISCV64_BIN)
> 
> If at all possible, I would strongly recommend *not* following the x86
> _BIN example, and instead using ENV(_RISCV64_PREFIX) like
> the ARM/AARCH64 profiles.
> 
> >  DEFINE UNIX_IASL_BIN   = ENV(IASL_PREFIX)iasl
> >  DEFINE WIN_IASL_BIN= ENV(IASL_PREFIX)iasl.exe
> > @@ -236,6 +242,15 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
> >  # Required to build platforms or ACPI tables:
> >  #   Intel(r) ACPI Compiler from
> >  # 

Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]: BaseTools: BaseTools changes for RISC-V platform.

2019-09-16 Thread Abner Chang



> -Original Message-
> From: Leif Lindholm [mailto:leif.lindh...@linaro.org]
> Sent: Thursday, September 5, 2019 11:45 PM
> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> 
> Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]:
> BaseTools: BaseTools changes for RISC-V platform.
> 
> On Wed, Sep 04, 2019 at 06:43:06PM +0800, Abner Chang wrote:
> > BaseTools changes for building EDK2 RISC-V platform.
> > The changes made to build_rule.template is to avoid build errors cause by
> GCC711RISCV tool chain.
> 
> What errors?
-Wl cause build error on GCC711RISCV tool chain. I remember this has been fixed 
on the latest GCC RISC-V toolchain, however, the latest GCC RISC-V brings 
another issue which is the system hangs in the middle of POST and we didn't 
investigate the root cause yet.
> 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Abner Chang 
> > ---
> >  BaseTools/Conf/build_rule.template |   23 +-
> >  BaseTools/Conf/tools_def.template  |  108 +-
> >  BaseTools/Source/C/Common/BasePeCoff.c |   19 +-
> >  BaseTools/Source/C/Common/PeCoffLoaderEx.c |   96 ++
> >  BaseTools/Source/C/GenFv/GenFvInternalLib.c|  281 -
> >  BaseTools/Source/C/GenFw/Elf32Convert.c|6 +-
> >  BaseTools/Source/C/GenFw/Elf64Convert.c|  273 -
> >  BaseTools/Source/C/GenFw/elf_common.h  |   63 ++
> >  .../Source/C/Include/IndustryStandard/PeImage.h|   10 +
> >  BaseTools/Source/Python/Common/DataType.py | 1075
> ++--
> >  10 files changed, 1393 insertions(+), 561 deletions(-)
> >
> > diff --git a/BaseTools/Conf/build_rule.template
> b/BaseTools/Conf/build_rule.template
> > index db06d3a..8e7f6e0 100755
> > --- a/BaseTools/Conf/build_rule.template
> > +++ b/BaseTools/Conf/build_rule.template
> > @@ -145,14 +145,6 @@
> >  
> >  "$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
> >
> > -[C-Header-File]
> > -
> > -*.h, *.H
> > -
> > -
> > -
> > -
> > -
Seems like above was deleted by accident.

> >  [Assembly-Code-File.COMMON.COMMON]
> >  
> >  ?.asm, ?.Asm, ?.ASM
> > @@ -321,6 +313,21 @@
> >  "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
> >
> >
> > +[Static-Library-File.COMMON.RISCV64, Static-Library-
> File.COMMON.RISCV32]
> > +
> > +*.lib
> > +
> > +
> > +$(MAKE_FILE)
> > +
> > +
> > +$(DEBUG_DIR)(+)$(MODULE_NAME).dll
> > +
> > +
> > +"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH)
> @$(STATIC_LIBRARY_FILES_LIST) --end-group $(DLINK2_FLAGS)
> > +"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
> > +
> > +
> >  [Static-Library-File.USER_DEFINED, Static-Library-File.HOST_APPLICATION]
> >  
> >  *.lib
> > diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> > index 8f0e6cb..36a301a 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -3,7 +3,7 @@
> >  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> >  #  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
> >  #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
> > -#  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> > +#  (C) Copyright 2016-2019 Hewlett Packard Enterprise Development
> LP
> >  #
> >  #  SPDX-License-Identifier: BSD-2-Clause-Patent
> >  #
> > @@ -114,6 +114,12 @@ DEFINE GCC49_X64_PREFIX= ENV(GCC49_BIN)
> >  DEFINE GCC5_IA32_PREFIX= ENV(GCC5_BIN)
> >  DEFINE GCC5_X64_PREFIX = ENV(GCC5_BIN)
> >  DEFINE GCC_HOST_PREFIX = ENV(GCC_HOST_BIN)
> > +#
> > +# RISC-V GCC toolchain
> > +# This is the default directory used when install official riscv-tools.
> > +#
> > +DEFINE GCCRISCV_RISCV32_PREFIX = ENV(GCC_RISCV32_BIN)
> 
> I won't complain about adding 32-bit RISC-V things to industry
> standard headers, but apart from that I don't want to see bits of
> 32-bit support trickle through until there is actually a full port
> going in. So please delete all lines including "RISCV32" in this file.
> 
> > +DEFINE GCCRISCV_RISCV64_PREFIX = ENV(GCC_RISCV64_BIN)
> >
> >  DEFINE UNIX_IASL_BIN   = ENV(IASL_PREFIX)iasl
> >  DEFINE WIN_IASL_BIN= EN

Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]: BaseTools: BaseTools changes for RISC-V platform.

2019-09-09 Thread Leif Lindholm
Hi Abner,

Having actually tried to build things, I have come across a bunch of
issues with this patch I missed on my (very cursory) ocular review.

On Wed, Sep 04, 2019 at 06:43:06PM +0800, Abner Chang wrote:
> BaseTools changes for building EDK2 RISC-V platform.
> The changes made to build_rule.template is to avoid build errors cause by 
> GCC711RISCV tool chain.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Abner Chang 
> ---
>  BaseTools/Conf/build_rule.template |   23 +-
>  BaseTools/Conf/tools_def.template  |  108 +-
>  BaseTools/Source/C/Common/BasePeCoff.c |   19 +-
>  BaseTools/Source/C/Common/PeCoffLoaderEx.c |   96 ++
>  BaseTools/Source/C/GenFv/GenFvInternalLib.c|  281 -
>  BaseTools/Source/C/GenFw/Elf32Convert.c|6 +-
>  BaseTools/Source/C/GenFw/Elf64Convert.c|  273 -
>  BaseTools/Source/C/GenFw/elf_common.h  |   63 ++
>  .../Source/C/Include/IndustryStandard/PeImage.h|   10 +
>  BaseTools/Source/Python/Common/DataType.py | 1075 
> ++--
>  10 files changed, 1393 insertions(+), 561 deletions(-)
> 
> diff --git a/BaseTools/Conf/build_rule.template 
> b/BaseTools/Conf/build_rule.template
> index db06d3a..8e7f6e0 100755
> --- a/BaseTools/Conf/build_rule.template
> +++ b/BaseTools/Conf/build_rule.template
> @@ -145,14 +145,6 @@
>  
>  "$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
>  
> -[C-Header-File]
> -
> -*.h, *.H
> -
> -
> -
> -
> -
>  [Assembly-Code-File.COMMON.COMMON]
>  
>  ?.asm, ?.Asm, ?.ASM
> @@ -321,6 +313,21 @@
>  "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
>  
>  
> +[Static-Library-File.COMMON.RISCV64, Static-Library-File.COMMON.RISCV32]
> +
> +*.lib
> +
> +
> +$(MAKE_FILE)
> +
> +
> +$(DEBUG_DIR)(+)$(MODULE_NAME).dll
> +
> +
> +"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH) 
> @$(STATIC_LIBRARY_FILES_LIST) --end-group $(DLINK2_FLAGS)
> +"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
> +
> +
>  [Static-Library-File.USER_DEFINED, Static-Library-File.HOST_APPLICATION]
>  
>  *.lib
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index 8f0e6cb..36a301a 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -3,7 +3,7 @@
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  #  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
>  #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
> -#  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> +#  (C) Copyright 2016-2019 Hewlett Packard Enterprise Development LP
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -114,6 +114,12 @@ DEFINE GCC49_X64_PREFIX= ENV(GCC49_BIN)
>  DEFINE GCC5_IA32_PREFIX= ENV(GCC5_BIN)
>  DEFINE GCC5_X64_PREFIX = ENV(GCC5_BIN)
>  DEFINE GCC_HOST_PREFIX = ENV(GCC_HOST_BIN)
> +#
> +# RISC-V GCC toolchain
> +# This is the default directory used when install official riscv-tools.
> +#
> +DEFINE GCCRISCV_RISCV32_PREFIX = ENV(GCC_RISCV32_BIN)
> +DEFINE GCCRISCV_RISCV64_PREFIX = ENV(GCC_RISCV64_BIN)

If at all possible, I would strongly recommend *not* following the x86
_BIN example, and instead using ENV(_RISCV64_PREFIX) like
the ARM/AARCH64 profiles.

>  DEFINE UNIX_IASL_BIN   = ENV(IASL_PREFIX)iasl
>  DEFINE WIN_IASL_BIN= ENV(IASL_PREFIX)iasl.exe
> @@ -236,6 +242,15 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
>  # Required to build platforms or ACPI tables:
>  #   Intel(r) ACPI Compiler from
>  #   https://acpica.org/downloads
> +#   GCCRISCV- Linux   -  Requires:
> +# RISC-V official release of RISC-V GNU 
> toolchain,
> +#   https://github.com/riscv/riscv-gnu-toolchain 
> @64879b24
> +#   The commit ID 64879b24 is the one can build 
> RISC-V platform and boo to EFI shell.
> +#   Follow the instructions mentioned in 
> README.md to build RISC-V tool change.
> +# Set below environment variables to the RISC-V 
> tool chain binaries before building RISC-V EDK2 port.
> +#   - GCC_RISCV32_BIN
> +#   - GCC_RISCV64_BIN
> +#
>  #   CLANG35 -Linux,Windows-  Requires:
>  # Clang v3.5 or later, and GNU binutils 
> targeting aarch64-linux-gnu or arm-linux-gnueabi
>  #Optional:
> @@ -1806,6 +1821,26 @@ DEFINE GCC5_ARM_ASLDLINK_FLAGS   = 
> DEF(GCC49_ARM_ASLDLINK_FLAGS)
>  DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
>  DEFINE GCC5_ASLCC_FLAGS 

Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]: BaseTools: BaseTools changes for RISC-V platform.

2019-09-05 Thread Leif Lindholm
On Wed, Sep 04, 2019 at 06:43:06PM +0800, Abner Chang wrote:
> BaseTools changes for building EDK2 RISC-V platform.
> The changes made to build_rule.template is to avoid build errors cause by 
> GCC711RISCV tool chain.

What errors?

> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Abner Chang 
> ---
>  BaseTools/Conf/build_rule.template |   23 +-
>  BaseTools/Conf/tools_def.template  |  108 +-
>  BaseTools/Source/C/Common/BasePeCoff.c |   19 +-
>  BaseTools/Source/C/Common/PeCoffLoaderEx.c |   96 ++
>  BaseTools/Source/C/GenFv/GenFvInternalLib.c|  281 -
>  BaseTools/Source/C/GenFw/Elf32Convert.c|6 +-
>  BaseTools/Source/C/GenFw/Elf64Convert.c|  273 -
>  BaseTools/Source/C/GenFw/elf_common.h  |   63 ++
>  .../Source/C/Include/IndustryStandard/PeImage.h|   10 +
>  BaseTools/Source/Python/Common/DataType.py | 1075 
> ++--
>  10 files changed, 1393 insertions(+), 561 deletions(-)
> 
> diff --git a/BaseTools/Conf/build_rule.template 
> b/BaseTools/Conf/build_rule.template
> index db06d3a..8e7f6e0 100755
> --- a/BaseTools/Conf/build_rule.template
> +++ b/BaseTools/Conf/build_rule.template
> @@ -145,14 +145,6 @@
>  
>  "$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
>  
> -[C-Header-File]
> -
> -*.h, *.H
> -
> -
> -
> -
> -
>  [Assembly-Code-File.COMMON.COMMON]
>  
>  ?.asm, ?.Asm, ?.ASM
> @@ -321,6 +313,21 @@
>  "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
>  
>  
> +[Static-Library-File.COMMON.RISCV64, Static-Library-File.COMMON.RISCV32]
> +
> +*.lib
> +
> +
> +$(MAKE_FILE)
> +
> +
> +$(DEBUG_DIR)(+)$(MODULE_NAME).dll
> +
> +
> +"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH) 
> @$(STATIC_LIBRARY_FILES_LIST) --end-group $(DLINK2_FLAGS)
> +"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
> +
> +
>  [Static-Library-File.USER_DEFINED, Static-Library-File.HOST_APPLICATION]
>  
>  *.lib
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index 8f0e6cb..36a301a 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -3,7 +3,7 @@
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  #  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
>  #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
> -#  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> +#  (C) Copyright 2016-2019 Hewlett Packard Enterprise Development LP
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -114,6 +114,12 @@ DEFINE GCC49_X64_PREFIX= ENV(GCC49_BIN)
>  DEFINE GCC5_IA32_PREFIX= ENV(GCC5_BIN)
>  DEFINE GCC5_X64_PREFIX = ENV(GCC5_BIN)
>  DEFINE GCC_HOST_PREFIX = ENV(GCC_HOST_BIN)
> +#
> +# RISC-V GCC toolchain
> +# This is the default directory used when install official riscv-tools.
> +#
> +DEFINE GCCRISCV_RISCV32_PREFIX = ENV(GCC_RISCV32_BIN)

I won't complain about adding 32-bit RISC-V things to industry
standard headers, but apart from that I don't want to see bits of
32-bit support trickle through until there is actually a full port
going in. So please delete all lines including "RISCV32" in this file.

> +DEFINE GCCRISCV_RISCV64_PREFIX = ENV(GCC_RISCV64_BIN)
>  
>  DEFINE UNIX_IASL_BIN   = ENV(IASL_PREFIX)iasl
>  DEFINE WIN_IASL_BIN= ENV(IASL_PREFIX)iasl.exe
> @@ -236,6 +242,15 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
>  # Required to build platforms or ACPI tables:
>  #   Intel(r) ACPI Compiler from
>  #   https://acpica.org/downloads
> +#   GCCRISCV- Linux   -  Requires:
> +# RISC-V official release of RISC-V GNU 
> toolchain,
> +#   https://github.com/riscv/riscv-gnu-toolchain 
> @64879b24
> +#   The commit ID 64879b24 is the one can build 
> RISC-V platform and boo to EFI shell.
> +#   Follow the instructions mentioned in 
> README.md to build RISC-V tool change.
> +# Set below environment variables to the RISC-V 
> tool chain binaries before building RISC-V EDK2 port.
> +#   - GCC_RISCV32_BIN
> +#   - GCC_RISCV64_BIN
> +#
>  #   CLANG35 -Linux,Windows-  Requires:
>  # Clang v3.5 or later, and GNU binutils 
> targeting aarch64-linux-gnu or arm-linux-gnueabi
>  #Optional:
> @@ -1806,6 +1821,26 @@ DEFINE GCC5_ARM_ASLDLINK_FLAGS   = 
> DEF(GCC49_ARM_ASLDLINK_FLAGS)
>  DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
>  DEFINE GCC5_ASLCC_FLAGS  = 

[edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]: BaseTools: BaseTools changes for RISC-V platform.

2019-09-04 Thread Abner Chang
BaseTools changes for building EDK2 RISC-V platform.
The changes made to build_rule.template is to avoid build errors cause by 
GCC711RISCV tool chain.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Abner Chang 
---
 BaseTools/Conf/build_rule.template |   23 +-
 BaseTools/Conf/tools_def.template  |  108 +-
 BaseTools/Source/C/Common/BasePeCoff.c |   19 +-
 BaseTools/Source/C/Common/PeCoffLoaderEx.c |   96 ++
 BaseTools/Source/C/GenFv/GenFvInternalLib.c|  281 -
 BaseTools/Source/C/GenFw/Elf32Convert.c|6 +-
 BaseTools/Source/C/GenFw/Elf64Convert.c|  273 -
 BaseTools/Source/C/GenFw/elf_common.h  |   63 ++
 .../Source/C/Include/IndustryStandard/PeImage.h|   10 +
 BaseTools/Source/Python/Common/DataType.py | 1075 ++--
 10 files changed, 1393 insertions(+), 561 deletions(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index db06d3a..8e7f6e0 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -145,14 +145,6 @@
 
 "$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
 
-[C-Header-File]
-
-*.h, *.H
-
-
-
-
-
 [Assembly-Code-File.COMMON.COMMON]
 
 ?.asm, ?.Asm, ?.ASM
@@ -321,6 +313,21 @@
 "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
 
 
+[Static-Library-File.COMMON.RISCV64, Static-Library-File.COMMON.RISCV32]
+
+*.lib
+
+
+$(MAKE_FILE)
+
+
+$(DEBUG_DIR)(+)$(MODULE_NAME).dll
+
+
+"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH) 
@$(STATIC_LIBRARY_FILES_LIST) --end-group $(DLINK2_FLAGS)
+"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
+
+
 [Static-Library-File.USER_DEFINED, Static-Library-File.HOST_APPLICATION]
 
 *.lib
diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 8f0e6cb..36a301a 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -3,7 +3,7 @@
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
 #  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
 #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
-#  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
+#  (C) Copyright 2016-2019 Hewlett Packard Enterprise Development LP
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -114,6 +114,12 @@ DEFINE GCC49_X64_PREFIX= ENV(GCC49_BIN)
 DEFINE GCC5_IA32_PREFIX= ENV(GCC5_BIN)
 DEFINE GCC5_X64_PREFIX = ENV(GCC5_BIN)
 DEFINE GCC_HOST_PREFIX = ENV(GCC_HOST_BIN)
+#
+# RISC-V GCC toolchain
+# This is the default directory used when install official riscv-tools.
+#
+DEFINE GCCRISCV_RISCV32_PREFIX = ENV(GCC_RISCV32_BIN)
+DEFINE GCCRISCV_RISCV64_PREFIX = ENV(GCC_RISCV64_BIN)
 
 DEFINE UNIX_IASL_BIN   = ENV(IASL_PREFIX)iasl
 DEFINE WIN_IASL_BIN= ENV(IASL_PREFIX)iasl.exe
@@ -236,6 +242,15 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
 # Required to build platforms or ACPI tables:
 #   Intel(r) ACPI Compiler from
 #   https://acpica.org/downloads
+#   GCCRISCV- Linux   -  Requires:
+# RISC-V official release of RISC-V GNU toolchain,
+#   https://github.com/riscv/riscv-gnu-toolchain 
@64879b24
+#   The commit ID 64879b24 is the one can build 
RISC-V platform and boo to EFI shell.
+#   Follow the instructions mentioned in README.md 
to build RISC-V tool change.
+# Set below environment variables to the RISC-V 
tool chain binaries before building RISC-V EDK2 port.
+#   - GCC_RISCV32_BIN
+#   - GCC_RISCV64_BIN
+#
 #   CLANG35 -Linux,Windows-  Requires:
 # Clang v3.5 or later, and GNU binutils targeting 
aarch64-linux-gnu or arm-linux-gnueabi
 #Optional:
@@ -1806,6 +1821,26 @@ DEFINE GCC5_ARM_ASLDLINK_FLAGS   = 
DEF(GCC49_ARM_ASLDLINK_FLAGS)
 DEFINE GCC5_AARCH64_ASLDLINK_FLAGS   = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
 DEFINE GCC5_ASLCC_FLAGS  = DEF(GCC49_ASLCC_FLAGS) -fno-lto
 
+DEFINE GCC_RISCV_ALL_CC_FLAGS= -g -fshort-wchar 
-fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections 
-fdata-sections -c -include AutoGen.h -fno-common 
-DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
+DEFINE GCC_RISCV_ALL_DLINK_COMMON= -nostdlib -n -q 
--gc-sections -z common-page-size=0x40
+DEFINE GCC_RISCV_ALL_DLINK_FLAGS = 
DEF(GCC_RISCV_ALL_DLINK_COMMON) --entry $(IMAGE_ENTRY_POINT) -u 
$(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+DEFINE