r2629 - in jhalfs/branches/experimental: . LFS common

manuel at linuxfromscratch.org manuel at linuxfromscratch.org
Wed May 3 15:03:59 PDT 2006


Author: manuel
Date: 2006-05-03 16:03:58 -0600 (Wed, 03 May 2006)
New Revision: 2629

Added:
   jhalfs/branches/experimental/common/opt_config
   jhalfs/branches/experimental/common/opt_override
Modified:
   jhalfs/branches/experimental/LFS/master.sh
   jhalfs/branches/experimental/common/common-functions
   jhalfs/branches/experimental/common/config
   jhalfs/branches/experimental/common/func_validate_configs.sh
   jhalfs/branches/experimental/master.sh
Log:
POC for optimizations code.

Modified: jhalfs/branches/experimental/LFS/master.sh
===================================================================
--- jhalfs/branches/experimental/LFS/master.sh	2006-05-03 19:35:01 UTC (rev 2628)
+++ jhalfs/branches/experimental/LFS/master.sh	2006-05-03 22:03:58 UTC (rev 2629)
@@ -215,6 +215,7 @@
     if [ "$vrs" != "" ] ; then
       FILE="$name-$vrs.tar.*"
       wrt_unpack2 "$FILE"
+      [[ "$OPTIMIZE" = "1" ]] && wrt_optimize "$name"
     fi
 
     # In the mount of kernel filesystems we need to set LFS

Modified: jhalfs/branches/experimental/common/common-functions
===================================================================
--- jhalfs/branches/experimental/common/common-functions	2006-05-03 19:35:01 UTC (rev 2628)
+++ jhalfs/branches/experimental/common/common-functions	2006-05-03 22:03:58 UTC (rev 2629)
@@ -198,8 +198,6 @@
 
 
 
-
-
 #----------------------------------#
 wrt_target() {                     # Create target and initialize log file
 #----------------------------------#
@@ -259,7 +257,6 @@
 }
 
 
-
 #----------------------------------#
 wrt_target_vars() {                # Target vars for hlfs (cross-build method)
 #----------------------------------#
@@ -274,6 +271,36 @@
 
 
 #----------------------------------#
+wrt_optimize() {                   # Apply pkg specific opt's to build
+#----------------------------------#
+  local pkg=$1
+  local optLvl optVal OPT_VAR
+
+  optLvl=`awk -v pkg="$pkg" '$1 == pkg { print $2 }' $JHALFSDIR/opt_override`
+  if [[ "$optLvl" = "" ]] ; then
+    optLvl=$DEF_OPT_LVL;
+  fi
+
+  for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; 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
+EOF
+) >> $MKFILE.tmp
+    else
+      continue
+    fi
+  done
+}
+
+
+#----------------------------------#
 wrt_run_as_su() {                  # Execute script inside time { }, footer to log file
 #----------------------------------#
   local this_script=$1

Modified: jhalfs/branches/experimental/common/config
===================================================================
--- jhalfs/branches/experimental/common/config	2006-05-03 19:35:01 UTC (rev 2628)
+++ jhalfs/branches/experimental/common/config	2006-05-03 22:03:58 UTC (rev 2629)
@@ -11,6 +11,10 @@
 #--- Mount point for the build
 BUILDDIR=/mnt/build_dir
 
+# Create SBU and disk usage report  0(no)/1(yes)
+# NOTE: requires to have bc installed on the host
+REPORT=1
+
 #=== Getting packages ===
 #--- Download the source packages 0(no)/1(yes)
 GETPKG=0
@@ -30,6 +34,10 @@
 #    In BLFS the Makefile can't be run automatically
 RUNMAKE=0
 
+#--- Optimize the build? 0(no)/1(yes)
+# Optimization values are set in opt_config and opt_override
+OPTIMIZE=1
+
 #--- Run test suites  [0-3]
 #  0 = none
 #  1 = only chapter06 Glibc, GCC and Binutils testsuites
@@ -41,10 +49,6 @@
 #      (in CLFS, alias to 2)
 TEST=1
 
-# Create SBU and disk usage report  0(no)/1(yes)
-# NOTE: requires to have bc installed on the host
-REPORT=1
-
 #--- Run the stripping phases  0(no)/1(yes)
 STRIP=1
 

Modified: jhalfs/branches/experimental/common/func_validate_configs.sh
===================================================================
--- jhalfs/branches/experimental/common/func_validate_configs.sh	2006-05-03 19:35:01 UTC (rev 2628)
+++ jhalfs/branches/experimental/common/func_validate_configs.sh	2006-05-03 22:03:58 UTC (rev 2629)
@@ -84,10 +84,10 @@
 inline_doc
 
   # First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
-  local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG         DEPEND                TEST"
-  local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE MODEL GRSECURITY_HOST TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB             CONFIG KEYMAP         PAGE TIMEZONE LANG LC_ALL"
-  local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE METHOD  ARCH  TARGET  TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG"
-  local -r  lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE                       TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB             CONFIG        VIMLANG PAGE TIMEZONE LANG"
+  local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG         DEPEND                TEST OPTIMIZE"
+  local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE MODEL GRSECURITY_HOST TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB             CONFIG KEYMAP         PAGE TIMEZONE LANG LC_ALL"
+  local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE METHOD  ARCH  TARGET  TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG"
+  local -r  lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE                       TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB             CONFIG        VIMLANG PAGE TIMEZONE LANG"
 
   local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
   local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
@@ -205,6 +205,7 @@
       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" ;;
       STRIP)      validate_against_str "x0x x1x" ;;
       VIMLANG)    validate_against_str "x0x x1x" ;;
       DEPEND)     validate_against_str "x0x x1x x2x" ;;

Added: jhalfs/branches/experimental/common/opt_config
===================================================================
--- jhalfs/branches/experimental/common/opt_config	                        (rev 0)
+++ jhalfs/branches/experimental/common/opt_config	2006-05-03 22:03:58 UTC (rev 2629)
@@ -0,0 +1,50 @@
+#####
+#
+# 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
+
+#--- 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"
+
+
+#--- LEVEL 1
+CFLAGS_1="-O2 -pipe"
+CXXFLAGS_1=$CFLAGS_1
+LDFLAGS_1=""
+
+#--- 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"


Property changes on: jhalfs/branches/experimental/common/opt_config
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/branches/experimental/common/opt_override
===================================================================
--- jhalfs/branches/experimental/common/opt_override	                        (rev 0)
+++ jhalfs/branches/experimental/common/opt_override	2006-05-03 22:03:58 UTC (rev 2629)
@@ -0,0 +1,4 @@
+binutils       0
+gcc            0
+glibc          0
+grub           0


Property changes on: jhalfs/branches/experimental/common/opt_override
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Modified: jhalfs/branches/experimental/master.sh
===================================================================
--- jhalfs/branches/experimental/master.sh	2006-05-03 19:35:01 UTC (rev 2628)
+++ jhalfs/branches/experimental/master.sh	2006-05-03 22:03:58 UTC (rev 2629)
@@ -56,6 +56,11 @@
 [[ $? > 0 ]] && echo "$COMMON_DIR/conf did not load.." && exit
 [[ $VERBOSITY > 0 ]] && echo "OK"
 #
+[[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
+source $COMMON_DIR/opt_config
+[[ $? > 0 ]] && echo " $COMMON_DIR/opt_config did not load.." && exit
+[[ $VERBOSITY > 0 ]] && echo "OK"
+#
 [[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
 source $COMMON_DIR/func_compare.sh
 [[ $? > 0 ]] && echo "$COMMON_DIR/func_compare.sh did not load.." && exit
@@ -468,6 +473,7 @@
 
 if [[ "$PWD" != "$JHALFSDIR" ]]; then
   cp $COMMON_DIR/makefile-functions $JHALFSDIR/
+  [[ "$OPTIMIZE" = "1" ]] && cp $COMMON_DIR/opt_override $JHALFSDIR/
   if [[ "$COMPARE" != "0" ]] ; then
     mkdir -p $JHALFSDIR/extras
     cp extras/* $JHALFSDIR/extras




More information about the alfs-log mailing list