On Oct 8, 2019, at 3:29 PM, Laszlo Ersek <lersek@redhat.com> wrote:

On 10/08/19 17:02, Gao, Liming wrote:
Laszlo:

-----Original Message-----
From: Laszlo Ersek <lersek@redhat.com>
Sent: Tuesday, October 1, 2019 4:42 AM
To: devel@edk2.groups.io; Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2-devel] [Patch 11/12] OvmfPkg: Enable CLANG9 tool chain

Hi Liming,

On 09/27/19 09:46, Liming Gao wrote:
1. Apply CLANG9 Linker option.

I'm confused by this, in two regards.

- Why do we refer to CLANG9 first as being in the GCC toolchain family
(see near mmx/sse), and then under a totally different family name
(CLANGPE?)

CLANGPE is used to override GCC option. GCC is used to append GCC options. 
You can see XCODE5 take the same way. 
CLANG9 tool chain doesn't recognize -z common-page-size=0x1000 option. 
So, here CLANGPE is used to specify /ALIGN:4096 option. 

Wait, so the "GCC" toolchain *family* applies to:
- actual GCC toolchains (such as GCC48, GCC49, GCC5)
- XCODE toolchains (such as XCODE5)
- CLANG toolchains (such as CLANG9)

but the "XCODE" toolchain *family* only applies to XCODE toolchains
(such as XCODE5), and similarly, the CLANGPE toolchain *family* only
applies to CLANG toolchains (such as CLANG9)?

Put differently, is XCODE in two toolchain families at the same time
(GCC and XCODE)?

Similarly, is CLANG9 in two toolchain families at the same time (GCC and
CLANGPE)?

Wait... from "BaseTools/Conf/tools_def.template":


#
#
# XCODE5 support
#

*_XCODE5_*_*_FAMILY            = GCC
*_XCODE5_*_*_BUILDRULEFAMILY   = XCODE

This makes me very unhappy. I don't know how anyone can follow this.

What is the difference between "FAMILY" and "BUILDRULEFAMILY"?

When I see

  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
  XCODE:*_*_*_DLINK_FLAGS =

how can I know that the first line applies due to "FAMILY", but the
second line also applies due to "BUILDRULEFAMILY" (and overrides the
first line)?

Hmmm....

https://edk2-docs.gitbooks.io/edk-ii-build-specification/5_meta-data_file_specifications/52_tools_def_txt.html

"""
FAMILY -- A flag to the build command that will be used to ensure the
         correct commands and flags are used in the generated Makefile
         or GNUMakefile, as well as to use the correct options for
         independent tools, such as the ACPI compiler. This is
         typically used to identify the type of Makefile that needs to
         be generated.

BUILDRULEFAMILY -- This flag is used by some tool chain tags to set a
                  special FAMILY value when processing the
                  build_rule.txt file. Normally, the FAMILY attribute
                  is used to identify the type of makefile the tools
                  need to generate. Tools such as XCODE will use GCC as
                  the FAMILY, but uses different (from GCC) processing
                  rules. If present and if a build rule (in
                  build_rules.txt) contains an attribute with the value
                  specified in this entry, that rule will be processed
                  and the rule with the FAMILY attribute will be
                  ignored.
"""

Well, I can't say that it's entirely clear to me what applies when. :/



Laszlo,

If you just have  *_*_*_*_FAMILY then that matches the statements in the INF and DSC files (It also matters for build_rule.txt) like this example for GCC [1]. 

When you have *_*_*_*_FAMILY and *_*_*_*_BUILDRULEFAMILY you get 2 levels. Thus XCODE is generally compatible with GCC so it is in that *_*_*_*_FAMILY, but if you need to do something XCODE specific you can use the XCODE *_*_*_*_BUILDRULEFAMILY. If we did not have 2 levels every place we had GCC would need XCODE and see the list [1]. Thus XCODE can use GCC when it is compatible with GCC (which is a majority of the time) and then use XCODE to have XCODE rules that are different than GCC. 

So I guess the way to describe it is XCODE inherits GCC and only needs to override when it is different.

As per usual we seem to have picked confusing names. 


In particular because in this patch, we don't use BUILDRULEFAMILY for
overrides in "build_rules.txt", we use BUILDRULEFAMILY for overrides in
DSC files.


Anyway, let's say that we use the following syntax for linker flag
overrides:

[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
 GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
 XCODE:*_*_*_DLINK_FLAGS =
 CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096

Fine.

But then, why don't we similarly use:

[BuildOptions]
 GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
 XCODE:*_*_*_CC_FLAGS                 =
 CLANGPE:*_*_*_CC_FLAGS               =

for CC flag overrides?

Because, the proposal is:

!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9"
 GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
!endif


Is this really the same as:
  XCODE: *_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
  GCC:*_CLANG8_*_CC_FLAGS            = -mno-mmx -mno-sse

Also for CLANG38 the above flags are part of CLANG38_ALL_CC_FLAGS. I they are needed then why are they not part of the generic tool chain definition? 

[1] git grep GCC -- *.inf *.dsc
ArmPkg/ArmPkg.dsc:93:  # Add support for GCC stack protector
ArmPkg/Drivers/ArmGic/ArmGicLib.inf:24:  GicV3/Arm/ArmGicV3.S     | GCC
ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf:37:  Arm/ExceptionSupport.S   | GCC
ArmPkg/Library/ArmExceptionLib/ArmRelocateExceptionLib.inf:32:  Arm/ExceptionSupport.S   | GCC
ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf:19:  Arm/ArmHvc.S      | GCC
ArmPkg/Library/ArmLib/ArmBaseLib.inf:28:  Arm/ArmLibSupport.S           | GCC
ArmPkg/Library/ArmLib/ArmBaseLib.inf:29:  Arm/ArmLibSupportV7.S         | GCC
ArmPkg/Library/ArmLib/ArmBaseLib.inf:30:  Arm/ArmV7Support.S            | GCC
ArmPkg/Library/ArmLib/ArmBaseLib.inf:31:  Arm/ArmV7ArchTimerSupport.S   | GCC
ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf:25:  Arm/ArmMmuLibV7Support.S   |GCC
ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf:18:  Arm/ArmSmc.S      | GCC
ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf:19:  AArch64/Reset.S   | GCC
ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf:23:  Arm/Reset.S       | GCC
ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf:57:  berkeley-softfloat-3/source/include/opts-GCC.h
ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf:92:  GCC:*_*_*_CC_FLAGS = -fno-lto -ffreestanding -Wno-unused-label
ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf:18:  Arm/ArmSvc.S      | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:24:  memcpy.c             | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:25:  memset.c             | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:45:  Arm/ashrdi3.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:46:  Arm/ashldi3.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:47:  Arm/div.S            | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:48:  Arm/divdi3.S         | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:49:  Arm/divsi3.S         | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:50:  Arm/lshrdi3.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:51:  Arm/memmove.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:52:  Arm/modsi3.S         | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:53:  Arm/moddi3.S         | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:54:  Arm/muldi3.S         | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:55:  Arm/mullu.S          | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:56:  Arm/udivsi3.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:57:  Arm/umodsi3.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:58:  Arm/udivdi3.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:59:  Arm/umoddi3.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:60:  Arm/udivmoddi4.S     | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:61:  Arm/clzsi2.S         | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:62:  Arm/ctzsi2.S         | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:63:  Arm/ucmpdi2.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:64:  Arm/switch8.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:65:  Arm/switchu8.S       | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:66:  Arm/switch16.S       | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:67:  Arm/switch32.S       | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:68:  Arm/sourcery.S       | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:69:  Arm/uldiv.S          | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:70:  Arm/ldivmod.S        | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:71:  Arm/lasr.S           | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:72:  Arm/llsr.S           | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:73:  Arm/llsl.S           | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:74:  Arm/uread.S          | GCC
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf:75:  Arm/uwrite.S         | GCC
ArmPkg/Library/SemihostLib/SemihostLib.inf:30:  Arm/GccSemihost.S | GCC
ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf:31:  Arm/ArmPlatformHelper.S    | GCC
ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf:25:  Arm/ArmPlatformStackLib.S       | GCC
ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf:25:  Arm/PrePeiCoreEntryPoint.S   | GCC
ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf:27:  Arm/SwitchStack.S        | GCC
ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf:29:  Arm/Exception.S          | GCC
ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf:25:  Arm/PrePeiCoreEntryPoint.S   | GCC
ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf:27:  Arm/SwitchStack.S        | GCC
ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf:29:  Arm/Exception.S          | GCC
ArmPlatformPkg/PrePi/PeiMPCore.inf:24:  Arm/ModuleEntryPoint.S   | GCC
ArmPlatformPkg/PrePi/PeiUniCore.inf:24:  Arm/ModuleEntryPoint.S   | GCC
ArmVirtPkg/ArmVirtQemuKernel.dsc:90:  GCC:*_CLANG38_*_CC_FLAGS = -include $(WORKSPACE)/ArmVirtPkg/Include/Platform/Hidden.h
ArmVirtPkg/ArmVirtXen.dsc:61:  GCC:*_CLANG38_*_CC_FLAGS = -include $(WORKSPACE)/ArmVirtPkg/Include/Platform/Hidden.h
ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf:100:  GCC:*_*_*_DLINK_FLAGS = -Wl,-Bsymbolic,-pie,-T,$(MODULE_DIR)/Scripts/PrePi-PIE.lds
CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf:102:  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf:103:  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf:97:  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf:98:  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf:108:  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf:109:  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf:105:  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf:106:  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf:38:  Ia32/MathLShiftS64.nasm   | GCC
CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf:39:  Ia32/MathRShiftU64.nasm   | GCC
CryptoPkg/Library/OpensslLib/OpensslLib.inf:659:  GCC:*_*_IA32_CC_FLAGS    = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable
CryptoPkg/Library/OpensslLib/OpensslLib.inf:660:  GCC:*_*_X64_CC_FLAGS     = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-error=format -Wno-format -Wno-error=unused-but-set-variable -DNO_MSABI_VA_FUNCS
CryptoPkg/Library/OpensslLib/OpensslLib.inf:661:  GCC:*_*_ARM_CC_FLAGS     = $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable
CryptoPkg/Library/OpensslLib/OpensslLib.inf:662:  GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable
CryptoPkg/Library/OpensslLib/OpensslLib.inf:663:  GCC:*_CLANG35_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
CryptoPkg/Library/OpensslLib/OpensslLib.inf:664:  GCC:*_CLANG38_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
CryptoPkg/Library/OpensslLib/OpensslLib.inf:698:  GCC:*_*_AARCH64_CC_XIPFLAGS ==
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:607:  GCC:*_*_IA32_CC_FLAGS    = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:608:  GCC:*_*_X64_CC_FLAGS     = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-error=format -Wno-format -Wno-error=unused-but-set-variable -DNO_MSABI_VA_FUNCS
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:609:  GCC:*_*_ARM_CC_FLAGS     = $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:610:  GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:611:  GCC:*_CLANG35_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:612:  GCC:*_CLANG38_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:646:  GCC:*_*_AARCH64_CC_XIPFLAGS ==
EmbeddedPkg/EmbeddedPkg.dsc:128:  # Add support for GCC stack protector
EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf:35:# Current usage of this library expects GCC in a UNIX-like shell environment with the date command
EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf:37:  GCC:*_*_*_CC_FLAGS = -DBUILD_EPOCH=`date +%s`
EmulatorPkg/Unix/Host/Host.inf:115:   GCC:*_*_IA32_DLINK_FLAGS == -o $(BIN_DIR)/Host -m32 -L/usr/X11R6/lib
EmulatorPkg/Unix/Host/Host.inf:116:   GCC:*_*_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
EmulatorPkg/Unix/Host/Host.inf:117:   GCC:*_*_IA32_PP_FLAGS == -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
EmulatorPkg/Unix/Host/Host.inf:118:   GCC:*_*_IA32_ASM_FLAGS == -m32 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
EmulatorPkg/Unix/Host/Host.inf:120:   GCC:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/Host -m64 -L/usr/X11R6/lib
EmulatorPkg/Unix/Host/Host.inf:121:   GCC:*_GCC5_X64_DLINK_FLAGS == -flto -o $(BIN_DIR)/Host -m64 -L/usr/X11R6/lib
EmulatorPkg/Unix/Host/Host.inf:122:   GCC:*_*_X64_CC_FLAGS == -m64 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
EmulatorPkg/Unix/Host/Host.inf:123:   GCC:*_GCC48_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"
EmulatorPkg/Unix/Host/Host.inf:124:   GCC:*_GCC49_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"
EmulatorPkg/Unix/Host/Host.inf:125:   GCC:*_GCC5_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -flto -DUSING_LTO -Os
EmulatorPkg/Unix/Host/Host.inf:126:   GCC:*_*_X64_PP_FLAGS == -m64 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
EmulatorPkg/Unix/Host/Host.inf:127:   GCC:*_*_X64_ASM_FLAGS == -m64 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
EmulatorPkg/Unix/Host/Host.inf:129:   GCC:*_*_*_DLINK2_FLAGS == -lpthread -ldl -lXext -lX11
FatPkg/FatPkg.dsc:23:  GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf:39:  RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf:34:  RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf:33:  RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf:108:  GCC:*_*_*_CC_FLAGS = -Wno-error=maybe-uninitialized
MdePkg/Library/BaseCpuLib/BaseCpuLib.inf:37:  Ia32/CpuSleepGcc.c | GCC
MdePkg/Library/BaseCpuLib/BaseCpuLib.inf:38:  Ia32/CpuFlushTlbGcc.c | GCC
MdePkg/Library/BaseCpuLib/BaseCpuLib.inf:53:  Arm/CpuFlushTlb.S   | GCC
MdePkg/Library/BaseCpuLib/BaseCpuLib.inf:54:  Arm/CpuSleep.S      | GCC
MdePkg/Library/BaseCpuLib/BaseCpuLib.inf:57:  AArch64/CpuFlushTlb.S   | GCC
MdePkg/Library/BaseCpuLib/BaseCpuLib.inf:58:  AArch64/CpuSleep.S      | GCC
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf:37:  IoLibGcc.c    | GCC
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf:43:  IoLibGcc.c    | GCC
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicArmVirt.inf:33:  Arm/ArmVirtMmio.S       | GCC
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicArmVirt.inf:38:  AArch64/ArmVirtMmio.S   | GCC
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf:35:  IoLibGcc.c    | GCC
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf:41:  IoLibGcc.c    | GCC
MdePkg/Library/BaseLib/BaseLib.inf:157:  Ia32/GccInline.c | GCC
MdePkg/Library/BaseLib/BaseLib.inf:159:  Ia32/EnableDisableInterrupts.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:161:  Ia32/DisablePaging32.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:162:  Ia32/EnablePaging32.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:163:  Ia32/Mwait.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:164:  Ia32/Monitor.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:165:  Ia32/CpuIdEx.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:166:  Ia32/CpuId.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:169:  Ia32/SwapBytes64.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:171:  Ia32/DivU64x32Remainder.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:172:  Ia32/ModU64x32.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:173:  Ia32/DivU64x32.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:174:  Ia32/MultU64x64.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:175:  Ia32/MultU64x32.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:176:  Ia32/RRotU64.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:177:  Ia32/LRotU64.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:178:  Ia32/ARShiftU64.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:179:  Ia32/RShiftU64.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:180:  Ia32/LShiftU64.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:181:  Ia32/EnableCache.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:182:  Ia32/DisableCache.nasm| GCC
MdePkg/Library/BaseLib/BaseLib.inf:187:  Ia32/InternalSwitchStack.nasm | GCC
MdePkg/Library/BaseLib/BaseLib.inf:311:  X64/GccInline.c | GCC
MdePkg/Library/BaseLib/BaseLib.inf:315:  ChkStkGcc.c  | GCC
MdePkg/Library/BaseLib/BaseLib.inf:351:  Arm/Math64.S                  | GCC
MdePkg/Library/BaseLib/BaseLib.inf:352:  Arm/SwitchStack.S             | GCC
MdePkg/Library/BaseLib/BaseLib.inf:353:  Arm/EnableInterrupts.S        | GCC
MdePkg/Library/BaseLib/BaseLib.inf:354:  Arm/DisableInterrupts.S       | GCC
MdePkg/Library/BaseLib/BaseLib.inf:355:  Arm/GetInterruptsState.S      | GCC
MdePkg/Library/BaseLib/BaseLib.inf:356:  Arm/SetJumpLongJump.S         | GCC
MdePkg/Library/BaseLib/BaseLib.inf:357:  Arm/CpuBreakpoint.S           | GCC
MdePkg/Library/BaseLib/BaseLib.inf:358:  Arm/MemoryFence.S             | GCC
MdePkg/Library/BaseLib/BaseLib.inf:359:  Arm/SpeculationBarrier.S      | GCC
MdePkg/Library/BaseLib/BaseLib.inf:366:  AArch64/MemoryFence.S             | GCC
MdePkg/Library/BaseLib/BaseLib.inf:367:  AArch64/SwitchStack.S             | GCC
MdePkg/Library/BaseLib/BaseLib.inf:368:  AArch64/EnableInterrupts.S        | GCC
MdePkg/Library/BaseLib/BaseLib.inf:369:  AArch64/DisableInterrupts.S       | GCC
MdePkg/Library/BaseLib/BaseLib.inf:370:  AArch64/GetInterruptsState.S      | GCC
MdePkg/Library/BaseLib/BaseLib.inf:371:  AArch64/SetJumpLongJump.S         | GCC
MdePkg/Library/BaseLib/BaseLib.inf:372:  AArch64/CpuBreakpoint.S           | GCC
MdePkg/Library/BaseLib/BaseLib.inf:373:  AArch64/SpeculationBarrier.S      | GCC
MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf:82:  Arm/ScanMem.S       |GCC
MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf:83:  Arm/SetMem.S        |GCC
MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf:84:  Arm/CopyMem.S       |GCC
MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf:85:  Arm/CompareMem.S    |GCC
MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf:86:  Arm/CompareGuid.S   |GCC
MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf:28:  BaseStackCheckGcc.c  | GCC
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf:43:  Ia32/InternalGetSpinLockProperties.c | GCC
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf:44:  Ia32/GccInline.c | GCC
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf:45:  SynchronizationGcc.c  | GCC
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf:63:  Ia32/InternalGetSpinLockProperties.c | GCC
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf:64:  X64/GccInline.c | GCC
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf:65:  SynchronizationGcc.c  | GCC
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf:74:  Arm/Synchronization.S         | GCC
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf:78:  AArch64/Synchronization.S     | GCC
OvmfPkg/OvmfPkgIa32.dsc:66:  GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
OvmfPkg/OvmfPkgIa32.dsc:70:  GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
OvmfPkg/OvmfPkgIa32.dsc:78:  GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
OvmfPkg/OvmfPkgIa32.dsc:81:  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
OvmfPkg/OvmfPkgIa32.dsc:87:  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
OvmfPkg/OvmfPkgIa32X64.dsc:66:  GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
OvmfPkg/OvmfPkgIa32X64.dsc:70:  GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
OvmfPkg/OvmfPkgIa32X64.dsc:74:  GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
OvmfPkg/OvmfPkgIa32X64.dsc:83:  GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
OvmfPkg/OvmfPkgIa32X64.dsc:86:  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
OvmfPkg/OvmfPkgIa32X64.dsc:92:  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
OvmfPkg/OvmfPkgX64.dsc:66:  GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
OvmfPkg/OvmfPkgX64.dsc:70:  GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
OvmfPkg/OvmfPkgX64.dsc:74:  GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
OvmfPkg/OvmfPkgX64.dsc:83:  GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
OvmfPkg/OvmfPkgX64.dsc:86:  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
OvmfPkg/OvmfPkgX64.dsc:92:  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
OvmfPkg/OvmfXen.dsc:63:  GCC:RELEASE_*_*_CC_FLAGS             = -DMDEPKG_NDEBUG
OvmfPkg/OvmfXen.dsc:67:  GCC:*_*_*_CC_FLAGS                   = -mno-mmx -mno-sse
OvmfPkg/OvmfXen.dsc:71:  GCC:*_*_X64_GENFW_FLAGS   = --keepexceptiontable
OvmfPkg/OvmfXen.dsc:80:  GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
OvmfPkg/OvmfXen.dsc:83:  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
OvmfPkg/OvmfXen.dsc:89:  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
SecurityPkg/SecurityPkg.dsc:78:  # Add support for GCC stack protector
ShellPkg/ShellPkg.dsc:69:  # Add support for GCC stack protector
SignedCapsulePkg/SignedCapsulePkg.dsc:107:  # Add support for GCC stack protector
StandaloneMmPkg/StandaloneMmPkg.dsc:116:GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 -march=armv8-a+nofp -mstrict-align
StandaloneMmPkg/StandaloneMmPkg.dsc:117:GCC:*_*_*_CC_FLAGS = -mstrict-align
UefiPayloadPkg/UefiPayloadPkgIa32.dsc:86:  GCC:*_UNIXGCC_*_CC_FLAGS       = -DMDEPKG_NDEBUG
UefiPayloadPkg/UefiPayloadPkgIa32.dsc:87:  GCC:RELEASE_*_*_CC_FLAGS       = -DMDEPKG_NDEBUG
UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc:86:  GCC:*_UNIXGCC_*_CC_FLAGS       = -DMDEPKG_NDEBUG
UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc:87:  GCC:RELEASE_*_*_CC_FLAGS       = -DMDEPKG_NDEBUG

[2] git grep XCODE  -- *.inf *.dsc
CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf:105:  XCODE:*_*_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf:100:  XCODE:*_*_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf:111:  XCODE:*_*_*_CC_FLAGS = -std=c99
CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf:103:  XCODE:*_*_*_CC_FLAGS = -mmmx -msse -std=c99
CryptoPkg/Library/OpensslLib/OpensslLib.inf:686:  XCODE:*_*_IA32_CC_FLAGS   = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w -std=c99 -Wno-error=uninitialized
CryptoPkg/Library/OpensslLib/OpensslLib.inf:687:  XCODE:*_*_X64_CC_FLAGS    = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w -std=c99 -Wno-error=uninitialized
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:634:  XCODE:*_*_IA32_CC_FLAGS   = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w -std=c99 -Wno-error=uninitialized
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf:635:  XCODE:*_*_X64_CC_FLAGS    = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w -std=c99 -Wno-error=uninitialized
EmulatorPkg/EmulatorPkg.dsc:335:!if "XCODE5" not in $(TOOL_CHAIN_TAG)
EmulatorPkg/EmulatorPkg.dsc:380:!if "XCODE5" not in $(TOOL_CHAIN_TAG)
EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.inf:32:   XCODE:*_*_*_DLINK_PATH == gcc
EmulatorPkg/Unix/Host/Host.inf:134:   XCODE:*_*_IA32_DLINK_PATH == gcc
EmulatorPkg/Unix/Host/Host.inf:135:   XCODE:*_*_IA32_CC_FLAGS = -I$(WORKSPACE)/EmulatorPkg/Unix/Host/X11IncludeHack
EmulatorPkg/Unix/Host/Host.inf:136:   XCODE:*_*_IA32_DLINK_FLAGS == -arch i386 -o $(BIN_DIR)/Host -L/usr/X11R6/lib -lXext -lX11 -framework Carbon
EmulatorPkg/Unix/Host/Host.inf:137:   XCODE:*_*_IA32_ASM_FLAGS == -arch i386 -g
EmulatorPkg/Unix/Host/Host.inf:139:   XCODE:*_*_X64_DLINK_PATH == gcc
EmulatorPkg/Unix/Host/Host.inf:140:   XCODE:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/Host -L/usr/X11R6/lib -lXext -lX11 -framework Carbon -Wl,-no_pie
EmulatorPkg/Unix/Host/Host.inf:141:   XCODE:*_*_X64_ASM_FLAGS == -g
EmulatorPkg/Unix/Host/Host.inf:142:   XCODE:*_*_X64_CC_FLAGS = -O0 -target x86_64-apple-darwin -I$(WORKSPACE)/EmulatorPkg/Unix/Host/X11IncludeHack "-DEFIAPI=__attribute__((ms_abi))"
MdeModulePkg/MdeModulePkg.dsc:442:!if $(TOOL_CHAIN_TAG) != "XCODE5"
MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf:110:  # Not add -Wno-error=maybe-uninitialized option for XCODE
MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf:111:  # XCODE doesn't know this option
MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf:112:  XCODE:*_*_*_CC_FLAGS =
OvmfPkg/OvmfPkgIa32.dsc:69:!if $(TOOL_CHAIN_TAG) != "XCODE5"
OvmfPkg/OvmfPkgIa32.dsc:82:  XCODE:*_*_*_DLINK_FLAGS =
OvmfPkg/OvmfPkgIa32.dsc:88:  XCODE:*_*_*_DLINK_FLAGS =
OvmfPkg/OvmfPkgIa32.dsc:807:!if $(TOOL_CHAIN_TAG) != "XCODE5"
OvmfPkg/OvmfPkgIa32X64.dsc:69:!if $(TOOL_CHAIN_TAG) != "XCODE5"
OvmfPkg/OvmfPkgIa32X64.dsc:87:  XCODE:*_*_*_DLINK_FLAGS =
OvmfPkg/OvmfPkgIa32X64.dsc:93:  XCODE:*_*_*_DLINK_FLAGS =
OvmfPkg/OvmfPkgIa32X64.dsc:820:!if $(TOOL_CHAIN_TAG) != "XCODE5"
OvmfPkg/OvmfPkgX64.dsc:69:!if $(TOOL_CHAIN_TAG) != "XCODE5"
OvmfPkg/OvmfPkgX64.dsc:87:  XCODE:*_*_*_DLINK_FLAGS =
OvmfPkg/OvmfPkgX64.dsc:93:  XCODE:*_*_*_DLINK_FLAGS =
OvmfPkg/OvmfPkgX64.dsc:818:!if $(TOOL_CHAIN_TAG) != "XCODE5"
OvmfPkg/OvmfXen.dsc:66:!if $(TOOL_CHAIN_TAG) != "XCODE5"
OvmfPkg/OvmfXen.dsc:84:  XCODE:*_*_*_DLINK_FLAGS =
OvmfPkg/OvmfXen.dsc:90:  XCODE:*_*_*_DLINK_FLAGS =
OvmfPkg/OvmfXen.dsc:689:!if $(TOOL_CHAIN_TAG) != "XCODE5"
SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf:63:  XCODE:*_*_*_CC_FLAGS = -mmmx -msse

Thanks,

Andrew Fish

I mean, in one case (for the linker flags), we rely on BUILDRULEFAMILY
for specifying the override.

But in the other case (for the C compilation flags), we do not rely on
BUILDRULEFAMILY; instead we check $(TOOL_CHAIN_TAG).

Is this difference justified? Why?


The rest of your answers sounds good to me. Thanks!
Laszlo