diff mbox

[edk2,V2] BaseTools: support the NOOPT target with the GCC tool chains

Message ID 896ca32b-3f51-6815-5c1b-1846b2cffd1c@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek Oct. 6, 2016, 8:19 a.m. UTC
On 10/06/16 00:39, Bruce Cran wrote:
> On 10/04/2016 07:30 PM, Yonghong Zhu wrote:

> 

>> Update the tools_def.template to add NOOPT support with GCC tool chains.

>>

>> Cc: Liming Gao <liming.gao@intel.com>

>> Cc: Laszlo Ersek <lersek@redhat.com>

>> Contributed-under: TianoCore Contribution Agreement 1.0

>> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>

> 

> Reviewed-by: Bruce Cran <bruce.cran@gmail.com>

> Tested-by: Bruce Cran <bruce.cran@gmail.com>

> 

> Tested with both GCC49 and GCC5 toolchain settings (using gcc 6.2.1 for

> both) and verified that both have functional debugging, though gdb skips

> around with GCC5 as expected due to LTCG.

> 


Right; as I mentioned up-thread, I wonder if we should disable -flto and -Os in NOOPT_GCC5_IA32_DLINK_FLAGS and NOOPT_GCC5_X64_DLINK_FLAGS.

How about we add the following to Yonghong's v2?
- first, move "-flto" from GCC5_IA32_X64_DLINK_FLAGS and GCC5_X64_DLINK_FLAGS to the users of those macros (both GCC5- and CLANG38-related users exist),
- second, for the GCC5 users of these macros: split them into DEBUG/RELEASE/NOOPT, and remove -Os from NOOPT.

The end result is that none of the earlier macro values change, except for NOOPT_GCC5_(IA32|X64)_DLINK_FLAGS; those two lose both -flto and -Os, which is our purpose. This would eliminate the skipping around that you mention.

What do you guys think? See the patch below (again, to be applied on top of Yonghong's v2, or to be squashed into it).

Thanks!
Laszlo

-------------------
 DEFINE GCC5_IA32_DLINK2_FLAGS        = DEF(GCC49_IA32_DLINK2_FLAGS) -Wno-error

-DEFINE GCC5_X64_DLINK_FLAGS          = DEF(GCC49_X64_DLINK_FLAGS) -flto

+DEFINE GCC5_X64_DLINK_FLAGS          = DEF(GCC49_X64_DLINK_FLAGS)

 DEFINE GCC5_X64_DLINK2_FLAGS         = DEF(GCC49_X64_DLINK2_FLAGS) -Wno-error

 DEFINE GCC5_ASM_FLAGS                = DEF(GCC49_ASM_FLAGS)

 DEFINE GCC5_ARM_ASM_FLAGS            = DEF(GCC49_ARM_ASM_FLAGS)

@@ -5288,7 +5288,6 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS  = DEF(GCC49_AARCH64_DLINK_FLAGS)
 *_GCC5_IA32_ASLCC_FLAGS          = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto

 *_GCC5_IA32_ASLDLINK_FLAGS       = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386

 *_GCC5_IA32_ASM_FLAGS            = DEF(GCC5_ASM_FLAGS) -m32 -march=i386

-*_GCC5_IA32_DLINK_FLAGS          = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Os -Wl,-m,elf_i386,--oformat=elf32-i386

 *_GCC5_IA32_DLINK2_FLAGS         = DEF(GCC5_IA32_DLINK2_FLAGS)

 *_GCC5_IA32_RC_FLAGS             = DEF(GCC_IA32_RC_FLAGS)

 *_GCC5_IA32_OBJCOPY_FLAGS        =

@@ -5298,6 +5297,10 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS  = DEF(GCC49_AARCH64_DLINK_FLAGS)
 RELEASE_GCC5_IA32_CC_FLAGS       = DEF(GCC5_IA32_CC_FLAGS) -Os -Wno-unused-but-set-variable

   NOOPT_GCC5_IA32_CC_FLAGS       = DEF(GCC5_IA32_CC_FLAGS) -O0

 

+  DEBUG_GCC5_IA32_DLINK_FLAGS    = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-m,elf_i386,--oformat=elf32-i386 -flto -Os

+RELEASE_GCC5_IA32_DLINK_FLAGS    = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-m,elf_i386,--oformat=elf32-i386 -flto -Os

+  NOOPT_GCC5_IA32_DLINK_FLAGS    = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-m,elf_i386,--oformat=elf32-i386

+

 ##################

 # GCC5 X64 definitions

 ##################

@@ -5316,7 +5319,6 @@ RELEASE_GCC5_IA32_CC_FLAGS       = DEF(GCC5_IA32_CC_FLAGS) -Os -Wno-unused-but-s
 *_GCC5_X64_ASLCC_FLAGS           = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto

 *_GCC5_X64_ASLDLINK_FLAGS        = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64

 *_GCC5_X64_ASM_FLAGS             = DEF(GCC5_ASM_FLAGS) -m64

-*_GCC5_X64_DLINK_FLAGS           = DEF(GCC5_X64_DLINK_FLAGS) -Os

 *_GCC5_X64_DLINK2_FLAGS          = DEF(GCC5_X64_DLINK2_FLAGS)

 *_GCC5_X64_RC_FLAGS              = DEF(GCC_X64_RC_FLAGS)

 *_GCC5_X64_OBJCOPY_FLAGS         =

@@ -5326,6 +5328,10 @@ RELEASE_GCC5_IA32_CC_FLAGS       = DEF(GCC5_IA32_CC_FLAGS) -Os -Wno-unused-but-s
 RELEASE_GCC5_X64_CC_FLAGS        = DEF(GCC5_X64_CC_FLAGS) -Wno-unused-but-set-variable

   NOOPT_GCC5_X64_CC_FLAGS        = DEF(GCC5_X64_CC_FLAGS) -O0

 

+  DEBUG_GCC5_X64_DLINK_FLAGS     = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os

+RELEASE_GCC5_X64_DLINK_FLAGS     = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os

+  NOOPT_GCC5_X64_DLINK_FLAGS     = DEF(GCC5_X64_DLINK_FLAGS)

+

 ##################

 # GCC5 ARM definitions

 ##################

@@ -5516,7 +5522,7 @@ DEFINE CLANG38_ALL_CC_FLAGS         = DEF(GCC44_ALL_CC_FLAGS) -Wno-empty-body -f
 *_CLANG38_IA32_ASM_FLAGS            = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANG38_IA32_TARGET)

 DEBUG_CLANG38_IA32_CC_FLAGS         = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET) -g

 RELEASE_CLANG38_IA32_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET)

-*_CLANG38_IA32_DLINK_FLAGS          = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-Oz -Wl,-melf_i386 -Wl,--oformat=elf32-i386

+*_CLANG38_IA32_DLINK_FLAGS          = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Wl,-Oz -Wl,-melf_i386 -Wl,--oformat=elf32-i386

 *_CLANG38_IA32_DLINK2_FLAGS         = DEF(GCC5_IA32_DLINK2_FLAGS) -O3

 *_CLANG38_IA32_RC_FLAGS             = DEF(GCC_IA32_RC_FLAGS)

 *_CLANG38_IA32_OBJCOPY_FLAGS        =

@@ -5545,7 +5551,7 @@ RELEASE_CLANG38_IA32_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -
 *_CLANG38_X64_ASM_FLAGS            = DEF(GCC5_ASM_FLAGS) -m64 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

 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)

-*_CLANG38_X64_DLINK_FLAGS          = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small

+*_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

 *_CLANG38_X64_DLINK2_FLAGS         = DEF(GCC5_X64_DLINK2_FLAGS) -O3

 *_CLANG38_X64_RC_FLAGS             = DEF(GCC_X64_RC_FLAGS)

 *_CLANG38_X64_OBJCOPY_FLAGS        =

-------------------


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Ard Biesheuvel Oct. 6, 2016, 8:20 a.m. UTC | #1
On 6 October 2016 at 09:19, Laszlo Ersek <lersek@redhat.com> wrote:
> On 10/06/16 00:39, Bruce Cran wrote:

>> On 10/04/2016 07:30 PM, Yonghong Zhu wrote:

>>

>>> Update the tools_def.template to add NOOPT support with GCC tool chains.

>>>

>>> Cc: Liming Gao <liming.gao@intel.com>

>>> Cc: Laszlo Ersek <lersek@redhat.com>

>>> Contributed-under: TianoCore Contribution Agreement 1.0

>>> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>

>>

>> Reviewed-by: Bruce Cran <bruce.cran@gmail.com>

>> Tested-by: Bruce Cran <bruce.cran@gmail.com>

>>

>> Tested with both GCC49 and GCC5 toolchain settings (using gcc 6.2.1 for

>> both) and verified that both have functional debugging, though gdb skips

>> around with GCC5 as expected due to LTCG.

>>

>

> Right; as I mentioned up-thread, I wonder if we should disable -flto and -Os in NOOPT_GCC5_IA32_DLINK_FLAGS and NOOPT_GCC5_X64_DLINK_FLAGS.

>

> How about we add the following to Yonghong's v2?

> - first, move "-flto" from GCC5_IA32_X64_DLINK_FLAGS and GCC5_X64_DLINK_FLAGS to the users of those macros (both GCC5- and CLANG38-related users exist),

> - second, for the GCC5 users of these macros: split them into DEBUG/RELEASE/NOOPT, and remove -Os from NOOPT.

>

> The end result is that none of the earlier macro values change, except for NOOPT_GCC5_(IA32|X64)_DLINK_FLAGS; those two lose both -flto and -Os, which is our purpose. This would eliminate the skipping around that you mention.

>

> What do you guys think? See the patch below (again, to be applied on top of Yonghong's v2, or to be squashed into it).

>


I agree. If we are going through the trouble of having a separate
NOOPT flavor, it should at least do what it says on the tin. If it
skips around, using it has no advantage over using DEBUG
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 2c0dcd67b906..60b2c2578f8d 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -4477,9 +4477,9 @@  DEFINE GCC5_IA32_CC_FLAGS            = DEF(GCC49_IA32_CC_FLAGS) -flto -fno-built
 DEFINE GCC5_X64_CC_FLAGS             = DEF(GCC49_X64_CC_FLAGS) -flto -fno-builtin -DUSING_LTO

 DEFINE GCC5_IA32_X64_DLINK_COMMON    = DEF(GCC49_IA32_X64_DLINK_COMMON)

 DEFINE GCC5_IA32_X64_ASLDLINK_FLAGS  = DEF(GCC49_IA32_X64_ASLDLINK_FLAGS)

-DEFINE GCC5_IA32_X64_DLINK_FLAGS     = DEF(GCC49_IA32_X64_DLINK_FLAGS) -flto

+DEFINE GCC5_IA32_X64_DLINK_FLAGS     = DEF(GCC49_IA32_X64_DLINK_FLAGS)