public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Shi, Steven" <steven.shi@intel.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: "sigmaepsilon92@gmail.com" <sigmaepsilon92@gmail.com>,
	"Zhu, Yonghong" <yonghong.zhu@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>,
	"Justen, Jordan L" <jordan.l.justen@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"leif.lindholm@linaro.org" <leif.lindholm@linaro.org>,
	"afish@apple.com" <afish@apple.com>
Subject: Re: [PATCH 3/3] BaseTools GCC: add the compiler flags to the linker command line
Date: Wed, 17 Aug 2016 11:38:44 +0000	[thread overview]
Message-ID: <06C8AB66E78EE34A949939824ABE2B310338D619@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1470148772-15712-4-git-send-email-ard.biesheuvel@linaro.org>

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:



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?





"/home/jshi19/clang38/bin/clang" -o /home/jshi19/edk2-fork/Build/OvmfX64/DEBUG_CLANG38/X64/OvmfPkg/Sec/SecMain/DEBUG/SecMain.dll -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x40 -Wl,--entry,_ModuleEntryPoint -u _ModuleEntryPoint -Wl,-Map,/home/jshi19/edk2-fork/Build/OvmfX64/DEBUG_CLANG38/X64/OvmfPkg/Sec/SecMain/DEBUG/SecMain.map -flto -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--start-group,@/home/jshi19/edk2-fork/Build/OvmfX64/DEBUG_CLANG38/X64/OvmfPkg/Sec/SecMain/OUTPUT/static_library_files.lst,--end-group -g -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=SecMainStrings -Wno-empty-body -fno-stack-protector -fno-builtin -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-parentheses-equality -Wno-unknown-pragmas -Wno-tautological-constant-out-of-range-compare -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference -Wno-tautological-compare -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto -target x86_64-pc-linux-gnu -g -mno-mmx -mno-sse -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 -Wl,--script=/home/jshi19/edk2-fork/BaseTools/Scripts/GccBase.lds -Wno-error -v

clang version 3.8.0 (tags/RELEASE_380/final)

Target: x86_64-pc-linux-gnu

Thread model: posix

InstalledDir: /home/jshi19/clang38/bin

Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7

Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.4

Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9

Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3

Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0

Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0

Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0

Candidate multilib: .;@m64

Candidate multilib: 32;@m32

Candidate multilib: x32;@mx32

Selected multilib: .;@m64

"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /home/jshi19/edk2-fork/Build/OvmfX64/DEBUG_CLANG38/X64/OvmfPkg/Sec/SecMain/DEBUG/SecMain.dll -u _ModuleEntryPoint -L/usr/lib/gcc/x86_64-linux-gnu/5.4.0 -L/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../.. -L/home/jshi19/clang38/bin/../lib -L/lib -L/usr/lib -plugin /home/jshi19/clang38/bin/../lib/LLVMgold.so -plugin-opt=mcpu=x86-64 -plugin-opt=Oz -n -q --gc-sections -z common-page-size=0x40 --entry _ModuleEntryPoint -Map /home/jshi19/edk2-fork/Build/OvmfX64/DEBUG_CLANG38/X64/OvmfPkg/Sec/SecMain/DEBUG/SecMain.map -Oz -melf_x86_64 --oformat=elf64-x86-64 -pie --start-group @/home/jshi19/edk2-fork/Build/OvmfX64/DEBUG_CLANG38/X64/OvmfPkg/Sec/SecMain/OUTPUT/static_library_files.lst --end-group --defsym=PECOFF_HEADER_SIZE=0x228 --script=/home/jshi19/edk2-fork/BaseTools/Scripts/GccBase.lds

/usr/bin/ld: error: Optimization level must be between 0 and 3

clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)







Steven Shi

Intel\SSG\STO\UEFI Firmware



Tel: +86 021-61166522

iNet: 821-6522





> -----Original Message-----

> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of

> Ard Biesheuvel

> Sent: Tuesday, August 02, 2016 10:40 PM

> To: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming

> <liming.gao@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>;

> edk2-devel@lists.01.org; leif.lindholm@linaro.org

> Cc: sigmaepsilon92@gmail.com; Ard Biesheuvel <ard.biesheuvel@linaro.org>

> Subject: [edk2] [PATCH 3/3] BaseTools GCC: add the compiler flags to the

> linker command line

>

> 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(-)

>

> 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>

> --

> 2.7.4

>

> _______________________________________________

> edk2-devel mailing list

> edk2-devel@lists.01.org

> https://lists.01.org/mailman/listinfo/edk2-devel

  reply	other threads:[~2016-08-17 11:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 14:39 [PATCH 0/3] BaseTools GCC: pass CC flags to linker Ard Biesheuvel
2016-08-02 14:39 ` [PATCH 1/3] BaseTools GCC: move -c compiler flag to build rules Ard Biesheuvel
2016-08-02 15:01   ` Leif Lindholm
2016-08-02 15:02     ` Ard Biesheuvel
2016-08-02 15:09       ` Ard Biesheuvel
2016-08-02 14:39 ` [PATCH 2/3] BaseTools GCC5: disable warnings-as-errors for now Ard Biesheuvel
2016-08-02 14:39 ` [PATCH 3/3] BaseTools GCC: add the compiler flags to the linker command line Ard Biesheuvel
2016-08-17 11:38   ` Shi, Steven [this message]
2016-08-17 11:42     ` Ard Biesheuvel
2016-08-17 12:24       ` Shi, Steven
2016-08-17 13:06         ` Ard Biesheuvel
2016-08-02 14:50 ` [PATCH 0/3] BaseTools GCC: pass CC flags to linker Gao, Liming
2016-08-02 14:51   ` Ard Biesheuvel
2016-08-03  8:22     ` Ard Biesheuvel
2016-08-03  8:58       ` Gao, Liming
2016-08-03  9:23         ` Ard Biesheuvel
2016-08-03 13:20           ` Gao, Liming
2016-08-03 15:50             ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06C8AB66E78EE34A949939824ABE2B310338D619@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox