From e2dfa2c90f5daf7a24e5b955453fbcd0c792f28e Mon Sep 17 00:00:00 2001 From: Manuel Canales Esparcia Date: Sun, 30 Sep 2007 13:02:43 +0000 Subject: [PATCH] Migrated optimizations support to XSL-based code. --- LFS/lfs.xsl | 25 +- XSL/optimize.xsl | 485 +++++++++++++++++++++++++++++ common/libs/func_book_parser | 1 + jhalfs | 19 -- optimize/opt_config | 53 ---- optimize/opt_config.d/O3pipe | 22 -- optimize/opt_config.d/O3pipe_march | 25 -- optimize/opt_config.d/defOpt_fPIC | 36 --- optimize/opt_config.d/noOpt | 27 -- optimize/opt_config.d/noSymbols | 23 -- optimize/opt_override | 5 - optimize/optimize_functions | 91 ------ 12 files changed, 508 insertions(+), 304 deletions(-) create mode 100644 XSL/optimize.xsl delete mode 100644 optimize/opt_config delete mode 100644 optimize/opt_config.d/O3pipe delete mode 100644 optimize/opt_config.d/O3pipe_march delete mode 100644 optimize/opt_config.d/defOpt_fPIC delete mode 100644 optimize/opt_config.d/noOpt delete mode 100644 optimize/opt_config.d/noSymbols delete mode 100644 optimize/opt_override delete mode 100644 optimize/optimize_functions diff --git a/LFS/lfs.xsl b/LFS/lfs.xsl index b928b34..6abae06 100644 --- a/LFS/lfs.xsl +++ b/LFS/lfs.xsl @@ -10,9 +10,10 @@ - - + + + @@ -48,6 +49,13 @@ n + + 0 + @@ -176,7 +184,7 @@ - + PKG_PHASE= @@ -186,6 +194,17 @@ + + + + + + + + + + + TEST_LOG= diff --git a/XSL/optimize.xsl b/XSL/optimize.xsl new file mode 100644 index 0000000..b8516e1 --- /dev/null +++ b/XSL/optimize.xsl @@ -0,0 +1,485 @@ + + + + + + + + + + + + y + + + + -j3 + + + + + keep_this_line + autoconf + dejagnu + gettext + groff + man-db + keep_this_line + + + + + + + + + + keep_this_line + keep_this_line + + + + + + + + + y + + + + + keep_this_line + binutils + binutils-pass1 + binutils-pass2 + gcc + gcc-pass1 + gcc-pass2 + glibc + grub + keep_this_line + + + + + + + -O3 -pipe + + + + $CFLAGS + + + + $CFLAGS + + + + $CXXFLAGS + + + + + + + + + + + + + + + + zlib -fPIC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + 1 + + + + MAKEFLAGS=" + + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CFLAGS=" + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + CXXFLAGS=" + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + OTHER_CFLAGS=" + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + OTHER_CXXFLAGS=" + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + LDFLAGS=" + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + OTHER_LDFLAGS=" + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/libs/func_book_parser b/common/libs/func_book_parser index 8ef74a4..ab90d4f 100644 --- a/common/libs/func_book_parser +++ b/common/libs/func_book_parser @@ -146,6 +146,7 @@ extract_commands() { # --stringparam lang $LANG \ --stringparam custom-tools $CUSTOM_TOOLS \ --stringparam blfs-tool $BLFS_TOOL \ + --stringparam optimize $OPTIMIZE \ -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1 ;; *) echo -n " ${L_arrow}${BOLD}${PROGNAME}${R_arrow} book invalid, terminate build... " diff --git a/jhalfs b/jhalfs index 9bfa01d..2d457cb 100755 --- a/jhalfs +++ b/jhalfs @@ -266,22 +266,6 @@ if [[ "$COMPARE" = "y" ]]; then [[ $VERBOSITY > 0 ]] && echo "OK" fi # -# optimize module -if [[ "$OPTIMIZE" != "0" ]]; then - [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..." - source optimize/optimize_functions - [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit - [[ $VERBOSITY > 0 ]] && echo "OK" - # - # optimize configurations - [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..." - source optimize/opt_config - [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit - [[ $VERBOSITY > 0 ]] && echo "OK" - # Validate optimize settings, if required - validate_opt_settings -fi -# if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then @@ -327,9 +311,6 @@ if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then validate_config > $JHALFSDIR/jhalfs.config fi # - # Copy optimize files, if needed - [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/ - # # Copy compare files, if needed if [[ "$COMPARE" = "y" ]]; then mkdir -p $JHALFSDIR/extras diff --git a/optimize/opt_config b/optimize/opt_config deleted file mode 100644 index 78c07df..0000000 --- a/optimize/opt_config +++ /dev/null @@ -1,53 +0,0 @@ -##### -# -# optimization configuration file -# -##### -# -#$Id$ -# - -#--- Extra flags passed to the packages make commands -# "unset" will cause the variable to be not set -# instead of just set to null. -MAKEFLAGS="-j3" - -#--- List of packages that have issues with jobs control. -# This list may be different for you. -# If your MAKEFLAGS don't contains a -jX option, you can set -# a empty list here. -BLACK_LIST="autoconf dejagnu gettext groff man-db" - -#--- Default optimization mode -# This mode is overridden by definitions in opt_override; -# in this way, packages can be tuned independently. For example, -# if you have trouble building a package in the mode set here, add -# the package to opt_override with a different mode. -# -# Not set here combined modes of form defOpt_myMode. -# Combined modes of form modeA_modeB can be set here. -DEF_OPT_MODE=O3pipe - - -#--- Active optimization variables -# Variables listed here will be set as defined in the appropriate -# file in opt_config.d/; others will be ignored. -ACTIVE_OPT_VARS="CFLAGS CXXFLAGS LDFLAGS \ - OTHER_CFLAGS OTHER_CXXFLAGS OTHER_LDFLAGS" - -#--- Load optimization modes -# To add modes, create a working template.. -# cp opt_config.d/O3pipe opt_config.d/newMode -# ..and edit it as desired. -# -# To inherit another mode and add to it, see opt_config.d/O3pipe_march -# or opt_config.d/defOpt_fPIC as examples for two different ways of -# doing it. 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 optimize/opt_config.d/* ; do - source $mode -done diff --git a/optimize/opt_config.d/O3pipe b/optimize/opt_config.d/O3pipe deleted file mode 100644 index 517f39f..0000000 --- a/optimize/opt_config.d/O3pipe +++ /dev/null @@ -1,22 +0,0 @@ -# -#$Id$ -# -##### -# -# MODE O3pipe configuration -# -# Usage: - Apply optimization string to each variable -# - "unset" will cause the variable to be not set -# instead of just set to null. -# -# Use this as an example for cunstomized modes -# -##### - -CFLAGS_O3pipe="-O3 -pipe" -CXXFLAGS_O3pipe=$CFLAGS_O3pipe -LDFLAGS_O3pipe="unset" - -OTHER_CFLAGS_O3pipe=$CFLAGS_O3pipe -OTHER_CXXFLAGS_O3pipe=$CXXFLAGS_O3pipe -OTHER_LDFLAGS_O3pipe=$LDFLAGS_O3pipe diff --git a/optimize/opt_config.d/O3pipe_march b/optimize/opt_config.d/O3pipe_march deleted file mode 100644 index 7f0f50e..0000000 --- a/optimize/opt_config.d/O3pipe_march +++ /dev/null @@ -1,25 +0,0 @@ -# -#$Id$ -# -##### -# -# MODE O3pipe_march configuration -# -# Usage: - Apply optimization string to each variable -# - "unset" will cause the variable to be not set -# instead of just set to null. -# -# Use this as an example for modeA_modeB combined modes -# -##### - -# Inherit optimizations from O3pipe -source optimize/opt_config.d/O3pipe - -CFLAGS_O3pipe_march=$CFLAGS_O3pipe" -march=pentium4" -CXXFLAGS_O3pipe_march=$CFLAGS_O3pipe" -march=pentium4" -LDFLAGS_O3pipe_march=$LDFLAGS_O3pipe - -OTHER_CFLAGS_O3pipe_march=$CFLAGS_O3pipe" -march=pentium4" -OTHER_CXXFLAGS_O3pipe_march=$CXXFLAGS_O3pipe" -march=pentium4" -OTHER_LDFLAGS_O3pipe_march=$LDFLAGS_O3pipe diff --git a/optimize/opt_config.d/defOpt_fPIC b/optimize/opt_config.d/defOpt_fPIC deleted file mode 100644 index f114ab8..0000000 --- a/optimize/opt_config.d/defOpt_fPIC +++ /dev/null @@ -1,36 +0,0 @@ -# -#$Id$ -# -##### -# -# MODE defOpt_fPIC configuration -# -# WARNING: Do not edit this mode unless you know what you are -# doing. It's required to build Zlib. -# -# Usage: - Apply optimization string to each variable -# - "unset" will cause the variable to be not set -# instead of just set to null. -# -# Use this as an example for defOpt_myMode combined modes -# -##### - -# Inherit optimizations from DEF_OPT_MODE -source optimize/opt_config.d/${DEF_OPT_MODE} - -# Append " -fPIC" to default *C{,XX}FLAGS and retain other defaults -for OPT_VAR in $ACTIVE_OPT_VARS ; do - case $OPT_VAR in - CFLAGS | CXXFLAGS | OTHER_CFLAGS | OTHER_CXXFLAGS) - if [[ "$(eval "echo \$${OPT_VAR}_${DEF_OPT_MODE}")" != "unset" ]] ; then - eval ${OPT_VAR}_defOpt_fPIC=\$${OPT_VAR}_${DEF_OPT_MODE}\" -fPIC\" - else - eval ${OPT_VAR}_defOpt_fPIC="unset" - fi - ;; - *) - eval ${OPT_VAR}_defOpt_fPIC=\$${OPT_VAR}_${DEF_OPT_MODE} - ;; - esac -done diff --git a/optimize/opt_config.d/noOpt b/optimize/opt_config.d/noOpt deleted file mode 100644 index 39abdb3..0000000 --- a/optimize/opt_config.d/noOpt +++ /dev/null @@ -1,27 +0,0 @@ -# -#$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. -# -# Also, if you what to use MAKEFLAGS but no build -# optimizations, set this mode in DEF_OPT_MODE -# -# 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" diff --git a/optimize/opt_config.d/noSymbols b/optimize/opt_config.d/noSymbols deleted file mode 100644 index 7089f02..0000000 --- a/optimize/opt_config.d/noSymbols +++ /dev/null @@ -1,23 +0,0 @@ -# -#$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. -# -# NOTE: If using this mode in DEF_OPT_MODE (alone or combined with -# other modes) please set STRIP=0 in common/config -# -##### - -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 diff --git a/optimize/opt_override b/optimize/opt_override deleted file mode 100644 index 05f8637..0000000 --- a/optimize/opt_override +++ /dev/null @@ -1,5 +0,0 @@ -binutils noOpt -gcc noOpt -glibc noOpt -grub noOpt -zlib defOpt_fPIC diff --git a/optimize/optimize_functions b/optimize/optimize_functions deleted file mode 100644 index baec318..0000000 --- a/optimize/optimize_functions +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash - -# $Id$ - -set +e - - -#----------------------------------# -validate_opt_settings() { # Show optimize setting and wait user agreement -#----------------------------------# - local OPT_VAR optVal - - echo -e "\t\t${RED}${BOLD}WARNING:${OFF}\n" - echo -e "${BOLD}The use of build optimizations may be dangerous.\n" - echo -e "You should know what you are doing and be sure that the" - echo -e "optimization settings listed below are what you want.\n" - echo -e "If there are build issues or the system doesn't work as" - echo -e "expected, please rebuild without optimizations before" - echo -e "asking for support.${OFF}\n" - - echo -e "MAKEFLAGS: ${L_arrow}${BOLD}${MAKEFLAGS}${OFF}${R_arrow}" - [[ "$MAKEFLAGS" = "unset" ]] && echo - [[ "$MAKEFLAGS" != "unset" ]] && \ - echo -e "BLACK_LIST: ${L_arrow}${BOLD}${BLACK_LIST}${OFF}${R_arrow}\n" - - echo -e "DEF_OPT_MODE: ${L_arrow}${BOLD}${DEF_OPT_MODE}${OFF}${R_arrow}\n" - - for OPT_VAR in $ACTIVE_OPT_VARS ; do - eval optVal=\$${OPT_VAR}_${DEF_OPT_MODE} - echo -e "${OPT_VAR}: ${L_arrow}${BOLD}${optVal}${OFF}${R_arrow}" - done - - echo -e "\nOverridden packages:" - cat optimize/opt_override - echo "${nl_}${SD_BORDER}${nl_}" - - echo -n "Are you happy with these optimization settings? yes/no (no): " - read ANSWER - if [ x$ANSWER != "xyes" ] ; then - echo "${nl_}Fix the optimization options and rerun the script.${nl_}" - exit 1 - fi - echo "${nl_}${SD_BORDER}${nl_}" -} - -#----------------------------------# -wrt_optimize() { # Apply pkg specific opt's to build -#----------------------------------# - local pkg=$1 - local optMode optVal OPT_VAR - - optMode=`awk -v pkg="$pkg" '$1 == pkg { print $2 }' $JHALFSDIR/opt_override` - if [[ "$optMode" = "" ]] ; then - optMode=$DEF_OPT_MODE; - fi - - for OPT_VAR in $ACTIVE_OPT_VARS ; do - eval optVal=\$${OPT_VAR}_$optMode - - if [[ "$optVal" != "unset" ]]; then -( -cat << EOF - @echo "export $OPT_VAR=\"$optVal\"" >> envars -EOF -) >> $MKFILE.tmp - else - continue - fi - done -} - -#----------------------------------# -wrt_makeflags() { # Apply MAKEFLAGS to build -#----------------------------------# - local pkg=$1 - local MKF - - if [[ "$BLACK_LIST" =~ ${pkg} ]]; then - MKF=unset - else - MKF=$MAKEFLAGS - fi - - if [[ "$MKF" != "unset" ]]; then -( -cat << EOF - @echo "export MAKEFLAGS=\"$MAKEFLAGS\"" >> envars -EOF -) >> $MKFILE.tmp - fi -}