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.
wrt_unpack "$FILE"
[[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name"
fi
# Insert date and disk usage at the top of the log file, the script run
@ -215,7 +216,7 @@ chapter6_Makefiles() {
if [ "$vrs" != "" ] ; then
FILE="$name-$vrs.tar.*"
wrt_unpack2 "$FILE"
[[ "$OPTIMIZE" = "1" ]] && wrt_optimize "$name"
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name"
fi
# 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
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}
Run test suites [0-3]
0 = none
@ -291,13 +298,10 @@ wrt_optimize() { # Apply pkg specific opt's to build
optLvl=$DEF_OPT_LVL;
fi
for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; do
for OPT_VAR in $ACTIVE_OPT_VARS ; do
eval optVal=\$${OPT_VAR}_$optLvl
if [[ "$optVal" != "unset" ]]; then
case $pkg in
*zlib* ) [[ "$OPT_VAR" != "LDFLAGS" ]] && optVal="$optVal -fPIC" ;;
esac
(
cat << EOF
@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
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
OPTIMIZE=1
OPTIMIZE=0
#--- Run test suites [0-3]
# 0 = none

View file

@ -205,7 +205,7 @@ inline_doc
RUN_FARCE) [[ "$COMPARE" = "1" ]] && validate_against_str "x0x x1x" ;;
ITERATIONS) [[ "$COMPARE" = "1" ]] && validate_against_str "x2x x3x x4x x5x" ;;
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" ;;
VIMLANG) validate_against_str "x0x x1x" ;;
DEPEND) validate_against_str "x0x x1x x2x" ;;

View file

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

View file

@ -157,6 +157,21 @@ while test $# -gt 0 ; do
--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 )
test $# = 1 && eval "$exit_missing_arg"
shift
@ -473,7 +488,7 @@ fi
if [[ "$PWD" != "$JHALFSDIR" ]]; then
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
mkdir -p $JHALFSDIR/extras
cp extras/* $JHALFSDIR/extras