From c9020d95e7ee60a6641af3a31932f0578e38ace8 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 10 Jul 2015 11:01:57 -0300 Subject: [PATCH] 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 --- cpu/x86/Makefile.x86_common | 6 ++++++ platform/galileo/README.md | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/cpu/x86/Makefile.x86_common b/cpu/x86/Makefile.x86_common index 206a02d4e..44e96363b 100644 --- a/cpu/x86/Makefile.x86_common +++ b/cpu/x86/Makefile.x86_common @@ -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 + diff --git a/platform/galileo/README.md b/platform/galileo/README.md index 5b3ff9715..131bbb6d0 100644 --- a/platform/galileo/README.md +++ b/platform/galileo/README.md @@ -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.