Code Sample |
I'm revising everything. Actually, I'm trying to keep things as small as possible so I can post it on one of the one-click hosts instead of leaving my machine on all the time for a torrent. This will take a while. Sorry for the inconvenience! |
Code Sample |
buildroot's 'make menuconfig' allows you to set compiler optimizations; for example, the default is '-Os -pipe'. This is saved in the variable $BR2_TARGET_OPTIMIZATION. This is then passed on to 'configure' as part of the $CC variable (in the form of 'gcc -Os -pipe') when configuring packages. BR2_TARGET_OPTIMIZATION is supposed to replace CFLAGS/CXXFLAGS. When you run 'make', a script checks if CFLAGS/CXXFLAGS are clean. If not, the build is stopped and you are told to 'unset' the variable(s). This is probably to prevent you from running 'make' while unaware that CFLAGS is set to a bad value. The problem is, most 'configure' scripts also check for CFLAGS; if $CFLAGS is empty, the default (usually '-g -O2') is used. Since 'configure' always puts $CFLAGS after $CC, you get this: 'gcc -Os -pipe -g -O2'. In short, $BR2_TARGET_OPTIMIZATION always gets overridden by the default $CFLAGS stored in 'configure'. To solve the problem: 1. In the main buildroot directory, edit 'Makefile' and add these 3 lines: CFLAGS:=-Os CXXFLAGS:=-Os export CFLAGS CXXFLAGS This sets CFLAGS and CXXFLAGS to '-Os' when you run 'make'. 2. cd 'toolchain/dependencies/' and edit 'dependencies.sh'. Delete these 2 sections: if test -n "$CFLAGS"; then echo "CFLAGS clean: FALSE" /bin/echo -e "\n\nYou must run 'unset CFLAGS' so buildroot can run with"; /bin/echo -e "a clean environment on your build machine\n"; exit 1; fi; echo "CFLAGS clean: Ok" if test -n "$CXXFLAGS"; then echo "CXXFLAGS clean: FALSE" /bin/echo -e "\n\nYou must run 'unset CXXFLAGS' so buildroot can run with"; /bin/echo -e "a clean environment on your build machine\n"; exit 1; fi; echo "CXXFLAGS clean: Ok" |