Manuel,
Just saw earlier that you merged the optimization code into jhalfs..
Awesome.
I'm sorry I didn't have time to do it sooner, but I implemented some of
the ideas I mentioned previously and have attached a patch against
jhalfs-2639 for you to review when you get a chance.
I'm still in the process of running a test build with it, but the
generated Makefiles look as expected.
Changes:
- optimization levels -> optimization modes to reduce confusion with
command-line addition
- added optimization level to command-line to mimic test level
- 0: disabled, 1: ch6 only, 2: ch5 && ch6
- tweaked validation to include OPTIMIZATION=2
- moved optimization mode configurations to common/opt_config.d/<mode>
- modes are loaded by a loop in common/opt_config
- allows inheritance (more or less)
- opt_config could otherwise get very big and hard to edit
(especially if people have 9-10+ variables for each mode)
- added ACTIVE_OPT_VARS variable to enable desired variables
- the internal code just loops through the configurable list rather
than naming then explicitly in the code
- makes it easy to add others at the configuration level
without messing with the internal code
- moved the zlib hack out of wrt_optimize()
- uses the inheritance method to append " -fPIC" to the default
- users shouldn't have to edit internal code to remove a hard-coded
option; it is really out of place in that function, IMO.
- the hack gets uglier when more variables are used
- disabled optimization by default (default should be as per LFS)
- removed the '-march=pentium4' from the default so people
can get a stripped -O3 build without changing anything
if they have a different architecture.
- could/(should?) possibly remove the "-s" from the default too
since stripping is optional in the books (but didn't). Thoughts?
- cleaned up comments to reflect changes
- fixed my stupidity in comments (ie: s/cat ".."/echo ".."/) ..doh.
Limitations:
- No ?LFS optimization support still
- No default optimization mode from command-line
Future?:
- ditch the excessive preloaded env variables
- change to opt_config.d/modeOne_modeTwo:
----
inherits modeOne
cflags "-O3"
cxxflags cflags
...and so on.
----
- read only the appropriate mode config file from
common/opt_config.d/ as needed by current package
- the inheritance would then need to be handled internally
by the code parsing the file
- Add {C{,XX},LD}_EXTRA_FLAGS if needed.. others?
Looks like more than it is, really. Sorry for the long read.
Regards,
Jeremy.
diff -Naur jhalfs-2639/common/common-functions
jhalfs-2639-opt/common/common-functions
--- jhalfs-2639/common/common-functions 2006-05-04 20:46:41.000000000 -0700
+++ jhalfs-2639-opt/common/common-functions 2006-05-04 23:33:40.000000000
-0700
@@ -60,6 +60,13 @@
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
@@ -285,13 +292,10 @@
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
diff -Naur jhalfs-2639/common/config jhalfs-2639-opt/common/config
--- jhalfs-2639/common/config 2006-05-04 20:46:41.000000000 -0700
+++ jhalfs-2639-opt/common/config 2006-05-04 23:33:40.000000000 -0700
@@ -34,9 +34,13 @@
# 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
diff -Naur jhalfs-2639/common/func_validate_configs.sh
jhalfs-2639-opt/common/func_validate_configs.sh
--- jhalfs-2639/common/func_validate_configs.sh 2006-05-04 20:46:41.000000000
-0700
+++ jhalfs-2639-opt/common/func_validate_configs.sh 2006-05-04
23:33:40.000000000 -0700
@@ -205,7 +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" ;;
+ 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" ;;
diff -Naur jhalfs-2639/common/opt_config jhalfs-2639-opt/common/opt_config
--- jhalfs-2639/common/opt_config 2006-05-04 20:46:41.000000000 -0700
+++ jhalfs-2639-opt/common/opt_config 2006-05-04 23:33:40.000000000 -0700
@@ -4,47 +4,32 @@
#
#####
-#--- Default optimization level
-# This level is overridden by definitions in common/def_opt_override;
+#--- 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 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=""
+# 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 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"
+#--- 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"
+
+#--- 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
diff -Naur jhalfs-2639/common/opt_config.d/defOpt
jhalfs-2639-opt/common/opt_config.d/defOpt
--- jhalfs-2639/common/opt_config.d/defOpt 1969-12-31 16:00:00.000000000
-0800
+++ jhalfs-2639-opt/common/opt_config.d/defOpt 2006-05-04 23:33:40.000000000
-0700
@@ -0,0 +1,17 @@
+#####
+#
+# 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
diff -Naur jhalfs-2639/common/opt_config.d/defOpt_fPIC
jhalfs-2639-opt/common/opt_config.d/defOpt_fPIC
--- jhalfs-2639/common/opt_config.d/defOpt_fPIC 1969-12-31 16:00:00.000000000
-0800
+++ jhalfs-2639-opt/common/opt_config.d/defOpt_fPIC 2006-05-04
23:38:49.000000000 -0700
@@ -0,0 +1,20 @@
+#####
+#
+# 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
diff -Naur jhalfs-2639/common/opt_config.d/noOpt
jhalfs-2639-opt/common/opt_config.d/noOpt
--- jhalfs-2639/common/opt_config.d/noOpt 1969-12-31 16:00:00.000000000
-0800
+++ jhalfs-2639-opt/common/opt_config.d/noOpt 2006-05-04 23:33:40.000000000
-0700
@@ -0,0 +1,21 @@
+#####
+#
+# 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"
diff -Naur jhalfs-2639/common/opt_config.d/noSymbols
jhalfs-2639-opt/common/opt_config.d/noSymbols
--- jhalfs-2639/common/opt_config.d/noSymbols 1969-12-31 16:00:00.000000000
-0800
+++ jhalfs-2639-opt/common/opt_config.d/noSymbols 2006-05-04
23:33:40.000000000 -0700
@@ -0,0 +1,17 @@
+#####
+#
+# 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
diff -Naur jhalfs-2639/common/opt_override jhalfs-2639-opt/common/opt_override
--- jhalfs-2639/common/opt_override 2006-05-04 20:46:41.000000000 -0700
+++ jhalfs-2639-opt/common/opt_override 2006-05-04 23:33:40.000000000 -0700
@@ -1,4 +1,5 @@
-binutils 0
-gcc 0
-glibc 0
-grub 0
+binutils noOpt
+gcc noOpt
+glibc noOpt
+grub noOpt
+zlib defOpt_fPIC
diff -Naur jhalfs-2639/LFS/master.sh jhalfs-2639-opt/LFS/master.sh
--- jhalfs-2639/LFS/master.sh 2006-05-04 20:46:39.000000000 -0700
+++ jhalfs-2639-opt/LFS/master.sh 2006-05-04 23:33:40.000000000 -0700
@@ -112,6 +112,7 @@
# 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 @@
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
diff -Naur jhalfs-2639/master.sh jhalfs-2639-opt/master.sh
--- jhalfs-2639/master.sh 2006-05-04 20:46:41.000000000 -0700
+++ jhalfs-2639-opt/master.sh 2006-05-04 23:33:40.000000000 -0700
@@ -157,6 +157,21 @@
--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 @@
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
--
http://linuxfromscratch.org/mailman/listinfo/alfs-discuss
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page