OpenWrt Forum Archive

Topic: Compiled parts of OpenWrt with gcc-4.0.2

The content of this topic has been archived on 3 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.


I tried to compile OpenWrt trunk (AR7 port for Sinus 154) with a newer compiler (gcc-4.0.2).
Only two trivial patches were needed for Linux kernel 2.4.32 (AR7 specific code),
the rest compiled without change (at least the basic package subset which I use).
The resulting kernel worked as before.

My motivation was to see whether the new code was smaller. This was the case
for normal applications (checked with busybox, uclib, wlan driver) but not for
the largest code, the kernel itself, which increased dramatically. I had to change
the load address from 0x94200000 to 0x94300000 because the uncompressed
kernel grew larger than 0x200000.

Here are the code sizes:

Comparision of gcc-3.* and gcc-4.02

   text    data     bss     dec     hex filename
366103    4480   19352  389935   5f32f openwrt-3.4.4/toolchain_build_mipsel/uClibc-0.9.28/lib/
361047    4484   19352  384883   5df73 openwrt-4.0.2/toolchain_build_mipsel/uClibc-0.9.28/lib/

  text    data     bss     dec     hex filename
552146   10412  821840 1384398  151fce openwrt-3.4.4/build_mipsel/busybox-1.1.0-pre1/busybox
546948   10388  821840 1379176  150b68 openwrt-4.0.2/build_mipsel/busybox-1.1.0-pre1/busybox

   text    data     bss     dec     hex filename
  92660    5232   35088  132980   20774 openwrt-3.4.4/build_mipsel/linux-2.4-ar7/linux-2.4.32/kernel/kernel.o
166384    5232   35088  206704   32770 openwrt-4.0.2/build_mipsel/linux-2.4-ar7/linux-2.4.32/kernel/kernel.o

   text    data     bss     dec     hex filename
373216  108400  449776  931392   e3640 wlan-3.4.4/make/tiap.o
355416  108400  449776  913592   df0b8 wlan-4.0.2/make/tiap.o

Obviously the default kernel compiler flags are not good for the new compiler.


There was a story on LWN somewhere where one of the kernel devs noticed that disabling the effects of the inline keyword and allowing gcc to figure out the inlining strategy by itself would decrease the code size a lot.
This only works properly on gcc 4.0.2+. Maybe you should try it...

Ok, I examined the compiler options which are related to inline functions.

Removing option -finline-limit=100000 from linux-2.4.32/arch/mips/Makefile
results in a large reduction of kernel size, even smaller than with gcc-3.4.4:

   text    data     bss     dec     hex filename
1548518  118936  174560 1842014  1c1b5e src/openwrt-gcc-3.4.4/build_mipsel/linux-2.4-ar7/linux-2.4.32/vmlinux
1417342  118936  174560 1710838  1a1af6 src/openwrt-gcc-4.0.2/build_mipsel/linux-2.4-ar7/linux-2.4.32/vmlinux

I had to replace include/asm-mips/unaligned.h by include/asm-generic/unaligned.h
to avoid a linker problem, but then the new kernel was built and it worked, too.


I'm facing the same thing with 2.6 smile I've already backported the inlining changes to .15 from .16-rc1, but the uncompressed kernel is still 600K bigger. Thanks for the hint, I try without that option, too smile

The discussion might have continued from here.