From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web12.16732.1595417102467466280 for ; Wed, 22 Jul 2020 04:25:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RyVveKZM; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595417101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lzTBNGebQMZZn81XFgUJMukmBSJ9Dg/XtG+jbccK5Oc=; b=RyVveKZM4QCiMI8CbV/McisJwdFwOBXwXylh7oOeiPtsxeGkCoclGDHFMsitNl8TM3LgGg 2edrLKR48l8pXE6pDKIuAKQg5MYmyr+5yc6BIaUjprYFNrJ+wivxtiz0jwLn8Iw0YeYWMh Xt9kuMpY1m6UZiTkNMdfVLdyGOcH3j8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-157-hhiYB3kFNDWk5CCdwRh3kQ-1; Wed, 22 Jul 2020 07:24:59 -0400 X-MC-Unique: hhiYB3kFNDWk5CCdwRh3kQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 08251800469; Wed, 22 Jul 2020 11:24:58 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-129.ams2.redhat.com [10.36.113.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECF3D71D00; Wed, 22 Jul 2020 11:24:55 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH V2 2/2] BaseTools: Factorize GCC flags From: "Laszlo Ersek" To: pierre.gondois@arm.com Cc: devel@edk2.groups.io, bob.c.feng@intel.com, liming.gao@intel.com, tomas.pilar@arm.com, nd@arm.com, "Leif Lindholm (Nuvia address)" , "Ard Biesheuvel (ARM address)" References: <20200707083522.138944-1-pierre.gondois@arm.com> <20200707083522.138944-3-pierre.gondois@arm.com> <879fda8a-37bd-a902-6028-c879ed37fa28@redhat.com> Message-ID: Date: Wed, 22 Jul 2020 13:24:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <879fda8a-37bd-a902-6028-c879ed37fa28@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 07/22/20 13:03, Laszlo Ersek wrote: > Hi Pierre, > > On 07/07/20 10:35, PierreGondois wrote: >> From: Pierre Gondois >> >> 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 >> Suggested-by: Tomas Pilar >> --- >> >> 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..a1fd27b1adba8769949b7d628d7fbed49fe24267 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.) We do have some AARCH64 duplication here: DEFINE GCC49_AARCH64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(GCC_AARCH64_CC_FLAGS) -mcmodel=small because GCC48_ALL_CC_FLAGS is now based on GCC_ALL_CC_FLAGS, and GCC_AARCH64_CC_FLAGS is *also* based on GCC_ALL_CC_FLAGS. However, this duplication is not introduced by this patch -- it goes back to commit 63e1c23b2255 ("BaseTools/AARCH64: use large code model for GCC <= 4.8", 2015-10-02). So it's a separate topic. Thanks Laszlo > > 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? > > Thanks > Laszlo >