From b5f0c89470b838c66f8036455ac4d00d53ef3a6e Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Tue, 11 Apr 2017 20:17:25 +0200 Subject: [PATCH] Enable optimization for size by default This saves few kB in code size. Tested on all supported SOCs (built with LEDE upstream toolchain). --- Makefile | 9 +++++++++ u-boot/httpd/Makefile | 3 +++ u-boot/net/net.c | 8 ++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 96add61..d2a0db1 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,15 @@ ifndef CROSS_COMPILE endif export CROSS_COMPILE +# By default, optimization for size (-Os) is enabled, set below option +# to n or remove it if you want only basic optimization (-O/-O1) +# BUILD_OPTIMIZED = n + +ifneq ($(BUILD_OPTIMIZED), n) + BUILD_OPTIMIZED = y +endif +export BUILD_OPTIMIZED + # ========================================================================== # ======================= diff --git a/u-boot/httpd/Makefile b/u-boot/httpd/Makefile index d78fa43..247ffa4 100644 --- a/u-boot/httpd/Makefile +++ b/u-boot/httpd/Makefile @@ -4,6 +4,9 @@ include $(TOPDIR)/config.mk +# Suppress warnings when building with size optimization +CFLAGS += -fno-strict-aliasing + LIB = libhttpd.a OBJS += uip.o \ uip_arch.o \ diff --git a/u-boot/net/net.c b/u-boot/net/net.c index 639faf8..0ab249d 100644 --- a/u-boot/net/net.c +++ b/u-boot/net/net.c @@ -1383,8 +1383,6 @@ ushort getenv_VLAN(char *var){ #if defined(CONFIG_CMD_HTTPD) -#define BUF ((struct uip_eth_hdr *)&uip_buf[0]) - void NetSendHttpd(void){ volatile uchar *tmpbuf = NetTxPacket; int i; @@ -1401,10 +1399,12 @@ void NetSendHttpd(void){ } void NetReceiveHttpd(volatile uchar * inpkt, int len){ + struct uip_eth_hdr *eth_hdr = (struct uip_eth_hdr *)uip_buf; + memcpy(uip_buf, (const void *)inpkt, len); uip_len = len; - if(BUF->type == htons(UIP_ETHTYPE_IP)){ + if(eth_hdr->type == htons(UIP_ETHTYPE_IP)){ uip_arp_ipin(); uip_input(); @@ -1412,7 +1412,7 @@ void NetReceiveHttpd(volatile uchar * inpkt, int len){ uip_arp_out(); NetSendHttpd(); } - } else if(BUF->type == htons(UIP_ETHTYPE_ARP)){ + } else if(eth_hdr->type == htons(UIP_ETHTYPE_ARP)){ uip_arp_arpin(); if(uip_len > 0){ -- 2.25.1