Re: [staging/LoongArch RESEND PATCH v1 14/33] BaseTools: BaseTools changes for LoongArch platform.


Abner Chang
 

Acked-by: Abner Chang <abner.chang@...>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chao Li
Sent: Wednesday, February 9, 2022 2:55 PM
To: devel@edk2.groups.io
Cc: Bob Feng <bob.c.feng@...>; Liming Gao
<gaoliming@...>; Yuwei Chen <yuwei.chen@...>; Baoqi
Zhang <zhangbaoqi@...>
Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 14/33]
BaseTools: BaseTools changes for LoongArch platform.

BaseTools define template files changes for building EDK2 LoongArch
platform.

Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>

Signed-off-by: Chao Li <lichao@...>
Co-authored-by: Baoqi Zhang <zhangbaoqi@...>
---
BaseTools/Conf/tools_def.template | 43
++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Conf/tools_def.template
b/BaseTools/Conf/tools_def.template
index 85b8afbb2d..67b6c69dcf 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 ro loongarch64-linux-
gnu
# Optional:
# Required to build platforms or ACPI tables:
# Intel(r) ACPI Compiler from
@@ -1871,6 +1872,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) -
march=loongarch64 -mabi=lp64d -Wa,-mla-global-with-abs -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
@@ -1878,12 +1880,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
@@ -1897,6 +1902,7 @@ DEFINE GCC_X64_RC_FLAGS = -I binary -O
elf64-x86-64 -B i386
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 --alt-elf-eflags=0x3 --rename-section .data=.hii

# GCC Build Flag for included header file list generation
DEFINE GCC_DEPS_FLAGS = -MMD -MF $@.deps
@@ -1986,6 +1992,12 @@ 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) -mno-memcpy -Werror -Wno-maybe-
uninitialized -Wno-stringop-overflow -Wno-pointer-to-int-cast
+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 -Wa,-mla-global-with-abs -fno-builtin -c -
Wall
+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)


##########################################################
##########################
@@ -2464,6 +2476,35 @@ 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_CC_FLAGS =
DEF(GCC5_LOONGARCH64_CC_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




Join devel@edk2.groups.io to automatically receive all group messages.