[edk2-devel] [PATCH V2 2/2] BaseTools: Factorize GCC flags

Leif Lindholm leif at nuviainc.com
Thu Aug 27 15:25:11 UTC 2020


On Thu, Aug 27, 2020 at 16:55:11 +0200, Laszlo Ersek wrote:
> On 08/27/20 10:32, Pierre Gondois wrote:
> > Hello Laszlo,
> > I thought Leif wanted to revert this modification. Should I apply
> your requested changes, or should this patch be reverted?
> 
> The *other* patch in this series has indeed been reverted:
> 
> - original commit: dbd546a32d5a ("BaseTools: Add gcc flag to warn on
> void* pointer arithmetic", 2020-07-21)
> 
> - revert: 91e4bcb313f0 ("Revert "BaseTools: Add gcc flag to warn on
> void* pointer arithmetic"", 2020-07-24)
> 
> I'm not sure what the intent was ultimately with this patch though.
> (I.e., keep it or revert it.) Personally I'm not calling for a revert;
> I'd just like the "-Os" duplication to be eliminated. Also it doesn't
> need to occur for this stable tag, just eventually.
> 
> Leif, please comment!

I did propose reverting it. But I asked for Ard's feedback on the
reason for why we had the break in the flags-chain, in case he
remembered (and he was on holiday at the time).

Basically, I'm wondering whether we're better off changing this
behaviour or simply nuking GCC48.

Regards,

Leif


> Thanks!
> Laszlo
> 
> > 
> > Regards,
> > Pierre
> > 
> > -----Original Message-----
> > From: Laszlo Ersek <lersek at redhat.com> 
> > Sent: Wednesday, August 26, 2020 5:43 PM
> > To: Pierre Gondois <Pierre.Gondois at arm.com>
> > Cc: devel at edk2.groups.io; bob.c.feng at intel.com; liming.gao at intel.com; Tomas Pilar <Tomas.Pilar at arm.com>; nd <nd at arm.com>; Leif Lindholm (Nuvia address) <leif at nuviainc.com>; Ard Biesheuvel <Ard.Biesheuvel at arm.com>
> > Subject: Re: [edk2-devel] [PATCH V2 2/2] BaseTools: Factorize GCC flags
> > 
> > On 07/22/20 13:03, Laszlo Ersek wrote:
> >> Hi Pierre,
> >>
> >> On 07/07/20 10:35, PierreGondois wrote:
> >>> From: Pierre Gondois <pierre.gondois at arm.com>
> >>>
> >>> GCC48_ALL_CC_FLAGS has no dependency on GCC_ALL_CC_FLAGS.
> >>> By definition, there should be such dependency.
> >>>
> >>> The outcomes of this patch is that GCC48_ALL_CC_FLAGS and other 
> >>> dependent configurations will inherit from the additional "-Os" flag.
> >>> The "-Os" flag optimizes a build in size, not breaking any build. In 
> >>> a gcc command line, the last optimization flag has precedence. This 
> >>> means that this "-Os" flag will be overriden by a more specific 
> >>> optimization configuration, provided that this more specific flag is 
> >>> appended at the end of the CC_FLAGS.
> >>>
> >>> Signed-off-by: Pierre Gondois <pierre.gondois at arm.com>
> >>> Suggested-by: Tomas Pilar <Tomas.Pilar at arm.com>
> >>> ---
> >>>
> >>> The changes can be seen at: 
> >>> https://github.com/PierreARM/edk2/commits/831_Add_gcc_flag_warning_v2
> >>>
> >>> Notes:
> >>>     v2:
> >>>      - Make GCC48_ALL_CC_FLAGS dependent on
> >>>        GCC_ALL_CC_FLAGS. [Tomas]
> >>>
> >>>  BaseTools/Conf/tools_def.template | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/BaseTools/Conf/tools_def.template 
> >>> b/BaseTools/Conf/tools_def.template
> >>> index 
> >>> 397b011ba38f97f81f314f8641ac8bb95d5a2197..a1fd27b1adba8769949b7d628d7
> >>> fbed49fe24267 100755
> >>> --- a/BaseTools/Conf/tools_def.template
> >>> +++ b/BaseTools/Conf/tools_def.template
> >>> @@ -1952,7 +1952,7 @@ DEFINE GCC_RISCV64_RC_FLAGS        = -I binary -O elf64-littleriscv   -B riscv
> >>>  # GCC Build Flag for included header file list generation
> >>>  DEFINE GCC_DEPS_FLAGS              = -MMD -MF $@.deps
> >>>  
> >>> -DEFINE GCC48_ALL_CC_FLAGS            = -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
> >>> +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
> >>>
> >>
> >> As the commit message states, this change makes GCC48_ALL_CC_FLAGS inherit "-Os".
> >>
> >> It is true that all the NOOPT_GCC flags override "-Os" with "-O0":
> >>
> >> NOOPT_GCC48_IA32_CC_FLAGS       = DEF(GCC48_IA32_CC_FLAGS) -O0
> >> NOOPT_GCC48_X64_CC_FLAGS       = DEF(GCC48_X64_CC_FLAGS) -O0
> >> NOOPT_GCC48_ARM_CC_FLAGS       = DEF(GCC48_ARM_CC_FLAGS) -O0
> >> NOOPT_GCC48_AARCH64_CC_FLAGS   = DEF(GCC48_AARCH64_CC_FLAGS) -O0
> >> NOOPT_GCC49_IA32_CC_FLAGS       = DEF(GCC49_IA32_CC_FLAGS) -O0
> >> NOOPT_GCC49_X64_CC_FLAGS       = DEF(GCC49_X64_CC_FLAGS) -O0
> >> NOOPT_GCC49_ARM_CC_FLAGS       = DEF(GCC49_ARM_CC_FLAGS) -O0
> >> NOOPT_GCC49_AARCH64_CC_FLAGS     = DEF(GCC49_AARCH64_CC_FLAGS) -O0
> >> NOOPT_GCC5_IA32_CC_FLAGS       = DEF(GCC5_IA32_CC_FLAGS) -O0
> >> NOOPT_GCC5_X64_CC_FLAGS        = DEF(GCC5_X64_CC_FLAGS) -O0
> >> NOOPT_GCC5_ARM_CC_FLAGS        = DEF(GCC5_ARM_CC_FLAGS) -O0
> >> NOOPT_GCC5_AARCH64_CC_FLAGS    = DEF(GCC5_AARCH64_CC_FLAGS) -O0
> >>
> >> However, *some* of the DEBUG and RELEASE flags now have two "-Os" flags:
> >>
> >>   DEBUG_GCC48_IA32_CC_FLAGS       = DEF(GCC48_IA32_CC_FLAGS) -Os
> >> RELEASE_GCC48_IA32_CC_FLAGS       = DEF(GCC48_IA32_CC_FLAGS) -Os -Wno-unused-but-set-variable
> >>   DEBUG_GCC48_X64_CC_FLAGS       = DEF(GCC48_X64_CC_FLAGS) -Os
> >> RELEASE_GCC48_X64_CC_FLAGS       = DEF(GCC48_X64_CC_FLAGS) -Os -Wno-unused-but-set-variable
> >>   DEBUG_GCC49_IA32_CC_FLAGS       = DEF(GCC49_IA32_CC_FLAGS) -Os
> >> RELEASE_GCC49_IA32_CC_FLAGS       = DEF(GCC49_IA32_CC_FLAGS) -Os -Wno-unused-but-set-variable -Wno-unused-const-variable
> >>   DEBUG_GCC49_X64_CC_FLAGS       = DEF(GCC49_X64_CC_FLAGS) -Os
> >> RELEASE_GCC49_X64_CC_FLAGS       = DEF(GCC49_X64_CC_FLAGS) -Os -Wno-unused-but-set-variable -Wno-unused-const-variable
> >>   DEBUG_GCC5_IA32_CC_FLAGS       = DEF(GCC5_IA32_CC_FLAGS) -flto -Os
> >> RELEASE_GCC5_IA32_CC_FLAGS       = DEF(GCC5_IA32_CC_FLAGS) -flto -Os -Wno-unused-but-set-variable -Wno-unused-const-variable
> >>   DEBUG_GCC5_X64_CC_FLAGS        = DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO -Os
> >> RELEASE_GCC5_X64_CC_FLAGS        = DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO -Os -Wno-unused-but-set-variable -Wno-unused-const-variable
> >>
> >> (The ARM and AARCH64 DEBUG/RELEASE GCC options don't seem to be 
> >> affected, as they have relied on inherited -- not open-coded -- "-Os" 
> >> options from much earlier. So now they do not suffer from this 
> >> duplication.)
> >>
> >> The point of this patch was a kind of "normalization", so I think the work isn't complete until the duplication is undone, i.e., the explicit "-Os" flag is removed from the last twelve defines.
> >>
> >> Can you submit a follow-up patch please?
> > 
> > I have not received an answer, and I'm not aware of a follow-up patch being on the list; so now I've filed:
> > 
> > https://bugzilla.tianocore.org/show_bug.cgi?id=2928
> > 
> > Thanks
> > Laszlo
> > 
> 

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

View/Reply Online (#64694): https://edk2.groups.io/g/devel/message/64694
Mute This Topic: https://groups.io/mt/75351533/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list