x86: Build release image

This patch adds support for building release images. The main difference
between release images and default images is that the former is optimized
for size while the latter is "optimized" for debugging. To build a release
image, the BUILD_RELEASE variable should be set to 1. For instance, the
following command build a release image from the hello-world application:
$ cd examples/hello-world && make TARGET=galileo BUILD_RELEASE=1

To optimize for size we use the '-Os' option from gcc. This option also
enables the strict aliasing optimization. This generates lots of warning
messages since we use the '-Wall' option and lots of code in core/net/
break the strict-aliasing rules. Some test have shown that the strict
aliasing optimization it not taking effect in the final binary. For that
reasons, this patch manually disables the optimization. Also, the release
image is stripped.

For the sake of comparison, below follows the output from 'wc' and 'size'
for both debugging (default) and release images.

Default image:
$  wc -c hello-world.galileo
71112 hello-world.galileo
$ size hello-world.galileo
   text    data     bss     dec     hex filename
  20379    1188   12808   34375    8647 hello-world.galileo

Release image:
$ wc -c hello-world.galileo
26320 hello-world.galileo
$ size hello-world.galileo
   text    data     bss     dec     hex filename
  18146    1156   12808   32110    7d6e hello-world.galileo
This commit is contained in:
Andre Guedes 2015-07-10 11:01:57 -03:00 committed by Jesus Sanchez-Palencia
parent 6c9ab4eb6c
commit c9020d95e7
2 changed files with 21 additions and 6 deletions

View file

@ -11,3 +11,9 @@ STRIP = strip
CFLAGS += -Wall -g
LDFLAGS += -Wl,-Map=contiki-$(TARGET).map,--build-id=none
ifeq ($(BUILD_RELEASE),1)
CFLAGS += -Os -fno-strict-aliasing
LDFLAGS += -Wl,--strip-all
endif

View file

@ -56,18 +56,27 @@ $ cd examples/hello-world/ && make TARGET=galileo
```
This will generate the 'hello-world.galileo' file which is a multiboot-
compliant [3] ELF image. In order to boot the Contiki image, you will need
a multiboot-compliant bootloader. In the bsp directory, we provide a helper
script which builds the Grub bootloader with multiboot support. To build the
bootloader, just run the following command:
compliant [3] ELF image. This image contains debugging information and it
should be used in your daily development.
You can also build a "Release" image by setting the BUILD_RELEASE variable to
1. This will generate a Contiki stripped-image optimized for size.
```
$ platform/galileo/bsp/grub/build_grub.sh
$ cd examples/hello-world/ && make TARGET=galileo BUILD_RELEASE=1
```
Running
-------
So to run Contiki applications in Galileo, we have three main steps:
In order to boot the Contiki image, you will need a multiboot-compliant
bootloader. In the bsp directory, we provide a helper script which builds the
Grub bootloader with multiboot support. To build the bootloader, just run the
following command:
```
$ platform/galileo/bsp/grub/build_grub.sh
```
Once Grub is built, we have three main steps to run Contiki applications:
prepare SDcard, connect to console, and boot image. Below follows
detailed instructions.