On 07/09/15 04:31, Scott Duplichan wrote:
> Bruce Cran [mailto:br...@cran.org.uk] wrote:
> 
> ]Sent: Wednesday, July 08, 2015 05:12 PM
> ]To: edk2-devel@lists.sourceforge.net
> ]Subject: Re: [edk2] [PATCH] BaseTools/GCC: allow unused but set variables
> ]
> ]On Wed, Jul 08, 2015 at 10:43:38PM +0200, Laszlo Ersek wrote:
> ]
> ]> I think it would make a difference if -flto *actually* worked, but from
> ]> a quick google search, I think it either doesn't work with gcc-4.8 at
> ]> all, *or* the edk2 build system would have to use FLTO-aware binutils
> ]> and linker wrappers (or parameters). I have no clue how to set that up.
> ]> So for now we'll have to stick with MDEPKG_NDEBUG I guess.
> ]
> ]I've been trying to get -flto working this week, but without success (yet!).
> ]I'm currently running into a problem of ld (built from source) apparently not
> ]knowing about the lto plugin (and passing the liblto.so file via -plugin 
> causes
> ]an assert failure), but I'll keep trying.
> 
> Last year I spent some time to get gcc -flto working properly with EDK2.
> At that time, the people here were busy with other things and there didn't
> seem to be a lot of interest in gcc link time optimization. So I never
> submitted a patch. Maybe it is time to revive this effort. Here is what I
> found:
> 
>     http://notabs.org/uefi/gcc-lto.htm

I apologize if I should remember this from last year, but I don't. Sorry
about that. Do you think you could revive it? The space savings would be
nice, but more importantly (to me), that would allow us to "opt out" of
MDEPKG_NDEBUG in at least OvmfPkg. (Based on Andrew's description, I now
believe that opting out of MDEPKG_NDEBUG is a good thing -- it would
allow the compiler to check more things, rather than "hiding" those
things with the preprocessor.)

In the article you wrote,
> gcc link time optimization exposes a few warnings that do not occur
> with the standard builds

and I guess Bill hinted that he saw similar warnings, and at least one
of those indicated a real problem?... So maybe we should find and fix
these for good.

> So 6 conditions need to be met for ghcc link time optimization to work
> properly with EDK2:
> 
>     1) Add -flto to the compile flags

Right.

>     2) Use gcc to launch ld instead of invoking ld directly

This was consistent with my google results, and where I gave up.

>     3) Include the compile flags on the link command line

I did that too (DLINK_FLAGS?)

>     4) Use gcc-ar in place of ar when building static libraries

Also why I gave up... But now I checked (based on your article), and my
RHEL-7 laptop actually satisfies these requirements. It has gcc-ar, has
plugin support, etc. I ran your (very helpful!) build test from your
article, and it seemed to work:

main.exe:     file format elf64-x86-64
Disassembly of section .text:
0000000000400150 <main>:
  400150:       31 c0                   xor    eax,eax
  400152:       c3                      ret
  400153:       90                      nop

Thanks!
Laszlo

>     5) Library code that resolves helper function calls generated by the 
> compiler must be compiled without the -flto flag
>     6) These libraries must be prefixed with -Wl,-plugin-opt=-pass-through= 
> on the link command line.
> 
> A patch from late 2014 is here:
> http://sourceforge.net/projects/edk2developertoolsforwindows/files/Patches/Link%20Time%20Optimization/
> 
> Thanks,
> Scott
> 
> 
> ]Also, in terms of edk2-related resources, if anyone's interested I've been
> ]running doxygen on the sources and putting the results in
> ]http://bluestop.org/edk2/docs - the log files contain the tons of warnings 
> the
> ]tool generates, while the directories (http://bluestop.org/edk2/docs/trunk, 
> ]http://bluestop.org/edk2/docs/UDK2014.SP1 etc.)
> ]contain the API docs themselves.  I started generating them since I noticed
> ]feishare.com hadn't been updated for a couple of years and wasn't aware of 
> any
> ]other sites hosting a copy.
> ]
> ]-- 
> ]Bruce
> 
> 
> 
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> 


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to