coreboot-kgpe-d16/payloads/libpayload
Jacob Garber 04540f1549 libpayload: Add support for link time optimization
Link time optimization is a technique for whole-program optimization.
Instead of doing code generation during compilation, the compiler saves
its intermediate representation to the object files. During the final
linking step, it will then merge all the object files together and
perform optimizations on the entire program. This can often reduce the
final binary size, but also may increase the total compilation time.

This patch introduces a Kconfig option for enabling link time
optimization in libpayload. Since libpayload does no linking of its own,
its LTO archive files will contain only IR and no generated code.
Downstream projects will need to use LTO-aware tools when manipulating
the archives (eg. gcc-ar and gcc-nm), but otherwise do not need to use
LTO themselves -- the compiler will recognize which files are LTO and
which are not, so enabling this option should mostly be "drop in".

For example, when building coreinfo.elf using tinycurses libpayload:

		binary size	compilation time
default		114 KiB		11.49s
LTO		95 KiB		10.36s

In this case the total compilation time was actually shorter -- despite
the final linking step taking longer, this was offset by the shorter
compilation times for each individual file (since there is no code gen
until the very end).

Change-Id: I048f2ff6298ed0d891098942e1e8b29d35487b91
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38291
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Martin Roth <martinroth@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-11-02 22:05:02 +00:00
..
arch libpayload/x86: Try to discover invariant TSC rate 2020-11-02 06:24:33 +00:00
bin
configs libpayload/defconfig: Set default heap size to 1MiB 2020-08-17 06:10:49 +00:00
crypto payloads: Drop unneeded empty lines 2020-09-21 16:20:57 +00:00
curses libpayload/curses: Use <stdbool.h> 2020-10-26 06:57:21 +00:00
drivers libpayload/keyboard: Use `bool` as return type 2020-10-26 06:57:47 +00:00
gdb
include libpayload/x86: Add enumeration of Intel family 6 models 2020-11-02 06:24:10 +00:00
libc lib/libpayload: Replace strapping_ids with new board configuration entry 2020-10-30 15:25:28 +00:00
libcbfs
liblz4
liblzma payloads: Drop unneeded empty lines 2020-09-21 16:20:57 +00:00
libpci libpayload/libpci: Introduce device class attribute in pci_dev 2020-10-17 16:33:55 +00:00
sample
tests
.gitignore .gitignore: Split into subdirectory files 2020-10-30 07:05:27 +00:00
Doxyfile
Kconfig libpayload: Add support for link time optimization 2020-11-02 22:05:02 +00:00
LICENSES
LICENSE_GPL
Makefile
Makefile.inc libpayload: Add support for link time optimization 2020-11-02 22:05:02 +00:00
README

README

-------------------------------------------------------------------------------
libpayload README
-------------------------------------------------------------------------------

libpayload is a minimal library to support standalone payloads
that can be booted with firmware like coreboot. It handles the setup
code, and provides common C library symbols such as malloc() and printf().

Note: This is _not_ a standard library for use with an operating system,
rather it's only useful for coreboot payload development!
See https://www.coreboot.org for details on coreboot.


Installation
------------

 $ git clone https://review.coreboot.org/coreboot.git

 $ cd coreboot/payloads/libpayload

 $ make menuconfig

 $ make

 $ make install (optional, will install into ./install per default)

On x86 systems, libpayload will always be 32-bit even if your host OS runs
in 64-bit, so you might have to install the 32-bit libgcc version.
On Debian systems you'd do 'apt-get install gcc-multilib' for example.

Run 'make distclean' before switching boards. This command will remove
your current .config file, so you need 'make menuconfig' again or
'make defconfig' in order to set up configuration. Default configuration
is based on 'configs/defconfig'. See the configs/ directory for examples
of configuration.


Usage
-----

Here's an example of a very simple payload (hello.c) and how to build it:

 #include <libpayload.h>

 int main(void)
 {
     printf("Hello, world!\n");
     return 0;
 }

Building the payload using the 'lpgcc' compiler wrapper:

 $ lpgcc -o hello.elf hello.c

Please see the sample/ directory for details.


Website and Mailing List
------------------------

The main website is https://www.coreboot.org/Libpayload.

For additional information, patches, and discussions, please join the
coreboot mailing list at https://www.coreboot.org/Mailinglist, where most
libpayload developers are subscribed.


Copyright and License
---------------------

See LICENSES.