POC for optimizations code.
This commit is contained in:
parent
65d83a612a
commit
17c7894389
7 changed files with 104 additions and 11 deletions
|
@ -215,6 +215,7 @@ chapter6_Makefiles() {
|
|||
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
|
||||
|
|
|
@ -198,8 +198,6 @@ HEADER="# This file is automatically generated by jhalfs-X
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_target() { # Create target and initialize log file
|
||||
#----------------------------------#
|
||||
|
@ -259,7 +257,6 @@ EOF
|
|||
}
|
||||
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
||||
#----------------------------------#
|
||||
|
@ -273,6 +270,36 @@ EOF
|
|||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
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
|
||||
#----------------------------------#
|
||||
|
|
|
@ -11,6 +11,10 @@ declare -r LOG=000-masterscript.log
|
|||
#--- 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 @@ SERVER=ftp://ftp.lfs-matrix.net
|
|||
# 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 @@ RUNMAKE=0
|
|||
# (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
|
||||
|
||||
|
|
|
@ -84,10 +84,10 @@ validate_config() { # Are the config values sane (within reason)
|
|||
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 @@ 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" ;;
|
||||
STRIP) validate_against_str "x0x x1x" ;;
|
||||
VIMLANG) validate_against_str "x0x x1x" ;;
|
||||
DEPEND) validate_against_str "x0x x1x x2x" ;;
|
||||
|
|
50
common/opt_config
Normal file
50
common/opt_config
Normal file
|
@ -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"
|
4
common/opt_override
Normal file
4
common/opt_override
Normal file
|
@ -0,0 +1,4 @@
|
|||
binutils 0
|
||||
gcc 0
|
||||
glibc 0
|
||||
grub 0
|
|
@ -56,6 +56,11 @@ source $COMMON_DIR/config
|
|||
[[ $? > 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 @@ fi
|
|||
|
||||
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
|
||||
|
|
Reference in a new issue