[PATCH] BaseTools/tools_def.txt: Add -march=x86-64 for X64 CLANG and GCC targets


dann frazier
 

From: dann frazier <dann.frazier@...>

Some Linux distributions are experimenting with builds that target a
higher x86-64 psABI, such as x86-64-v3. To avoid inheriting these
compiler defaults in edk2 builds, and therefore breaking compatibility
with machines using older CPUs, explicitly target the generic x86-64
psABI. This is similar to how we explicitly specify the cpu type for
some other architectures (-march=3Di586 for IA32, -march=3Darmv7-a for ARM).

Spot tested with OVMF builds using GCC5 and CLANG38.

Signed-off-by: dann frazier <dann.frazier@...>
---
BaseTools/Conf/tools_def.template | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t=
emplate
index adcd23f727..569d16fb3e 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1885,7 +1885,7 @@ DEFINE GCC_DEPS_FLAGS =3D -MMD -MF $@.de=
ps
DEFINE GCC48_ALL_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -ffunction-=
sections -fdata-sections -DSTRING_ARRAY_NAME=3D$(BASE_NAME)Strings=0D
DEFINE GCC48_IA32_X64_DLINK_COMMON =3D -nostdlib -Wl,-n,-q,--gc-sections=
-z common-page-size=3D0x20=0D
DEFINE GCC48_IA32_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) -m32 -mar=
ch=3Di586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-un=
wind-tables -Wno-address=0D
-DEFINE GCC48_X64_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) -m64 -fno=
-stack-protector "-DEFIAPI=3D__attribute__((ms_abi))" -maccumulate-outgoing=
-args -mno-red-zone -Wno-address -mcmodel=3Dsmall -fpie -fno-asynchronous-u=
nwind-tables -Wno-address=0D
+DEFINE GCC48_X64_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) -m64 -mar=
ch=3Dx86-64 -fno-stack-protector "-DEFIAPI=3D__attribute__((ms_abi))" -macc=
umulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=3Dsmall -fpie -fn=
o-asynchronous-unwind-tables -Wno-address=0D
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS =3D DEF(GCC48_IA32_X64_DLINK_COMMON) =
-Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable=0D
DEFINE GCC48_IA32_X64_DLINK_FLAGS =3D DEF(GCC48_IA32_X64_DLINK_COMMON) =
-Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DI=
R_DEBUG)/$(BASE_NAME).map,--whole-archive=0D
DEFINE GCC48_IA32_DLINK2_FLAGS =3D -Wl,--defsym=3DPECOFF_HEADER_SIZE=
=3D0x220 DEF(GCC_DLINK2_FLAGS_COMMON)=0D
@@ -2613,15 +2613,15 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS =3D DEF(GCC5_IA=
32_DLINK2_FLAGS) -O0
*_CLANG38_X64_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X6=
4_TARGET)=0D
*_CLANG38_X64_VFRPP_FLAGS =3D DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X6=
4_TARGET)=0D
=0D
-DEBUG_CLANG38_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DE=
FIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -fpie -Oz -=
flto DEF(CLANG38_X64_TARGET) -g=0D
+DEBUG_CLANG38_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 -mar=
ch=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Ds=
mall -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g=0D
DEBUG_CLANG38_X64_DLINK_FLAGS =3D DEF(GCC5_IA32_X64_DLINK_FLAGS) -flt=
o -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=3Delf64-x86-64 -Wl,-pie -mcmodel=
=3Dsmall=0D
DEBUG_CLANG38_X64_DLINK2_FLAGS =3D DEF(GCC5_X64_DLINK2_FLAGS) -O3=0D
=0D
-RELEASE_CLANG38_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DE=
FIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -fpie -Oz -=
flto DEF(CLANG38_X64_TARGET)=0D
+RELEASE_CLANG38_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 -mar=
ch=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Ds=
mall -fpie -Oz -flto DEF(CLANG38_X64_TARGET)=0D
RELEASE_CLANG38_X64_DLINK_FLAGS =3D DEF(GCC5_IA32_X64_DLINK_FLAGS) -flt=
o -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=3Delf64-x86-64 -Wl,-pie -mcmodel=
=3Dsmall=0D
RELEASE_CLANG38_X64_DLINK2_FLAGS =3D DEF(GCC5_X64_DLINK2_FLAGS) -O3=0D
=0D
-NOOPT_CLANG38_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DE=
FIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -fpie -O0 D=
EF(CLANG38_X64_TARGET) -g=0D
+NOOPT_CLANG38_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 -mar=
ch=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Ds=
mall -fpie -O0 DEF(CLANG38_X64_TARGET) -g=0D
NOOPT_CLANG38_X64_DLINK_FLAGS =3D DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,=
-O0 -Wl,-melf_x86_64 -Wl,--oformat=3Delf64-x86-64 -Wl,-pie -mcmodel=3Dsmall=
=0D
NOOPT_CLANG38_X64_DLINK2_FLAGS =3D DEF(GCC5_X64_DLINK2_FLAGS) -O0=0D
=0D
@@ -2798,17 +2798,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =3D
*_CLANGPDB_X64_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_=
X64_TARGET)=0D
*_CLANGPDB_X64_VFRPP_FLAGS =3D DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_=
X64_TARGET)=0D
=0D
-DEBUG_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-=
DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -Oz -flto=
DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables=0D
+DEBUG_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -m=
arch=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=
=3Dsmall -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables=0D
DEBUG_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001=
/OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(=
IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /=
DEBUG:GHASH /MLLVM:-exception-model=3Dwineh /lldmap=0D
DEBUG_CLANGPDB_X64_DLINK2_FLAGS =3D=0D
DEBUG_CLANGPDB_X64_GENFW_FLAGS =3D --keepexceptiontable=0D
=0D
-RELEASE_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-=
DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -Oz -flto=
DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables=0D
+RELEASE_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -m=
arch=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=
=3Dsmall -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables=0D
RELEASE_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001=
/IGNORE:4254 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdat=
a,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYS=
TEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=3D.data /MLLV=
M:-exception-model=3Dwineh /lldmap=0D
RELEASE_CLANGPDB_X64_DLINK2_FLAGS =3D=0D
RELEASE_CLANGPDB_X64_GENFW_FLAGS =3D=0D
=0D
-NOOPT_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-=
DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -O0 DEF(C=
LANGPDB_X64_TARGET) -gcodeview -funwind-tables=0D
+NOOPT_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -m=
arch=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=
=3Dsmall -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables=0D
NOOPT_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001=
/OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(=
IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /=
DEBUG:GHASH /MLLVM:-exception-model=3Dwineh /lldmap=0D
NOOPT_CLANGPDB_X64_DLINK2_FLAGS =3D=0D
NOOPT_CLANGPDB_X64_GENFW_FLAGS =3D --keepexceptiontable=0D
@@ -2901,15 +2901,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS =3D DEF(CLAN=
GDWARF_IA32_DLINK2_FLAGS) -O0 -
*_CLANGDWARF_X64_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) DEF(CLANG38=
_X64_TARGET)=0D
*_CLANGDWARF_X64_VFRPP_FLAGS =3D DEF(GCC_VFRPP_FLAGS) DEF(CLANG38=
_X64_TARGET)=0D
=0D
-DEBUG_CLANGDWARF_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 "=
-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -fpie -O=
z -flto DEF(CLANG38_X64_TARGET) -g=0D
+DEBUG_CLANGDWARF_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 -=
march=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=
=3Dsmall -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g=0D
DEBUG_CLANGDWARF_X64_DLINK_FLAGS =3D DEF(CLANGDWARF_IA32_X64_DLINK_FL=
AGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mc=
model=3Dsmall -Wl,--apply-dynamic-relocs=0D
DEBUG_CLANGDWARF_X64_DLINK2_FLAGS =3D DEF(CLANGDWARF_X64_DLINK2_FLAGS)=
-O3 -fuse-ld=3Dlld=0D
=0D
-RELEASE_CLANGDWARF_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 "=
-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -fpie -O=
z -flto DEF(CLANG38_X64_TARGET)=0D
+RELEASE_CLANGDWARF_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 -=
march=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=
=3Dsmall -fpie -Oz -flto DEF(CLANG38_X64_TARGET)=0D
RELEASE_CLANGDWARF_X64_DLINK_FLAGS =3D DEF(CLANGDWARF_IA32_X64_DLINK_FL=
AGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mc=
model=3Dsmall -Wl,--apply-dynamic-relocs=0D
RELEASE_CLANGDWARF_X64_DLINK2_FLAGS =3D DEF(CLANGDWARF_X64_DLINK2_FLAGS)=
-O3 -fuse-ld=3Dlld=0D
=0D
-NOOPT_CLANGDWARF_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 "=
-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -fpie -O=
0 DEF(CLANG38_X64_TARGET) -g=0D
+NOOPT_CLANGDWARF_X64_CC_FLAGS =3D DEF(CLANG38_ALL_CC_FLAGS) -m64 -=
march=3Dx86-64 "-DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=
=3Dsmall -fpie -O0 DEF(CLANG38_X64_TARGET) -g=0D
NOOPT_CLANGDWARF_X64_DLINK_FLAGS =3D DEF(CLANGDWARF_IA32_X64_DLINK_FL=
AGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=
=3Dsmall -Wl,--apply-dynamic-relocs=0D
NOOPT_CLANGDWARF_X64_DLINK2_FLAGS =3D DEF(CLANGDWARF_X64_DLINK2_FLAGS)=
-O0 -fuse-ld=3Dlld=0D
=0D
--=20
2.36.1


dann frazier
 

Ping on this. Would it be more palatable if I limited the change only
to tested toolchains (gcc/clang)? Alternatively, is there a way to
submit this code to CI to verify the !(gcc|clang) variants?

-dann

On Fri, Jun 10, 2022 at 12:09:18PM -0600, dann frazier wrote:
From: dann frazier <dann.frazier@...>

Some Linux distributions are experimenting with builds that target a
higher x86-64 psABI, such as x86-64-v3. To avoid inheriting these
compiler defaults in edk2 builds, and therefore breaking compatibility
with machines using older CPUs, explicitly target the generic x86-64
psABI. This is similar to how we explicitly specify the cpu type for
some other architectures (-march=i586 for IA32, -march=armv7-a for ARM).

Spot tested with OVMF builds using GCC5 and CLANG38.

Signed-off-by: dann frazier <dann.frazier@...>
---
BaseTools/Conf/tools_def.template | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index adcd23f727..569d16fb3e 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1885,7 +1885,7 @@ DEFINE GCC_DEPS_FLAGS = -MMD -MF $@.deps
DEFINE GCC48_ALL_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x20
DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -Wno-address
-DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address
+DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64 -march=x86-64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
DEFINE GCC48_IA32_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
@@ -2613,15 +2613,15 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS) -O0
*_CLANG38_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)
*_CLANG38_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)

-DEBUG_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
DEBUG_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
DEBUG_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O3

-RELEASE_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
RELEASE_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
RELEASE_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O3

-NOOPT_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
NOOPT_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
NOOPT_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O0

@@ -2798,17 +2798,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =
*_CLANGPDB_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_X64_TARGET)
*_CLANGPDB_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_X64_TARGET)

-DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
+DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
DEBUG_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
DEBUG_CLANGPDB_X64_DLINK2_FLAGS =
DEBUG_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable

-RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
+RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
RELEASE_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
RELEASE_CLANGPDB_X64_DLINK2_FLAGS =
RELEASE_CLANGPDB_X64_GENFW_FLAGS =

-NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
+NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
NOOPT_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
NOOPT_CLANGPDB_X64_DLINK2_FLAGS =
NOOPT_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable
@@ -2901,15 +2901,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
*_CLANGDWARF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)
*_CLANGDWARF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)

-DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
DEBUG_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
DEBUG_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

-RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
RELEASE_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
RELEASE_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

-NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
NOOPT_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
NOOPT_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld


Pedro Falcato
 

This may be a strong opinion but I would consider toolchains that explicitly change the default -march from the well understood x86-64 (which all 64-bit processors support) to be totally broken. If a distro wants to switch the -march for the packages, override CFLAGS :)

On Wed, Jun 29, 2022 at 10:57 PM dann frazier <dann.frazier@...> wrote:
Ping on this. Would it be more palatable if I limited the change only
to tested toolchains (gcc/clang)? Alternatively, is there a way to
submit this code to CI to verify the !(gcc|clang) variants?

  -dann

On Fri, Jun 10, 2022 at 12:09:18PM -0600, dann frazier wrote:
> From: dann frazier <dann.frazier@...>
>
> Some Linux distributions are experimenting with builds that target a
> higher x86-64 psABI, such as x86-64-v3. To avoid inheriting these
> compiler defaults in edk2 builds, and therefore breaking compatibility
> with machines using older CPUs, explicitly target the generic x86-64
> psABI. This is similar to how we explicitly specify the cpu type for
> some other architectures (-march=i586 for IA32, -march=armv7-a for ARM).
>
> Spot tested with OVMF builds using GCC5 and CLANG38.
>
> Signed-off-by: dann frazier <dann.frazier@...>
> ---
>  BaseTools/Conf/tools_def.template | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> index adcd23f727..569d16fb3e 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -1885,7 +1885,7 @@ DEFINE GCC_DEPS_FLAGS              = -MMD -MF $@.deps
>  DEFINE GCC48_ALL_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
>  DEFINE GCC48_IA32_X64_DLINK_COMMON   = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x20
>  DEFINE GCC48_IA32_CC_FLAGS           = DEF(GCC48_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -Wno-address
> -DEFINE GCC48_X64_CC_FLAGS            = DEF(GCC48_ALL_CC_FLAGS) -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address
> +DEFINE GCC48_X64_CC_FLAGS            = DEF(GCC48_ALL_CC_FLAGS) -m64 -march=x86-64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address
>  DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
>  DEFINE GCC48_IA32_X64_DLINK_FLAGS    = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
>  DEFINE GCC48_IA32_DLINK2_FLAGS       = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
> @@ -2613,15 +2613,15 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS     = DEF(GCC5_IA32_DLINK2_FLAGS) -O0
>  *_CLANG38_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)
>  *_CLANG38_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)

> -DEBUG_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
> +DEBUG_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
>  DEBUG_CLANG38_X64_DLINK_FLAGS      = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
>  DEBUG_CLANG38_X64_DLINK2_FLAGS     = DEF(GCC5_X64_DLINK2_FLAGS) -O3

> -RELEASE_CLANG38_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
> +RELEASE_CLANG38_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
>  RELEASE_CLANG38_X64_DLINK_FLAGS    = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
>  RELEASE_CLANG38_X64_DLINK2_FLAGS   = DEF(GCC5_X64_DLINK2_FLAGS) -O3

> -NOOPT_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
> +NOOPT_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
>  NOOPT_CLANG38_X64_DLINK_FLAGS      = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
>  NOOPT_CLANG38_X64_DLINK2_FLAGS     = DEF(GCC5_X64_DLINK2_FLAGS) -O0

> @@ -2798,17 +2798,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS     =
>  *_CLANGPDB_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_X64_TARGET)
>  *_CLANGPDB_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_X64_TARGET)

> -DEBUG_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview  -funwind-tables
> +DEBUG_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview  -funwind-tables
>  DEBUG_CLANGPDB_X64_DLINK_FLAGS      = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
>  DEBUG_CLANGPDB_X64_DLINK2_FLAGS     =
>  DEBUG_CLANGPDB_X64_GENFW_FLAGS      = --keepexceptiontable

> -RELEASE_CLANGPDB_X64_CC_FLAGS       = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
> +RELEASE_CLANGPDB_X64_CC_FLAGS       = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
>  RELEASE_CLANGPDB_X64_DLINK_FLAGS    = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
>  RELEASE_CLANGPDB_X64_DLINK2_FLAGS   =
>  RELEASE_CLANGPDB_X64_GENFW_FLAGS    =

> -NOOPT_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
> +NOOPT_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
>  NOOPT_CLANGPDB_X64_DLINK_FLAGS      = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
>  NOOPT_CLANGPDB_X64_DLINK2_FLAGS     =
>  NOOPT_CLANGPDB_X64_GENFW_FLAGS      = --keepexceptiontable
> @@ -2901,15 +2901,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS     = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
>  *_CLANGDWARF_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)
>  *_CLANGDWARF_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)

> -DEBUG_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
> +DEBUG_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
>  DEBUG_CLANGDWARF_X64_DLINK_FLAGS      = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
>  DEBUG_CLANGDWARF_X64_DLINK2_FLAGS     = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

> -RELEASE_CLANGDWARF_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
> +RELEASE_CLANGDWARF_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
>  RELEASE_CLANGDWARF_X64_DLINK_FLAGS    = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
>  RELEASE_CLANGDWARF_X64_DLINK2_FLAGS   = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

> -NOOPT_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
> +NOOPT_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64 -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
>  NOOPT_CLANGDWARF_X64_DLINK_FLAGS      = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
>  NOOPT_CLANGDWARF_X64_DLINK2_FLAGS     = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld








--
Pedro Falcato


dann frazier
 

On Wed, Jun 29, 2022 at 11:06:01PM +0100, Pedro Falcato wrote:
This may be a strong opinion but I would consider toolchains that
explicitly change the default -march from the well understood x86-64 (which
all 64-bit processors support) to be totally broken. If a distro wants to
switch the -march for the packages, override CFLAGS :)
Opinion noted. But is there a downside to edk2 being explicit about
its target CPU level on x86-64, given it already does so for IA32 and
ARM?

-dann

On Wed, Jun 29, 2022 at 10:57 PM dann frazier <dann.frazier@...>
wrote:

Ping on this. Would it be more palatable if I limited the change only
to tested toolchains (gcc/clang)? Alternatively, is there a way to
submit this code to CI to verify the !(gcc|clang) variants?

-dann

On Fri, Jun 10, 2022 at 12:09:18PM -0600, dann frazier wrote:
From: dann frazier <dann.frazier@...>

Some Linux distributions are experimenting with builds that target a
higher x86-64 psABI, such as x86-64-v3. To avoid inheriting these
compiler defaults in edk2 builds, and therefore breaking compatibility
with machines using older CPUs, explicitly target the generic x86-64
psABI. This is similar to how we explicitly specify the cpu type for
some other architectures (-march=i586 for IA32, -march=armv7-a for ARM).

Spot tested with OVMF builds using GCC5 and CLANG38.

Signed-off-by: dann frazier <dann.frazier@...>
---
BaseTools/Conf/tools_def.template | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template
b/BaseTools/Conf/tools_def.template
index adcd23f727..569d16fb3e 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1885,7 +1885,7 @@ DEFINE GCC_DEPS_FLAGS = -MMD -MF
$@.deps
DEFINE GCC48_ALL_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS)
-ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib
-Wl,-n,-q,--gc-sections -z common-page-size=0x20
DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32
-march=i586 -malign-double -fno-stack-protector -D EFI32
-fno-asynchronous-unwind-tables -Wno-address
-DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64
-fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
-fno-asynchronous-unwind-tables -Wno-address
+DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64
-march=x86-64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
-fno-asynchronous-unwind-tables -Wno-address
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON)
-Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON)
-Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
-Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
DEFINE GCC48_IA32_DLINK2_FLAGS =
-Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
@@ -2613,15 +2613,15 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS =
DEF(GCC5_IA32_DLINK2_FLAGS) -O0
*_CLANG38_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANG38_X64_TARGET)
*_CLANG38_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANG38_X64_TARGET)

-DEBUG_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
-flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
DEBUG_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
-mcmodel=small
DEBUG_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O3

-RELEASE_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
-flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
RELEASE_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
-mcmodel=small
RELEASE_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O3

-NOOPT_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0
DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
NOOPT_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
NOOPT_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O0

@@ -2798,17 +2798,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =
*_CLANGPDB_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANGPDB_X64_TARGET)
*_CLANGPDB_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANGPDB_X64_TARGET)

-DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto
DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
+DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview
-funwind-tables
DEBUG_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
/BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
DEBUG_CLANGPDB_X64_DLINK2_FLAGS =
DEBUG_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable

-RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto
DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
+RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
RELEASE_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32
/SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
/BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
RELEASE_CLANGPDB_X64_DLINK2_FLAGS =
RELEASE_CLANGPDB_X64_GENFW_FLAGS =

-NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0
DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
+NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
NOOPT_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
/BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
NOOPT_CLANGPDB_X64_DLINK2_FLAGS =
NOOPT_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable
@@ -2901,15 +2901,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS =
DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
*_CLANGDWARF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANG38_X64_TARGET)
*_CLANGDWARF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANG38_X64_TARGET)

-DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
-flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
DEBUG_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
DEBUG_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

-RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
-flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
RELEASE_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
RELEASE_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

-NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0
DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
NOOPT_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
NOOPT_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld





Michael D Kinney
 

What is the default when -march is not specified?

Mike

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of dann frazier
Sent: Wednesday, June 29, 2022 4:25 PM
To: Pedro Falcato <pedro.falcato@...>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>; Feng, Bob C <bob.c.feng@...>; Gao, Liming <gaoliming@...>;
Chen, Christine <yuwei.chen@...>
Subject: Re: [edk2-devel] [PATCH] BaseTools/tools_def.txt: Add -march=x86-64 for X64 CLANG and GCC targets

On Wed, Jun 29, 2022 at 11:06:01PM +0100, Pedro Falcato wrote:
This may be a strong opinion but I would consider toolchains that
explicitly change the default -march from the well understood x86-64 (which
all 64-bit processors support) to be totally broken. If a distro wants to
switch the -march for the packages, override CFLAGS :)
Opinion noted. But is there a downside to edk2 being explicit about
its target CPU level on x86-64, given it already does so for IA32 and
ARM?

-dann

On Wed, Jun 29, 2022 at 10:57 PM dann frazier <dann.frazier@...>
wrote:

Ping on this. Would it be more palatable if I limited the change only
to tested toolchains (gcc/clang)? Alternatively, is there a way to
submit this code to CI to verify the !(gcc|clang) variants?

-dann

On Fri, Jun 10, 2022 at 12:09:18PM -0600, dann frazier wrote:
From: dann frazier <dann.frazier@...>

Some Linux distributions are experimenting with builds that target a
higher x86-64 psABI, such as x86-64-v3. To avoid inheriting these
compiler defaults in edk2 builds, and therefore breaking compatibility
with machines using older CPUs, explicitly target the generic x86-64
psABI. This is similar to how we explicitly specify the cpu type for
some other architectures (-march=i586 for IA32, -march=armv7-a for ARM).

Spot tested with OVMF builds using GCC5 and CLANG38.

Signed-off-by: dann frazier <dann.frazier@...>
---
BaseTools/Conf/tools_def.template | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template
b/BaseTools/Conf/tools_def.template
index adcd23f727..569d16fb3e 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1885,7 +1885,7 @@ DEFINE GCC_DEPS_FLAGS = -MMD -MF
$@.deps
DEFINE GCC48_ALL_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS)
-ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib
-Wl,-n,-q,--gc-sections -z common-page-size=0x20
DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32
-march=i586 -malign-double -fno-stack-protector -D EFI32
-fno-asynchronous-unwind-tables -Wno-address
-DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64
-fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
-fno-asynchronous-unwind-tables -Wno-address
+DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64
-march=x86-64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
-fno-asynchronous-unwind-tables -Wno-address
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON)
-Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON)
-Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
-Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
DEFINE GCC48_IA32_DLINK2_FLAGS =
-Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
@@ -2613,15 +2613,15 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS =
DEF(GCC5_IA32_DLINK2_FLAGS) -O0
*_CLANG38_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANG38_X64_TARGET)
*_CLANG38_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANG38_X64_TARGET)

-DEBUG_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
-flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
DEBUG_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
-mcmodel=small
DEBUG_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O3

-RELEASE_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
-flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
RELEASE_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
-mcmodel=small
RELEASE_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O3

-NOOPT_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0
DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
NOOPT_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
NOOPT_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O0

@@ -2798,17 +2798,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =
*_CLANGPDB_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANGPDB_X64_TARGET)
*_CLANGPDB_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANGPDB_X64_TARGET)

-DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto
DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
+DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview
-funwind-tables
DEBUG_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
/BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
DEBUG_CLANGPDB_X64_DLINK2_FLAGS =
DEBUG_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable

-RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto
DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
+RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
RELEASE_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32
/SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
/BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
RELEASE_CLANGPDB_X64_DLINK2_FLAGS =
RELEASE_CLANGPDB_X64_GENFW_FLAGS =

-NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0
DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
+NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
NOOPT_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
/BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
NOOPT_CLANGPDB_X64_DLINK2_FLAGS =
NOOPT_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable
@@ -2901,15 +2901,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS =
DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
*_CLANGDWARF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANG38_X64_TARGET)
*_CLANGDWARF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANG38_X64_TARGET)

-DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
-flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
DEBUG_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
DEBUG_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

-RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
-flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
RELEASE_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
RELEASE_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

-NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0
DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
NOOPT_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
NOOPT_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld







dann frazier
 



On Wed, Jun 29, 2022, 18:10 Kinney, Michael D <michael.d.kinney@...> wrote:
What is the default when -march is not specified?

Whatever your compiler was built to target by default. Today that's x86-64 pretty much everywhere. But it's possible some distros may change that, and I don't think we want edk2 builds changing if they happen to be built on one of them.

  -dann

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of dann frazier
> Sent: Wednesday, June 29, 2022 4:25 PM
> To: Pedro Falcato <pedro.falcato@...>
> Cc: edk2-devel-groups-io <devel@edk2.groups.io>; Feng, Bob C <bob.c.feng@...>; Gao, Liming <gaoliming@...>;
> Chen, Christine <yuwei.chen@...>
> Subject: Re: [edk2-devel] [PATCH] BaseTools/tools_def.txt: Add -march=x86-64 for X64 CLANG and GCC targets
>
> On Wed, Jun 29, 2022 at 11:06:01PM +0100, Pedro Falcato wrote:
> > This may be a strong opinion but I would consider toolchains that
> > explicitly change the default -march from the well understood x86-64 (which
> > all 64-bit processors support) to be totally broken. If a distro wants to
> > switch the -march for the packages, override CFLAGS :)
>
> Opinion noted. But is there a downside to edk2 being explicit about
> its target CPU level on x86-64, given it already does so for IA32 and
> ARM?
>
>   -dann
>
> > On Wed, Jun 29, 2022 at 10:57 PM dann frazier <dann.frazier@...>
> > wrote:
> >
> > > Ping on this. Would it be more palatable if I limited the change only
> > > to tested toolchains (gcc/clang)? Alternatively, is there a way to
> > > submit this code to CI to verify the !(gcc|clang) variants?
> > >
> > >   -dann
> > >
> > > On Fri, Jun 10, 2022 at 12:09:18PM -0600, dann frazier wrote:
> > > > From: dann frazier <dann.frazier@...>
> > > >
> > > > Some Linux distributions are experimenting with builds that target a
> > > > higher x86-64 psABI, such as x86-64-v3. To avoid inheriting these
> > > > compiler defaults in edk2 builds, and therefore breaking compatibility
> > > > with machines using older CPUs, explicitly target the generic x86-64
> > > > psABI. This is similar to how we explicitly specify the cpu type for
> > > > some other architectures (-march=i586 for IA32, -march=armv7-a for ARM).
> > > >
> > > > Spot tested with OVMF builds using GCC5 and CLANG38.
> > > >
> > > > Signed-off-by: dann frazier <dann.frazier@...>
> > > > ---
> > > >  BaseTools/Conf/tools_def.template | 20 ++++++++++----------
> > > >  1 file changed, 10 insertions(+), 10 deletions(-)
> > > >
> > > > diff --git a/BaseTools/Conf/tools_def.template
> > > b/BaseTools/Conf/tools_def.template
> > > > index adcd23f727..569d16fb3e 100755
> > > > --- a/BaseTools/Conf/tools_def.template
> > > > +++ b/BaseTools/Conf/tools_def.template
> > > > @@ -1885,7 +1885,7 @@ DEFINE GCC_DEPS_FLAGS              = -MMD -MF
> > > $@.deps
> > > >  DEFINE GCC48_ALL_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS)
> > > -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
> > > >  DEFINE GCC48_IA32_X64_DLINK_COMMON   = -nostdlib
> > > -Wl,-n,-q,--gc-sections -z common-page-size=0x20
> > > >  DEFINE GCC48_IA32_CC_FLAGS           = DEF(GCC48_ALL_CC_FLAGS) -m32
> > > -march=i586 -malign-double -fno-stack-protector -D EFI32
> > > -fno-asynchronous-unwind-tables -Wno-address
> > > > -DEFINE GCC48_X64_CC_FLAGS            = DEF(GCC48_ALL_CC_FLAGS) -m64
> > > -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
> > > -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
> > > -fno-asynchronous-unwind-tables -Wno-address
> > > > +DEFINE GCC48_X64_CC_FLAGS            = DEF(GCC48_ALL_CC_FLAGS) -m64
> > > -march=x86-64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
> > > -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
> > > -fno-asynchronous-unwind-tables -Wno-address
> > > >  DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON)
> > > -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
> > > >  DEFINE GCC48_IA32_X64_DLINK_FLAGS    = DEF(GCC48_IA32_X64_DLINK_COMMON)
> > > -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
> > > -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
> > > >  DEFINE GCC48_IA32_DLINK2_FLAGS       =
> > > -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
> > > > @@ -2613,15 +2613,15 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS     =
> > > DEF(GCC5_IA32_DLINK2_FLAGS) -O0
> > > >  *_CLANG38_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS)
> > > DEF(CLANG38_X64_TARGET)
> > > >  *_CLANG38_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS)
> > > DEF(CLANG38_X64_TARGET)
> > > >
> > > > -DEBUG_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
> > > -flto DEF(CLANG38_X64_TARGET) -g
> > > > +DEBUG_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
> > > >  DEBUG_CLANG38_X64_DLINK_FLAGS      = DEF(GCC5_IA32_X64_DLINK_FLAGS)
> > > -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
> > > -mcmodel=small
> > > >  DEBUG_CLANG38_X64_DLINK2_FLAGS     = DEF(GCC5_X64_DLINK2_FLAGS) -O3
> > > >
> > > > -RELEASE_CLANG38_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
> > > -flto DEF(CLANG38_X64_TARGET)
> > > > +RELEASE_CLANG38_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
> > > >  RELEASE_CLANG38_X64_DLINK_FLAGS    = DEF(GCC5_IA32_X64_DLINK_FLAGS)
> > > -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
> > > -mcmodel=small
> > > >  RELEASE_CLANG38_X64_DLINK2_FLAGS   = DEF(GCC5_X64_DLINK2_FLAGS) -O3
> > > >
> > > > -NOOPT_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0
> > > DEF(CLANG38_X64_TARGET) -g
> > > > +NOOPT_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
> > > >  NOOPT_CLANG38_X64_DLINK_FLAGS      = DEF(GCC5_IA32_X64_DLINK_FLAGS)
> > > -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
> > > >  NOOPT_CLANG38_X64_DLINK2_FLAGS     = DEF(GCC5_X64_DLINK2_FLAGS) -O0
> > > >
> > > > @@ -2798,17 +2798,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS     =
> > > >  *_CLANGPDB_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS)
> > > DEF(CLANGPDB_X64_TARGET)
> > > >  *_CLANGPDB_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS)
> > > DEF(CLANGPDB_X64_TARGET)
> > > >
> > > > -DEBUG_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto
> > > DEF(CLANGPDB_X64_TARGET) -gcodeview  -funwind-tables
> > > > +DEBUG_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview
> > > -funwind-tables
> > > >  DEBUG_CLANGPDB_X64_DLINK_FLAGS      = /NOLOGO /NODEFAULTLIB
> > > /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL
> > > /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
> > > /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
> > > >  DEBUG_CLANGPDB_X64_DLINK2_FLAGS     =
> > > >  DEBUG_CLANGPDB_X64_GENFW_FLAGS      = --keepexceptiontable
> > > >
> > > > -RELEASE_CLANGPDB_X64_CC_FLAGS       = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto
> > > DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
> > > > +RELEASE_CLANGPDB_X64_CC_FLAGS       = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
> > > >  RELEASE_CLANGPDB_X64_DLINK_FLAGS    = /NOLOGO /NODEFAULTLIB
> > > /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32
> > > /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL
> > > /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
> > > /BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
> > > >  RELEASE_CLANGPDB_X64_DLINK2_FLAGS   =
> > > >  RELEASE_CLANGPDB_X64_GENFW_FLAGS    =
> > > >
> > > > -NOOPT_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0
> > > DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
> > > > +NOOPT_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
> > > >  NOOPT_CLANGPDB_X64_DLINK_FLAGS      = /NOLOGO /NODEFAULTLIB
> > > /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL
> > > /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
> > > /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
> > > >  NOOPT_CLANGPDB_X64_DLINK2_FLAGS     =
> > > >  NOOPT_CLANGPDB_X64_GENFW_FLAGS      = --keepexceptiontable
> > > > @@ -2901,15 +2901,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS     =
> > > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
> > > >  *_CLANGDWARF_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS)
> > > DEF(CLANG38_X64_TARGET)
> > > >  *_CLANGDWARF_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS)
> > > DEF(CLANG38_X64_TARGET)
> > > >
> > > > -DEBUG_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
> > > -flto DEF(CLANG38_X64_TARGET) -g
> > > > +DEBUG_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
> > > >  DEBUG_CLANGDWARF_X64_DLINK_FLAGS      =
> > > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
> > > -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
> > > -Wl,--apply-dynamic-relocs
> > > >  DEBUG_CLANGDWARF_X64_DLINK2_FLAGS     =
> > > DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld
> > > >
> > > > -RELEASE_CLANGDWARF_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
> > > -flto DEF(CLANG38_X64_TARGET)
> > > > +RELEASE_CLANGDWARF_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
> > > >  RELEASE_CLANGDWARF_X64_DLINK_FLAGS    =
> > > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
> > > -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
> > > -Wl,--apply-dynamic-relocs
> > > >  RELEASE_CLANGDWARF_X64_DLINK2_FLAGS   =
> > > DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld
> > > >
> > > > -NOOPT_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0
> > > DEF(CLANG38_X64_TARGET) -g
> > > > +NOOPT_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > > -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
> > > >  NOOPT_CLANGDWARF_X64_DLINK_FLAGS      =
> > > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64
> > > -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
> > > -Wl,--apply-dynamic-relocs
> > > >  NOOPT_CLANGDWARF_X64_DLINK2_FLAGS     =
> > > DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
>
>
>
>


Pedro Falcato
 

GCC 5.4 documentation (https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/x86-Options.html#x86-Options) doesn't include x86-64. I assume that specific option was added somewhere in the last 2-3 years when this x86-64-v* concept was added?

I went looking around in linux and they don't seem to specify anything of sorts either.

I can't speak for ARM but for IA32 it's pretty logic: the Pentium 1 (i586) was the first processor with CPUID, RDTSC, RD/WRMSR, etc. Essentials for firmware code that will never really even run on a processor that old.


On Thu, Jun 30, 2022 at 12:25 AM dann frazier <dann.frazier@...> wrote:
On Wed, Jun 29, 2022 at 11:06:01PM +0100, Pedro Falcato wrote:
> This may be a strong opinion but I would consider toolchains that
> explicitly change the default -march from the well understood x86-64 (which
> all 64-bit processors support) to be totally broken. If a distro wants to
> switch the -march for the packages, override CFLAGS :)

Opinion noted. But is there a downside to edk2 being explicit about
its target CPU level on x86-64, given it already does so for IA32 and
ARM?

  -dann

> On Wed, Jun 29, 2022 at 10:57 PM dann frazier <dann.frazier@...>
> wrote:
>
> > Ping on this. Would it be more palatable if I limited the change only
> > to tested toolchains (gcc/clang)? Alternatively, is there a way to
> > submit this code to CI to verify the !(gcc|clang) variants?
> >
> >   -dann
> >
> > On Fri, Jun 10, 2022 at 12:09:18PM -0600, dann frazier wrote:
> > > From: dann frazier <dann.frazier@...>
> > >
> > > Some Linux distributions are experimenting with builds that target a
> > > higher x86-64 psABI, such as x86-64-v3. To avoid inheriting these
> > > compiler defaults in edk2 builds, and therefore breaking compatibility
> > > with machines using older CPUs, explicitly target the generic x86-64
> > > psABI. This is similar to how we explicitly specify the cpu type for
> > > some other architectures (-march=i586 for IA32, -march=armv7-a for ARM).
> > >
> > > Spot tested with OVMF builds using GCC5 and CLANG38.
> > >
> > > Signed-off-by: dann frazier <dann.frazier@...>
> > > ---
> > >  BaseTools/Conf/tools_def.template | 20 ++++++++++----------
> > >  1 file changed, 10 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/BaseTools/Conf/tools_def.template
> > b/BaseTools/Conf/tools_def.template
> > > index adcd23f727..569d16fb3e 100755
> > > --- a/BaseTools/Conf/tools_def.template
> > > +++ b/BaseTools/Conf/tools_def.template
> > > @@ -1885,7 +1885,7 @@ DEFINE GCC_DEPS_FLAGS              = -MMD -MF
> > $@.deps
> > >  DEFINE GCC48_ALL_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS)
> > -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
> > >  DEFINE GCC48_IA32_X64_DLINK_COMMON   = -nostdlib
> > -Wl,-n,-q,--gc-sections -z common-page-size=0x20
> > >  DEFINE GCC48_IA32_CC_FLAGS           = DEF(GCC48_ALL_CC_FLAGS) -m32
> > -march=i586 -malign-double -fno-stack-protector -D EFI32
> > -fno-asynchronous-unwind-tables -Wno-address
> > > -DEFINE GCC48_X64_CC_FLAGS            = DEF(GCC48_ALL_CC_FLAGS) -m64
> > -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
> > -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
> > -fno-asynchronous-unwind-tables -Wno-address
> > > +DEFINE GCC48_X64_CC_FLAGS            = DEF(GCC48_ALL_CC_FLAGS) -m64
> > -march=x86-64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
> > -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
> > -fno-asynchronous-unwind-tables -Wno-address
> > >  DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON)
> > -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
> > >  DEFINE GCC48_IA32_X64_DLINK_FLAGS    = DEF(GCC48_IA32_X64_DLINK_COMMON)
> > -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
> > -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
> > >  DEFINE GCC48_IA32_DLINK2_FLAGS       =
> > -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
> > > @@ -2613,15 +2613,15 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS     =
> > DEF(GCC5_IA32_DLINK2_FLAGS) -O0
> > >  *_CLANG38_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS)
> > DEF(CLANG38_X64_TARGET)
> > >  *_CLANG38_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS)
> > DEF(CLANG38_X64_TARGET)
> > >
> > > -DEBUG_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
> > -flto DEF(CLANG38_X64_TARGET) -g
> > > +DEBUG_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
> > >  DEBUG_CLANG38_X64_DLINK_FLAGS      = DEF(GCC5_IA32_X64_DLINK_FLAGS)
> > -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
> > -mcmodel=small
> > >  DEBUG_CLANG38_X64_DLINK2_FLAGS     = DEF(GCC5_X64_DLINK2_FLAGS) -O3
> > >
> > > -RELEASE_CLANG38_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
> > -flto DEF(CLANG38_X64_TARGET)
> > > +RELEASE_CLANG38_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
> > >  RELEASE_CLANG38_X64_DLINK_FLAGS    = DEF(GCC5_IA32_X64_DLINK_FLAGS)
> > -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
> > -mcmodel=small
> > >  RELEASE_CLANG38_X64_DLINK2_FLAGS   = DEF(GCC5_X64_DLINK2_FLAGS) -O3
> > >
> > > -NOOPT_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0
> > DEF(CLANG38_X64_TARGET) -g
> > > +NOOPT_CLANG38_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
> > >  NOOPT_CLANG38_X64_DLINK_FLAGS      = DEF(GCC5_IA32_X64_DLINK_FLAGS)
> > -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
> > >  NOOPT_CLANG38_X64_DLINK2_FLAGS     = DEF(GCC5_X64_DLINK2_FLAGS) -O0
> > >
> > > @@ -2798,17 +2798,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS     =
> > >  *_CLANGPDB_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS)
> > DEF(CLANGPDB_X64_TARGET)
> > >  *_CLANGPDB_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS)
> > DEF(CLANGPDB_X64_TARGET)
> > >
> > > -DEBUG_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto
> > DEF(CLANGPDB_X64_TARGET) -gcodeview  -funwind-tables
> > > +DEBUG_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview
> > -funwind-tables
> > >  DEBUG_CLANGPDB_X64_DLINK_FLAGS      = /NOLOGO /NODEFAULTLIB
> > /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL
> > /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
> > /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
> > >  DEBUG_CLANGPDB_X64_DLINK2_FLAGS     =
> > >  DEBUG_CLANGPDB_X64_GENFW_FLAGS      = --keepexceptiontable
> > >
> > > -RELEASE_CLANGPDB_X64_CC_FLAGS       = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto
> > DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
> > > +RELEASE_CLANGPDB_X64_CC_FLAGS       = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
> > >  RELEASE_CLANGPDB_X64_DLINK_FLAGS    = /NOLOGO /NODEFAULTLIB
> > /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32
> > /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL
> > /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
> > /BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
> > >  RELEASE_CLANGPDB_X64_DLINK2_FLAGS   =
> > >  RELEASE_CLANGPDB_X64_GENFW_FLAGS    =
> > >
> > > -NOOPT_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0
> > DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
> > > +NOOPT_CLANGPDB_X64_CC_FLAGS         = DEF(CLANGPDB_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
> > >  NOOPT_CLANGPDB_X64_DLINK_FLAGS      = /NOLOGO /NODEFAULTLIB
> > /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL
> > /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO
> > /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
> > >  NOOPT_CLANGPDB_X64_DLINK2_FLAGS     =
> > >  NOOPT_CLANGPDB_X64_GENFW_FLAGS      = --keepexceptiontable
> > > @@ -2901,15 +2901,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS     =
> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
> > >  *_CLANGDWARF_X64_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS)
> > DEF(CLANG38_X64_TARGET)
> > >  *_CLANGDWARF_X64_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS)
> > DEF(CLANG38_X64_TARGET)
> > >
> > > -DEBUG_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
> > -flto DEF(CLANG38_X64_TARGET) -g
> > > +DEBUG_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
> > >  DEBUG_CLANGDWARF_X64_DLINK_FLAGS      =
> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
> > -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
> > -Wl,--apply-dynamic-relocs
> > >  DEBUG_CLANGDWARF_X64_DLINK2_FLAGS     =
> > DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld
> > >
> > > -RELEASE_CLANGDWARF_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz
> > -flto DEF(CLANG38_X64_TARGET)
> > > +RELEASE_CLANGDWARF_X64_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
> > >  RELEASE_CLANGDWARF_X64_DLINK_FLAGS    =
> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
> > -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
> > -Wl,--apply-dynamic-relocs
> > >  RELEASE_CLANGDWARF_X64_DLINK2_FLAGS   =
> > DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld
> > >
> > > -NOOPT_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0
> > DEF(CLANG38_X64_TARGET) -g
> > > +NOOPT_CLANGDWARF_X64_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m64
> > -march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
> > -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
> > >  NOOPT_CLANGDWARF_X64_DLINK_FLAGS      =
> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64
> > -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
> > -Wl,--apply-dynamic-relocs
> > >  NOOPT_CLANGDWARF_X64_DLINK2_FLAGS     =
> > DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld
> > >
> >
> >
> >
> >
> >
> >
>


--
Pedro Falcato


dann frazier
 

Hi Pedro,

Yeah, apparently GCC didn't document it until 8.1.0:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=c7cb6c178884
But it appears to have been introduced far earlier - best I can tell,
in 4.1:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=3fec9fa9b726
It seems to be unrelated to the introduction of x86-64-v*, which was
in 11.1:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=324bec558e95

I don't speak GCC source fluently, so it's possible I could've
misinterpreted those commits, so I did some testing. Ubuntu 16.04 had
compilers based on GCC 5.4.0 and clang 4.0. Both accept -march=x86-64:

$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc hello.c -o hello -march=x86-64

$ clang-4.0 --version
clang version 4.0.0-1ubuntu1~16.04.2 (tags/RELEASE_400/rc1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang-4.0 hello.c -o hello -march=x86-64
$

Going all the way back to Ubuntu 12.04, which included compilers based
on GCC 4.4.7 and clang 3.3:

$ gcc-4.4 --version
gcc-4.4 (Ubuntu/Linaro 4.4.7-1ubuntu2) 4.4.7
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc-4.4 test.c -o test -march=x86-64
$ clang --version
Ubuntu clang version 3.3-5ubuntu4~precise1 (branches/release_33) (based on LLVM 3.3)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang test.c -o test -march=x86-64
$

-dann

On Thu, Jun 30, 2022 at 02:05:52AM +0100, Pedro Falcato wrote:
GCC 5.4 documentation (
https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/x86-Options.html#x86-Options)
doesn't include x86-64. I assume that specific option was added somewhere
in the last 2-3 years when this x86-64-v* concept was added?

I went looking around in linux and they don't seem to specify anything of
sorts either.

I can't speak for ARM but for IA32 it's pretty logic: the Pentium 1 (i586)
was the first processor with CPUID, RDTSC, RD/WRMSR, etc. Essentials for
firmware code that will never really even run on a processor that old.

On Thu, Jun 30, 2022 at 12:25 AM dann frazier <dann.frazier@...>
wrote:

On Wed, Jun 29, 2022 at 11:06:01PM +0100, Pedro Falcato wrote:
This may be a strong opinion but I would consider toolchains that
explicitly change the default -march from the well understood x86-64
(which
all 64-bit processors support) to be totally broken. If a distro wants to
switch the -march for the packages, override CFLAGS :)
Opinion noted. But is there a downside to edk2 being explicit about
its target CPU level on x86-64, given it already does so for IA32 and
ARM?

-dann

On Wed, Jun 29, 2022 at 10:57 PM dann frazier <
dann.frazier@...>
wrote:

Ping on this. Would it be more palatable if I limited the change only
to tested toolchains (gcc/clang)? Alternatively, is there a way to
submit this code to CI to verify the !(gcc|clang) variants?

-dann

On Fri, Jun 10, 2022 at 12:09:18PM -0600, dann frazier wrote:
From: dann frazier <dann.frazier@...>

Some Linux distributions are experimenting with builds that target a
higher x86-64 psABI, such as x86-64-v3. To avoid inheriting these
compiler defaults in edk2 builds, and therefore breaking
compatibility
with machines using older CPUs, explicitly target the generic x86-64
psABI. This is similar to how we explicitly specify the cpu type for
some other architectures (-march=i586 for IA32, -march=armv7-a for
ARM).

Spot tested with OVMF builds using GCC5 and CLANG38.

Signed-off-by: dann frazier <dann.frazier@...>
---
BaseTools/Conf/tools_def.template | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template
b/BaseTools/Conf/tools_def.template
index adcd23f727..569d16fb3e 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1885,7 +1885,7 @@ DEFINE GCC_DEPS_FLAGS = -MMD -MF
$@.deps
DEFINE GCC48_ALL_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS)
-ffunction-sections -fdata-sections
-DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib
-Wl,-n,-q,--gc-sections -z common-page-size=0x20
DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32
-march=i586 -malign-double -fno-stack-protector -D EFI32
-fno-asynchronous-unwind-tables -Wno-address
-DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64
-fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small
-fpie
-fno-asynchronous-unwind-tables -Wno-address
+DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64
-march=x86-64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small
-fpie
-fno-asynchronous-unwind-tables -Wno-address
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS =
DEF(GCC48_IA32_X64_DLINK_COMMON)
-Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
DEFINE GCC48_IA32_X64_DLINK_FLAGS =
DEF(GCC48_IA32_X64_DLINK_COMMON)
-Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
-Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
DEFINE GCC48_IA32_DLINK2_FLAGS =
-Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
@@ -2613,15 +2613,15 @@ NOOPT_CLANG38_IA32_DLINK2_FLAGS =
DEF(GCC5_IA32_DLINK2_FLAGS) -O0
*_CLANG38_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANG38_X64_TARGET)
*_CLANG38_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANG38_X64_TARGET)

-DEBUG_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie
-Oz
-flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
DEBUG_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
-mcmodel=small
DEBUG_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O3

-RELEASE_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie
-Oz
-flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
RELEASE_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
-mcmodel=small
RELEASE_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O3

-NOOPT_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie
-O0
DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANG38_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
NOOPT_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS)
-Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
-mcmodel=small
NOOPT_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) -O0

@@ -2798,17 +2798,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =
*_CLANGPDB_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANGPDB_X64_TARGET)
*_CLANGPDB_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANGPDB_X64_TARGET)

-DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS)
-m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz
-flto
DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
+DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS)
-m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview
-funwind-tables
DEBUG_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64
/DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
/SAFESEH:NO
/BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
DEBUG_CLANGPDB_X64_DLINK2_FLAGS =
DEBUG_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable

-RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS)
-m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz
-flto
DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
+RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS)
-m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
RELEASE_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32
/SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
/SAFESEH:NO
/BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
RELEASE_CLANGPDB_X64_DLINK2_FLAGS =
RELEASE_CLANGPDB_X64_GENFW_FLAGS =

-NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS)
-m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0
DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
+NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS)
-m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
NOOPT_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB
/IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64
/DLL
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
/SAFESEH:NO
/BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
NOOPT_CLANGPDB_X64_DLINK2_FLAGS =
NOOPT_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable
@@ -2901,15 +2901,15 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS =
DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
*_CLANGDWARF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
DEF(CLANG38_X64_TARGET)
*_CLANGDWARF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
DEF(CLANG38_X64_TARGET)

-DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS)
-m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie
-Oz
-flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS)
-m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
DEBUG_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
DEBUG_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

-RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS)
-m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie
-Oz
-flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS)
-m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
RELEASE_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
RELEASE_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld

-NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS)
-m64
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie
-O0
DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS)
-m64
-march=x86-64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone
-mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
NOOPT_CLANGDWARF_X64_DLINK_FLAGS =
DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64
-Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small
-Wl,--apply-dynamic-relocs
NOOPT_CLANGDWARF_X64_DLINK2_FLAGS =
DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld