From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id 5FC221A1DF5 for ; Wed, 17 Aug 2016 06:01:55 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 17 Aug 2016 06:01:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,529,1464678000"; d="scan'208";a="1015929046" Received: from fanglian-mobl.ccr.corp.intel.com (HELO JSHI19-MOBL2.ccr.corp.intel.com) ([10.255.25.102]) by orsmga001.jf.intel.com with ESMTP; 17 Aug 2016 06:01:54 -0700 From: "Shi, Steven" To: edk2-devel@lists.01.org, liming.gao@intel.com Cc: ard.biesheuvel@linaro.org, Steven Shi Date: Wed, 17 Aug 2016 21:01:37 +0800 Message-Id: <1471438897-32784-1-git-send-email-steven.shi@intel.com> X-Mailer: git-send-email 2.8.1.windows.1 Subject: [PATCH] BaseTools-CLANG38: Add O3 in Dlink2 flag X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2016 13:01:55 -0000 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_X64_DLINK2_FLAGS to override the -Oz flag in *_CLANG38_X64_CC_FLAGS to pass LLVMgold.so linking. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Steven Shi --- 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 974656c..c8e80c9 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -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