Applied optimize patch from Jeremy Byron.

This commit is contained in:
Manuel Canales Esparcia 2006-05-05 17:41:56 +00:00
parent d20c553943
commit 53588e287f
11 changed files with 153 additions and 53 deletions

View file

@ -112,6 +112,7 @@ chapter5_Makefiles() {
# Insert instructions for unpacking the package and to set the PKGDIR variable. # Insert instructions for unpacking the package and to set the PKGDIR variable.
wrt_unpack "$FILE" wrt_unpack "$FILE"
[[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name"
fi fi
# Insert date and disk usage at the top of the log file, the script run # Insert date and disk usage at the top of the log file, the script run
@ -215,7 +216,7 @@ chapter6_Makefiles() {
if [ "$vrs" != "" ] ; then if [ "$vrs" != "" ] ; then
FILE="$name-$vrs.tar.*" FILE="$name-$vrs.tar.*"
wrt_unpack2 "$FILE" wrt_unpack2 "$FILE"
[[ "$OPTIMIZE" = "1" ]] && wrt_optimize "$name" [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name"
fi fi
# In the mount of kernel filesystems we need to set LFS # In the mount of kernel filesystems we need to set LFS

View file

@ -65,6 +65,13 @@ ${BOLD} -G, --get-packages${OFF}
in the configuration file has the proper packages and patches for the in the configuration file has the proper packages and patches for the
book version being processed. book version being processed.
${BOLD} -O, --optimize${OFF}
Optimize [0-2]
0 = no optimization
1 = optimize chapter06 only
2 = optimize both chapter05 and chapter06
Edit common/opt_config{,.d/*} and common/opt_override as desired.
${BOLD} -T, --testsuites N ${OFF} ${BOLD} -T, --testsuites N ${OFF}
Run test suites [0-3] Run test suites [0-3]
0 = none 0 = none
@ -291,13 +298,10 @@ wrt_optimize() { # Apply pkg specific opt's to build
optLvl=$DEF_OPT_LVL; optLvl=$DEF_OPT_LVL;
fi fi
for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; do for OPT_VAR in $ACTIVE_OPT_VARS ; do
eval optVal=\$${OPT_VAR}_$optLvl eval optVal=\$${OPT_VAR}_$optLvl
if [[ "$optVal" != "unset" ]]; then if [[ "$optVal" != "unset" ]]; then
case $pkg in
*zlib* ) [[ "$OPT_VAR" != "LDFLAGS" ]] && optVal="$optVal -fPIC" ;;
esac
( (
cat << EOF cat << EOF
@echo "export $OPT_VAR=\"$optVal\"" >> envars @echo "export $OPT_VAR=\"$optVal\"" >> envars

View file

@ -34,9 +34,13 @@ SERVER=ftp://ftp.lfs-matrix.net
# In BLFS the Makefile can't be run automatically # In BLFS the Makefile can't be run automatically
RUNMAKE=0 RUNMAKE=0
#--- Optimize the build? 0(no)/1(yes) #--- Optimize the build [0-2]
# 0 = no optimization
# 1 = optimize chapter06 only
# 2 = optimize both chapter05 and chapter06
#
# Optimization values are set in opt_config and opt_override # Optimization values are set in opt_config and opt_override
OPTIMIZE=1 OPTIMIZE=0
#--- Run test suites [0-3] #--- Run test suites [0-3]
# 0 = none # 0 = none

View file

@ -205,7 +205,7 @@ inline_doc
RUN_FARCE) [[ "$COMPARE" = "1" ]] && validate_against_str "x0x x1x" ;; RUN_FARCE) [[ "$COMPARE" = "1" ]] && validate_against_str "x0x x1x" ;;
ITERATIONS) [[ "$COMPARE" = "1" ]] && validate_against_str "x2x x3x x4x x5x" ;; ITERATIONS) [[ "$COMPARE" = "1" ]] && validate_against_str "x2x x3x x4x x5x" ;;
TEST) validate_against_str "x0x x1x x2x x3x" ;; TEST) validate_against_str "x0x x1x x2x x3x" ;;
OPTIMIZE) validate_against_str "x0x x1x" ;; OPTIMIZE) validate_against_str "x0x x1x x2x" ;;
STRIP) validate_against_str "x0x x1x" ;; STRIP) validate_against_str "x0x x1x" ;;
VIMLANG) validate_against_str "x0x x1x" ;; VIMLANG) validate_against_str "x0x x1x" ;;
DEPEND) validate_against_str "x0x x1x x2x" ;; DEPEND) validate_against_str "x0x x1x x2x" ;;

View file

@ -3,48 +3,36 @@
# optimization configuration file # optimization configuration file
# #
##### #####
#--- Default optimization level
# This level is overridden by definitions in common/def_opt_override;
# in this way, packages can be tuned independently. For example,
# if you have trouble building a package at level 3, add it to
# common/def_opt_override as an alternate level.
# #
# Optimization levels need not be numeric; custom strings #$Id$
# can be defined. #
# For example: CFLAGS_myLevel="-O3 -pipe"
# cat "fooPkg myLevel" >> common/def_opt_override
DEF_OPT_LVL=3
#--- Optimization level definitions #--- Default optimization mode
# Usage: - Apply optimization string at any given level # This level is overridden by definitions in common/opt_override;
# - "unset" will cause the variable to be not set # in this way, packages can be tuned independently. For example,
# instead of set to null # if you have trouble building a package in mode defOpt, add
#--- LEVEL 0 # the package to common/opt_override with a different mode.
# WARNING: Do not edit this level unless you know what you are DEF_OPT_LVL=defOpt
# doing. By default, this is set to affect packages
# which may have problems with optimization.
CFLAGS_0="unset"
CXXFLAGS_0=$CFLAGS_0
LDFLAGS_0="unset"
#--- LEVEL 1 #--- Active optimization variables
CFLAGS_1="-O2 -pipe" # Variables listed here will be set as defined in the appropriate
CXXFLAGS_1=$CFLAGS_1 # file in common/opt_config.d/; others will be ignored.
LDFLAGS_1="" ACTIVE_OPT_VARS="CFLAGS CXXFLAGS LDFLAGS \
OTHER_CFLAGS OTHER_CXXFLAGS OTHER_LDFLAGS"
#--- LEVEL 2 #--- Load optimization modes
CFLAGS_2="-O3 -pipe" # To add modes, create a working template..
CXXFLAGS_2=$CFLAGS_2 # cp opt_config.d/defOpt opt_config.d/newMode
LDFLAGS_2="" # ..and edit it as desired.
#
#--- LEVEL 3 # To inherit another mode and add to it, see opt_config.d/defOpt_fPIC
CFLAGS_3="-O3 -march=pentium4 -pipe -s" # as an example. Given opt_config.d/modeA_modeB_modeC, modeB inherits
CXXFLAGS_3=$CFLAGS_3 # the optimizations of modeA by sourcing it, and modeC inherits those
LDFLAGS_3="-s" # of modeB (which includes those of modeA).
#
#--- LEVEL noOpt_noSymbols # Add packages that are to use this mode to opt_override with:
CFLAGS_noOpt_noSymbols="-s" # echo 'myPkg newMode' >> opt_override
CXXFLAGS_noOpt_noSymbols=$CFLAGS_noOpt_noSymbols for mode in $COMMON_DIR/opt_config.d/* ; do
LDFLAGS_noOpt_noSymbols="-s" source $mode
done

View file

@ -0,0 +1,20 @@
#
#$Id$
#
#####
#
# MODE defOpt configuration
#
# Usage: - Apply optimization string to each variable
# - "unset" will cause the variable to be not set
# instead of just set to null.
#
#####
CFLAGS_defOpt="-O3 -pipe -s"
CXXFLAGS_defOpt=$CFLAGS_defOpt
LDFLAGS_defOpt="-s"
OTHER_CFLAGS_defOpt=$CFLAGS_defOpt
OTHER_CXXFLAGS_defOpt=$CXXFLAGS_defOpt
OTHER_LDFLAGS_defOpt=$LDFLAGS_defOpt

View file

@ -0,0 +1,23 @@
#
#$Id$
#
#####
#
# MODE defOpt_fPIC configuration
#
# Usage: - Apply optimization string to each variable
# - "unset" will cause the variable to be not set
# instead of just set to null.
#
#####
# Inherit optimizations from defOpt
source $COMMON_DIR/opt_config.d/defOpt
CFLAGS_defOpt_fPIC=$CFLAGS_defOpt" -fPIC"
CXXFLAGS_defOpt_fPIC=$CFLAGS_defOpt" -fPIC"
LDFLAGS_defOpt_fPIC=$LDFLAGS_defOpt
OTHER_CFLAGS_defOpt_fPIC=$CFLAGS_defOpt" -fPIC"
OTHER_CXXFLAGS_defOpt_fPIC=$CXXFLAGS_defOpt" -fPIC"
OTHER_LDFLAGS_defOpt_fPIC=$LDFLAGS_defOpt

24
common/opt_config.d/noOpt Normal file
View file

@ -0,0 +1,24 @@
#
#$Id$
#
#####
#
# MODE noOpt configuration
#
# WARNING: Do not edit this mode unless you know what you are
# doing. By default, this is set to disable optimization
# of packages known to have build or runtime failure.
#
# Usage: - Apply optimization string to each variable
# - "unset" will cause the variable to be not set
# instead of being just set to null.
#
#####
CFLAGS_noOpt="unset"
CXXFLAGS_noOpt="unset"
LDFLAGS_noOpt="unset"
OTHER_CFLAGS_noOpt="unset"
OTHER_CXXFLAGS_noOpt="unset"
OTHER_LDFLAGS_noOpt="unset"

View file

@ -0,0 +1,20 @@
#
#$Id$
#
#####
#
# MODE noOpt_noSymbols configuration
#
# Usage: - Apply optimization string to each variable
# - "unset" will cause the variable to be not set
# instead of just set to null.
#
#####
CFLAGS_noSymbols="-s"
CXXFLAGS_noSymbols=$CFLAGS_noSymbols
LDFLAGS_noSymbols="-s"
OTHER_CFLAGS_noSymbols=$CFLAGS_noSymbols
OTHER_CXXFLAGS_noSymbols=$CXXFLAGS_noSymbols
OTHER_LDFLAGS_noSymbols=$LDFLAGS_noSymbols

View file

@ -1,4 +1,5 @@
binutils 0 binutils noOpt
gcc 0 gcc noOpt
glibc 0 glibc noOpt
grub 0 grub noOpt
zlib defOpt_fPIC

View file

@ -157,6 +157,21 @@ while test $# -gt 0 ; do
--help | -h ) usage | more && exit ;; --help | -h ) usage | more && exit ;;
--optimize | -O )
test $# = 1 && eval "$exit_missing_arg"
shift
case $1 in
0 | 1 | 2 )
OPTIMIZE=$1
;;
* )
echo -e "\n$1 isn't a valid optimize level value."
echo -e "You must use 0, 1, or 2.\n"
exit 1
;;
esac
;;
--testsuites | -T ) --testsuites | -T )
test $# = 1 && eval "$exit_missing_arg" test $# = 1 && eval "$exit_missing_arg"
shift shift
@ -473,7 +488,7 @@ fi
if [[ "$PWD" != "$JHALFSDIR" ]]; then if [[ "$PWD" != "$JHALFSDIR" ]]; then
cp $COMMON_DIR/makefile-functions $JHALFSDIR/ cp $COMMON_DIR/makefile-functions $JHALFSDIR/
[[ "$OPTIMIZE" = "1" ]] && cp $COMMON_DIR/opt_override $JHALFSDIR/ [[ "$OPTIMIZE" != "0" ]] && cp $COMMON_DIR/opt_override $JHALFSDIR/
if [[ "$COMPARE" != "0" ]] ; then if [[ "$COMPARE" != "0" ]] ; then
mkdir -p $JHALFSDIR/extras mkdir -p $JHALFSDIR/extras
cp extras/* $JHALFSDIR/extras cp extras/* $JHALFSDIR/extras