Liming,
Ok, I will change the commit message in the V3.


Thanks,
Chao
--------

On 9月 15 2022, at 2:28 下午, "gaoliming" <gaoliming@byosoft.com.cn> wrote:
Chao:
This change is to update GCC5 tool chain to support LoongArch. So, the
commit message title should be updated for GCC5 tool chain.

The code change is good to me. Reviewed-by: Liming Gao <gaoliming@byosoft.
com.cn>

Thanks
Liming
> -----邮件原件-----
> 发件人: Chao Li <lichao@loongson.cn>
> 发送时间: 2022年9月14日 17:40
> 收件人: devel@edk2.groups.io
> 抄送: Bob Feng <bob.c.feng@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Yuwei Chen <yuwei.chen@intel.com>;
> Dongyan Qian <qiandongyan@loongson.cn>; Baoqi Zhang
> <zhangbaoqi@loongson.cn>
> 主题: [PATCH v2 16/34] BaseTools: BaseTools changes for LoongArch
> platform.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4053
>
> BaseTools define template files changes for building EDK2 LoongArch
> platform.
>
> Cc: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Yuwei Chen <yuwei.chen@intel.com>
>
> Signed-off-by: Chao Li <lichao@loongson.cn>
> Co-authored-by: Dongyan Qian <qiandongyan@loongson.cn>
> Co-authored-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
> ---
> BaseTools/Conf/tools_def.template | 54
> +++++++++++++++++++++++++++----
> 1 file changed, 48 insertions(+), 6 deletions(-)
>
> diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> index 5ed19810b7..9ceadeaa59 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -4,6 +4,7 @@
> # Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.<BR>
>
> # Copyright (c) 2015, Hewlett-Packard Development Company, L.P.<BR>
>
> # (C) Copyright 2020, Hewlett Packard Enterprise Development LP<BR>
>
> +# Copyright (c) 2022, Loongson Technology Corporation Limited. All
rights
> reserved.<BR>
>
> # Copyright (c) Microsoft Corporation
>
> #
>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -267,7 +268,7 @@ DEFINE DTC_BIN =
> ENV(DTC_PREFIX)dtc
> # Intel(r) ACPI Compiler from
>
> # https://acpica.org/downloads
>
> # GCC5 -Linux,Windows- Requires:
>
> -# GCC 5 with LTO support, targeting
> x86_64-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabi or
riscv64-linux-gnu
>
> +# GCC 5 with LTO support, targeting
> x86_64-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabi, riscv64-linux-gnu
or
> loongarch64-linux-gnu
>
> # Optional:
>
> # Required to build platforms or ACPI
> tables:
>
> # Intel(r) ACPI Compiler from
>
> @@ -1852,6 +1853,7 @@ DEFINE GCC_ALL_CC_FLAGS = -g
> -Os -fshort-wchar -fno-builtin -fno-stri
> DEFINE GCC_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS)
> -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2
> -mno-stack-arg-probe
>
> DEFINE GCC_X64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS)
> -mno-red-zone -Wno-address -mno-stack-arg-probe
>
> DEFINE GCC_ARM_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS)
> -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char
> -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address
> -mthumb -mfloat-abi=soft -fno-pic -fno-pie
>
> +DEFINE GCC_LOONGARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS)
> -mabi=lp64d -fno-asynchronous-unwind-tables -fno-plt -Wno-address
> -fno-short-enums -fsigned-char -ffunction-sections -fdata-sections
>
> DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
>
> DEFINE GCC_AARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS)
> -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char
> -ffunction-sections -fdata-sections -Wno-address
> -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie
> -ffixed-x18
>
> DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align
> -mgeneral-regs-only
>
> @@ -1859,12 +1861,15 @@ DEFINE GCC_DLINK_FLAGS_COMMON =
> -nostdlib --pie
> DEFINE GCC_DLINK2_FLAGS_COMMON =
> -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
>
> DEFINE GCC_IA32_X64_DLINK_COMMON =
> DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
>
> DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs
> -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT)
> -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).
> map
>
> +DEFINE GCC_LOONGARCH64_DLINK_COMMON= -Wl,--emit-relocs
> -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT)
> -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).
> map
>
> DEFINE GCC_ARM_DLINK_FLAGS =
> DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
> -Wl,--pic-veneer
>
> DEFINE GCC_AARCH64_DLINK_FLAGS =
> DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
>
> +DEFINE GCC_LOONGARCH64_DLINK_FLAGS =
> DEF(GCC_LOONGARCH64_DLINK_COMMON) -z common-page-size=0x20
>
> DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS =
> -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON)
> -z common-page-size=0x20
>
> DEFINE GCC_IA32_X64_ASLDLINK_FLAGS =
> DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u
> $(IMAGE_ENTRY_POINT)
>
> DEFINE GCC_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS)
> -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
> DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
>
> DEFINE GCC_AARCH64_ASLDLINK_FLAGS =
> DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u
> $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
>
> +DEFINE GCC_LOONGARCH64_ASLDLINK_FLAGS =
> DEF(GCC_LOONGARCH64_DLINK_FLAGS) --entry ReferenceAcpiTable -u
> $(IMAGE_ENTRY_POINT)
>
> DEFINE GCC_IA32_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
>
> DEFINE GCC_ASM_FLAGS = -c -x assembler -imacros
> AutoGen.h
>
> DEFINE GCC_PP_FLAGS = -E -x assembler-with-cpp
> -include AutoGen.h
>
> @@ -1873,11 +1878,12 @@ DEFINE GCC_ASLPP_FLAGS = -x
> c -E -include AutoGen.h
> DEFINE GCC_ASLCC_FLAGS = -x c
>
> DEFINE GCC_WINDRES_FLAGS = -J rc -O coff
>
> DEFINE GCC_DTCPP_FLAGS = -E -x assembler-with-cpp
> -imacros AutoGen.h -nostdinc -undef
>
> -DEFINE GCC_IA32_RC_FLAGS = -I binary -O elf32-i386
> -B i386 --rename-section .data=.hii
>
> -DEFINE GCC_X64_RC_FLAGS = -I binary -O elf64-x86-64
> -B i386 --rename-section .data=.hii
>
> -DEFINE GCC_ARM_RC_FLAGS = -I binary -O elf32-littlearm
> -B arm --rename-section .data=.hii
>
> -DEFINE GCC_AARCH64_RC_FLAGS = -I binary -O elf64-littleaarch64
> -B aarch64 --rename-section .data=.hii
>
> -DEFINE GCC_RISCV64_RC_FLAGS = -I binary -O elf64-littleriscv
> -B riscv --rename-section .data=.hii
>
> +DEFINE GCC_IA32_RC_FLAGS = -I binary -O elf32-i386
> -B i386 --rename-section .data=.hii
>
> +DEFINE GCC_X64_RC_FLAGS = -I binary -O elf64-x86-64
> -B i386 --rename-section .data=.hii
>
> +DEFINE GCC_ARM_RC_FLAGS = -I binary -O elf32-littlearm
> -B arm --rename-section .data=.hii
>
> +DEFINE GCC_AARCH64_RC_FLAGS = -I binary -O
> elf64-littleaarch64 -B aarch64 --rename-section .data=.hii
>
> +DEFINE GCC_RISCV64_RC_FLAGS = -I binary -O elf64-littleriscv
> -B riscv --rename-section .data=.hii
>
> +DEFINE GCC_LOONGARCH64_RC_FLAGS = -I binary -O elf64-loongarch
> -B loongarch64 --rename-section .data=.hii
>
>
>
> # GCC Build Flag for included header file list generation
>
> DEFINE GCC_DEPS_FLAGS = -MMD -MF $@.deps
>
> @@ -1967,6 +1973,14 @@ DEFINE GCC5_RISCV64_CC_FLAGS
> = DEF(GCC5_RISCV_ALL_CC_FLAGS) DEF(GC
> DEFINE GCC5_RISCV64_DLINK_FLAGS =
> DEF(GCC5_RISCV_ALL_DLINK_FLAGS)
> -Wl,-melf64lriscv,--oformat=elf64-littleriscv,--no-relax
>
> DEFINE GCC5_RISCV64_DLINK2_FLAGS =
> DEF(GCC5_RISCV_ALL_DLINK2_FLAGS)
>
> DEFINE GCC5_RISCV64_ASM_FLAGS =
> DEF(GCC5_RISCV_ALL_ASM_FLAGS) -march=DEF(GCC5_RISCV64_ARCH)
> -mcmodel=medany -mabi=lp64
>
> +
>
> +DEFINE GCC5_LOONGARCH64_CC_FLAGS =
> DEF(GCC_LOONGARCH64_CC_FLAGS) -march=loongarch64 -mno-memcpy
> -Werror -Wno-maybe-uninitialized -Wno-stringop-overflow
> -Wno-pointer-to-int-cast -no-pie -fno-stack-protector -mno-explicit-relocs
>
> +DEFINE GCC5_LOONGARCH64_DLINK_FLAGS =
> DEF(GCC_LOONGARCH64_DLINK_FLAGS)
>
> +DEFINE GCC5_LOONGARCH64_DLINK2_FLAGS =
> DEF(GCC_DLINK2_FLAGS_COMMON)
> -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
>
> +DEFINE GCC5_LOONGARCH64_ASLDLINK_FLAGS =
> DEF(GCC_LOONGARCH64_ASLDLINK_FLAGS)
>
> +DEFINE GCC5_LOONGARCH64_ASM_FLAGS = -x
> assembler-with-cpp -mabi=lp64d -march=loongarch64 -fno-builtin -c -Wall
> -mno-explicit-relocs
>
> +DEFINE GCC5_LOONGARCH64_PP_FLAGS = -mabi=lp64d
> -march=loongarch64 DEF(GCC_PP_FLAGS)
>
> +
>
> DEFINE GCC_PP_FLAGS = -E -x
> assembler-with-cpp -include AutoGen.h DEF(GCC5_RISCV_OPENSBI_TYPES)
>
>
>
>
> ##############################################################
> ######################
>
> @@ -2445,6 +2459,34 @@ RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z
> common-page-size=0x20
> *_GCC5_RISCV64_OBJCOPY_FLAGS =
>
> *_GCC5_RISCV64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
>
>
>
> +##################
>
> +# GCC5 LOONGARCH64 definitions
>
> +##################
>
> +*_GCC5_LOONGARCH64_OBJCOPY_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)objcopy
>
> +*_GCC5_LOONGARCH64_CC_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc
>
> +*_GCC5_LOONGARCH64_SLINK_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc-ar
>
> +*_GCC5_LOONGARCH64_DLINK_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc
>
> +*_GCC5_LOONGARCH64_ASLDLINK_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc
>
> +*_GCC5_LOONGARCH64_ASM_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc
>
> +*_GCC5_LOONGARCH64_PP_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc
>
> +*_GCC5_LOONGARCH64_VFRPP_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc
>
> +*_GCC5_LOONGARCH64_ASLCC_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc
>
> +*_GCC5_LOONGARCH64_ASLPP_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)gcc
>
> +*_GCC5_LOONGARCH64_RC_PATH =
> ENV(GCC5_LOONGARCH64_PREFIX)objcopy
>
> +
>
> +*_GCC5_LOONGARCH64_ASLCC_FLAGS =
> DEF(GCC_ASLCC_FLAGS)
>
> +*_GCC5_LOONGARCH64_ASLDLINK_FLAGS =
> DEF(GCC5_LOONGARCH64_ASLDLINK_FLAGS)
>
> +*_GCC5_LOONGARCH64_ASM_FLAGS =
> DEF(GCC5_LOONGARCH64_ASM_FLAGS)
>
> +*_GCC5_LOONGARCH64_DLINK_FLAGS =
> DEF(GCC5_LOONGARCH64_DLINK_FLAGS)
>
> +*_GCC5_LOONGARCH64_DLINK2_FLAGS =
> DEF(GCC5_LOONGARCH64_DLINK2_FLAGS)
>
> +*_GCC5_LOONGARCH64_RC_FLAGS =
> DEF(GCC_LOONGARCH64_RC_FLAGS)
>
> +*_GCC5_LOONGARCH64_OBJCOPY_FLAGS =
>
> +*_GCC5_LOONGARCH64_NASM_FLAGS = -f elf32
>
> +*_GCC5_LOONGARCH64_PP_FLAGS =
> DEF(GCC5_LOONGARCH64_PP_FLAGS)
>
> +
>
> +DEBUG_GCC5_LOONGARCH64_CC_FLAGS =
> DEF(GCC5_LOONGARCH64_CC_FLAGS)
>
> +RELEASE_GCC5_LOONGARCH64_CC_FLAGS =
> DEF(GCC5_LOONGARCH64_CC_FLAGS) -Wno-unused-but-set-variable
> -Wno-unused-variable
>
> +
>
>
> ##############################################################
> ######################
>
> #
>
> # CLANG35 - This configuration is used to compile under Linux to
produce
>
> --
> 2.27.0