Message ID | 1470148772-15712-4-git-send-email-ard.biesheuvel@linaro.org |
---|---|
State | Accepted |
Commit | 478f50990a9a3b76524fd14f2085b9f1127fa41a |
Headers | show |
On 17 August 2016 at 13:38, Shi, Steven <steven.shi@intel.com> wrote: > Hi Ard, > > CLANG38 has a build failure as below for this patch. 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 link > error. LLVMgold.so only accept -O0~-O3, and you can see it in the LLVM gold > plugin source code in below: > This is interesting. I tried enabling LTO with CLANG35 for AARCH64 (using a 3.7 binary) and I did not see this problem. > > > http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_380/final/tools/gold/gold-plugin.cpp > > > > if (opt[1] < '0' || opt[1] > '3') > > line173: message(LDPL_FATAL, "Optimization level must be between 0 > and 3"); > > > > I hope to know is it mandatory to add compiler CC_FLAG in the linker rule > for you? If it is mandatory, I have to introduce a new link rule for CLANG38 > to remove the compiler CC_FLAG. What do you think? > Yes, it is mandatory. And I consider this a bug in Clang. For example, the mcmodel=xxx parameter *must* be passed to the linker, since the linker generates code itself under LTO, and needs to know for which code model it is doing so. The same applies to -fpie and -mstrict-align (although clang also requires the -pie linker flag to generate correct code) Could you try putting -O2 in the DLINK2_FLAGS for Clang 38? (i.e., so that the last -O option the linker sees is not -Oz)
On 17 August 2016 at 14:24, Shi, Steven <steven.shi@intel.com> wrote: >> > >> Could you try putting -O2 in the DLINK2_FLAGS for Clang 38? (i.e., so > >> that the last -O option the linker sees is not -Oz) > >> > > Ard, > > Add -O2 or -O3 in DLINK2_FLAGS works as below, thank your suggestion! > Good to know! Thanks, Ard. _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template index 7d9f8ca075c2..ddeef59a9ec6 100644 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -294,7 +294,7 @@ "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) <Command.GCC> - "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(DLINK2_FLAGS) + "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) $(DLINK2_FLAGS) "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst} <Command.GCCLD>
Now that we invoke GCC as the linker for the GCC toolchain family, we can pass the CC flags to the linker as well. This is only required for LTO (which may involve code generation during the link stage), but does not interfere with non-LTO builds. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- BaseTools/Conf/build_rule.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel