public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] BaseTools-CLANG38: Add -O3 in DLINK2 flag
@ 2016-08-19  2:46 Shi, Steven
  2016-08-19  4:56 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Shi, Steven @ 2016-08-19  2:46 UTC (permalink / raw)
  To: edk2-devel, liming.gao; +Cc: ard.biesheuvel, Steven Shi

CLANG38 build fail after CC_FLAG is added in the link rule.
This failure is because the CLANG38 enable the LTO through LLVMgold.so
linker plugin, but the LLVMgold.so plugin cannot accept the clang -Oz
CC flag as build option. After CC_FLAG is added in the link rule,
the LLVMgold.so plugin reports linking error. LLVMgold.so only accept
-O0 ~ -O3, and you can see it in the LLVM gold plugin source code
in below:

http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_380/final/tools/gold/
gold-plugin.cpp line173:

if (opt[1] < '0' || opt[1] > '3')
   message(LDPL_FATAL, "Optimization level must be between 0 and 3");

Add -O3 in the *_CLANG38_*_DLINK2_FLAGS to override the -Oz flag in
*_CLANG38_*_CC_FLAGS to pass LLVMgold.so linking.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
 BaseTools/Conf/tools_def.template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 974656c..42a3ca0 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -5489,7 +5489,7 @@ DEFINE CLANG38_ALL_CC_FLAGS         = DEF(GCC44_ALL_CC_FLAGS) -Wno-empty-body -f
 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_DLINK2_FLAGS         = DEF(GCC5_IA32_DLINK2_FLAGS)
+*_CLANG38_IA32_DLINK2_FLAGS         = DEF(GCC5_IA32_DLINK2_FLAGS) -O3
 *_CLANG38_IA32_RC_FLAGS             = DEF(GCC_IA32_RC_FLAGS)
 *_CLANG38_IA32_OBJCOPY_FLAGS        =
 *_CLANG38_IA32_NASM_FLAGS           = -f elf32
@@ -5518,7 +5518,7 @@ RELEASE_CLANG38_IA32_CC_FLAGS       = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -
 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_DLINK2_FLAGS         = DEF(GCC5_X64_DLINK2_FLAGS)
+*_CLANG38_X64_DLINK2_FLAGS         = DEF(GCC5_X64_DLINK2_FLAGS) -O3
 *_CLANG38_X64_RC_FLAGS             = DEF(GCC_X64_RC_FLAGS)
 *_CLANG38_X64_OBJCOPY_FLAGS        =
 *_CLANG38_X64_NASM_FLAGS           = -f elf64
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] BaseTools-CLANG38: Add -O3 in DLINK2 flag
  2016-08-19  2:46 [PATCH v2] BaseTools-CLANG38: Add -O3 in DLINK2 flag Shi, Steven
@ 2016-08-19  4:56 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2016-08-19  4:56 UTC (permalink / raw)
  To: Shi, Steven, edk2-devel@lists.01.org; +Cc: ard.biesheuvel@linaro.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Shi, Steven
> Sent: Friday, August 19, 2016 10:46 AM
> To: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com>
> Cc: ard.biesheuvel@linaro.org; Shi, Steven <steven.shi@intel.com>
> Subject: [PATCH v2] BaseTools-CLANG38: Add -O3 in DLINK2 flag
> 
> CLANG38 build fail after CC_FLAG is added in the link rule.
> This failure is because the CLANG38 enable the LTO through LLVMgold.so
> linker plugin, but the LLVMgold.so plugin cannot accept the clang -Oz
> CC flag as build option. After CC_FLAG is added in the link rule,
> the LLVMgold.so plugin reports linking error. LLVMgold.so only accept
> -O0 ~ -O3, and you can see it in the LLVM gold plugin source code
> in below:
> 
> http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_380/final/tools/gold/
> gold-plugin.cpp line173:
> 
> if (opt[1] < '0' || opt[1] > '3')
>    message(LDPL_FATAL, "Optimization level must be between 0 and 3");
> 
> Add -O3 in the *_CLANG38_*_DLINK2_FLAGS to override the -Oz flag in
> *_CLANG38_*_CC_FLAGS to pass LLVMgold.so linking.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Steven Shi <steven.shi@intel.com>
> ---
>  BaseTools/Conf/tools_def.template | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> index 974656c..42a3ca0 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -5489,7 +5489,7 @@ DEFINE CLANG38_ALL_CC_FLAGS         =
> DEF(GCC44_ALL_CC_FLAGS) -Wno-empty-body -f
>  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_DLINK2_FLAGS         = DEF(GCC5_IA32_DLINK2_FLAGS)
> +*_CLANG38_IA32_DLINK2_FLAGS         = DEF(GCC5_IA32_DLINK2_FLAGS) -
> O3
>  *_CLANG38_IA32_RC_FLAGS             = DEF(GCC_IA32_RC_FLAGS)
>  *_CLANG38_IA32_OBJCOPY_FLAGS        =
>  *_CLANG38_IA32_NASM_FLAGS           = -f elf32
> @@ -5518,7 +5518,7 @@ RELEASE_CLANG38_IA32_CC_FLAGS       =
> DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -
>  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_DLINK2_FLAGS         = DEF(GCC5_X64_DLINK2_FLAGS)
> +*_CLANG38_X64_DLINK2_FLAGS         = DEF(GCC5_X64_DLINK2_FLAGS) -O3
>  *_CLANG38_X64_RC_FLAGS             = DEF(GCC_X64_RC_FLAGS)
>  *_CLANG38_X64_OBJCOPY_FLAGS        =
>  *_CLANG38_X64_NASM_FLAGS           = -f elf64
> --
> 2.7.4



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-19  4:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-19  2:46 [PATCH v2] BaseTools-CLANG38: Add -O3 in DLINK2 flag Shi, Steven
2016-08-19  4:56 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox