Implement a restart facility.
If you select to debug ct-ng, then you have two new options:
- DEBUG_CT_PAUSE_STEPS : pause between every steps,
- DEBUG_CT_SAVE_STEPS : save state between every steps.
To restart a saved state, just set the RESTART make variable when calling make:
- make RESTART=<step_name>
1.1 --- a/Makefile Tue May 22 20:42:21 2007 +0000
1.2 +++ b/Makefile Tue May 22 20:46:07 2007 +0000
1.3 @@ -9,6 +9,8 @@
1.4 # This is crosstool-ng version string
1.5 export CT_VERSION=$(shell cat $(CT_TOP_DIR)/version)
1.6
1.7 +export CT_RESTART=$(RESTART)
1.8 +
1.9 .PHONY: all
1.10 all: build
1.11
1.12 @@ -32,6 +34,7 @@
1.13
1.14 help::
1.15 @echo 'Execute "make" or "make all" to build all targets marked with [*]'
1.16 + @echo 'Pass RESTART=<step> to restart a previously saved step (read doc first!)'
1.17
1.18 .config: $(CONFIG_FILES) $(CT_TOP_DIR)/config/debug.in
1.19 @make oldconfig
2.1 --- a/config/global.in Tue May 22 20:42:21 2007 +0000
2.2 +++ b/config/global.in Tue May 22 20:46:07 2007 +0000
2.3 @@ -1,7 +1,16 @@
2.4 # Overall toolchain configuration: paths, jobs, etc...
2.5
2.6 +# Ah, this option is here to break the dependency tracking, and allow
2.7 +# dependent option to line-up with the options they depend on ,rather
2.8 +# than being indented
2.9 +config FOOBAR
2.10 + bool
2.11 + default n
2.12 +
2.13 menu "Paths and misc options"
2.14
2.15 +comment "Crosstool behavior"
2.16 +
2.17 config EXPERIMENTAL
2.18 bool
2.19 prompt "Try features marked as EXPERIMENTAL"
2.20 @@ -26,6 +35,64 @@
2.21 Such obsolete features are the use of old kernel headers, old
2.22 gcc versions, etc...
2.23
2.24 +config DEBUG_CT
2.25 + bool
2.26 + prompt "Debug crosstool-NG"
2.27 + default n
2.28 + help
2.29 + Say 'y' here to get some debugging options
2.30 +
2.31 +if DEBUG_CT
2.32 +
2.33 +config DEBUG_CT_PAUSE_STEPS
2.34 + bool
2.35 + prompt "Pause between every steps"
2.36 + default n
2.37 + help
2.38 + Say 'y' if you intend to attend the build, and want to investigate
2.39 + the result of each steps before running the next one.
2.40 +
2.41 +config DEBUG_CT_SAVE_STEPS
2.42 + bool
2.43 + prompt "Save intermediate steps"
2.44 + default n
2.45 + help
2.46 + If you say 'y' here, then you will be able to restart crosstool-NG at
2.47 + any step by typing:
2.48 + make RESTART=<step_nane>
2.49 +
2.50 + where step_name is one of:
2.51 + - kernel_hdr
2.52 + - binutils
2.53 + - libc_hdr
2.54 + - cc_core
2.55 + - libfloat
2.56 + - libc
2.57 + - cc
2.58 + - libc_fin
2.59 + - debug
2.60 +
2.61 + It is not currently possible to rstart at any of the debug facility.
2.62 + They are treated a s a whole.
2.63 +
2.64 +config DEBUG_CT_SAVE_STEPS_GZIP
2.65 + bool
2.66 + prompt "gzip saved states"
2.67 + default y
2.68 + depends on DEBUG_CT_SAVE_STEPS
2.69 + help
2.70 + If you are tight on space, then you can ask to gzip the saved states
2.71 + tarballs. On the other hand, this takes some longer time...
2.72 +
2.73 + To lose as less time as possible, the gzip process is done with a low
2.74 + compression ratio (-3), which gives roughly 70% gain in size. Going
2.75 + further doesn't gain much, and takes far more time (believe me, I've
2.76 + got figures here! :-) ).
2.77 +
2.78 +endif
2.79 +
2.80 +comment "Build behavior"
2.81 +
2.82 config PARALLEL_JOBS
2.83 int
2.84 prompt "Number of parallel jobs"
2.85 @@ -157,6 +224,8 @@
2.86
2.87 Usefull to pre-retrieve the tarballs before going off-line.
2.88
2.89 +config FOOBAR
2.90 +
2.91 comment "Extracting"
2.92 depends on ! ONLY_DOWNLOAD
2.93
3.1 --- a/scripts/crosstool.sh Tue May 22 20:42:21 2007 +0000
3.2 +++ b/scripts/crosstool.sh Tue May 22 20:46:07 2007 +0000
3.3 @@ -28,10 +28,10 @@
3.4 CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
3.5
3.6 # Log policy:
3.7 -# - what goes to the log file goes to fd #1 (stdout)
3.8 -# - what goes to the screen goes to fd #6
3.9 +# - first of all, save stdout so we can see the live logs: fd #6
3.10 +exec 6>&1
3.11 +# - then point stdout to the log file (temporary for now)
3.12 tmp_log_file="${CT_TOP_DIR}/$$.log"
3.13 -exec 6>&1
3.14 exec >>"${tmp_log_file}"
3.15
3.16 # Are we configured? We'll need that later...
3.17 @@ -54,6 +54,13 @@
3.18 # Some sanity checks in the environment and needed tools
3.19 CT_DoLog INFO "Checking environment sanity"
3.20
3.21 +# First of really first of really all, **must not** move lower than here!
3.22 +if [ -n "${CT_RESTART}" -a -z "${CT_DEBUG_CT_SAVE_STEPS}" ]; then
3.23 + CT_DoLog ERROR "You asked to restart a non-restartable build"
3.24 + CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS in the config options"
3.25 + CT_Abort "I will stop here to avoid any carnage"
3.26 +fi
3.27 +
3.28 # Enable known ordering of files in directory listings:
3.29 CT_Test "Crosstool-NG might not work as expected with LANG=\"${LANG}\"" -n "${LANG}"
3.30 case "${LC_COLLATE},${LC_ALL}" in
3.31 @@ -108,6 +115,11 @@
3.32 CT_SRC_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/src"
3.33 CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
3.34 CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
3.35 +# Note: we'll always install the core compiler in its own directory, so as to
3.36 +# not mix the two builds: core and final. Anyway, its generic, wether we use
3.37 +# a different compiler as core, or not.
3.38 +CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
3.39 +CT_STATE_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/state"
3.40
3.41 # Make all path absolute, it so much easier!
3.42 CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
3.43 @@ -140,47 +152,62 @@
3.44
3.45 CT_DoLog EXTRA "Preparing working directories"
3.46
3.47 -# Get rid of pre-existing installed toolchain and previous build directories.
3.48 -# We need to do that _before_ we can safely log, because the log file will
3.49 -# most probably be in the toolchain directory.
3.50 -if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
3.51 - mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
3.52 - chmod -R u+w "${CT_TARBALLS_DIR}.$$"
3.53 - nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
3.54 -fi
3.55 -if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
3.56 - mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
3.57 - chmod -R u+w "${CT_SRC_DIR}.$$"
3.58 - nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
3.59 -fi
3.60 +# Ah! The build directory shall be eradicated, even if we restart!
3.61 if [ -d "${CT_BUILD_DIR}" ]; then
3.62 mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
3.63 chmod -R u+w "${CT_BUILD_DIR}.$$"
3.64 nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
3.65 fi
3.66 -if [ -d "${CT_INSTALL_DIR}" ]; then
3.67 - mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
3.68 - chmod -R u+w "${CT_INSTALL_DIR}.$$"
3.69 - nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
3.70 -fi
3.71 -if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
3.72 - mv "${CT_DEBUG_INSTALL_DIR}" "${CT_DEBUG_INSTALL_DIR}.$$"
3.73 - chmod -R u+w "${CT_DEBUG_INSTALL_DIR}.$$"
3.74 - nohup rm -rf "${CT_DEBUG_INSTALL_DIR}.$$" >/dev/null 2>&1 &
3.75 +
3.76 +# Don't eradicate directories if we need to restart
3.77 +if [ -z "${CT_RESTART}" ]; then
3.78 + # Get rid of pre-existing installed toolchain and previous build directories.
3.79 + # We need to do that _before_ we can safely log, because the log file will
3.80 + # most probably be in the toolchain directory.
3.81 + if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
3.82 + mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
3.83 + chmod -R u+w "${CT_TARBALLS_DIR}.$$"
3.84 + nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
3.85 + fi
3.86 + if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
3.87 + mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
3.88 + chmod -R u+w "${CT_SRC_DIR}.$$"
3.89 + nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
3.90 + fi
3.91 + if [ -d "${CT_INSTALL_DIR}" ]; then
3.92 + mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
3.93 + chmod -R u+w "${CT_INSTALL_DIR}.$$"
3.94 + nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
3.95 + fi
3.96 + if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
3.97 + mv "${CT_DEBUG_INSTALL_DIR}" "${CT_DEBUG_INSTALL_DIR}.$$"
3.98 + chmod -R u+w "${CT_DEBUG_INSTALL_DIR}.$$"
3.99 + nohup rm -rf "${CT_DEBUG_INSTALL_DIR}.$$" >/dev/null 2>&1 &
3.100 + fi
3.101 + # In case we start anew, get rid of the previously saved state directory
3.102 + if [ -d "${CT_STATE_DIR}" ]; then
3.103 + mv "${CT_STATE_DIR}" "${CT_STATE_DIR}.$$"
3.104 + chmod -R u+w "${CT_STATE_DIR}.$$"
3.105 + nohup rm -rf "${CT_STATE_DIR}.$$" >/dev/null 2>&1 &
3.106 + fi
3.107 fi
3.108
3.109 -# Note: we'll always install the core compiler in its own directory, so as to
3.110 -# not mix the two builds: core and final. Anyway, its generic, wether we use
3.111 -# a different compiler as core, or not.
3.112 -CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
3.113 -
3.114 -# Create the directories we'll use
3.115 +# Create the directories we'll use, even if restarting: it does no harm to
3.116 +# create already existent directories, and CT_BUILD_DIR needs to be created
3.117 +# anyway
3.118 mkdir -p "${CT_TARBALLS_DIR}"
3.119 mkdir -p "${CT_SRC_DIR}"
3.120 mkdir -p "${CT_BUILD_DIR}"
3.121 mkdir -p "${CT_INSTALL_DIR}"
3.122 +mkdir -p "${CT_PREFIX_DIR}"
3.123 mkdir -p "${CT_DEBUG_INSTALL_DIR}"
3.124 mkdir -p "${CT_CC_CORE_PREFIX_DIR}"
3.125 +mkdir -p "${CT_STATE_DIR}"
3.126 +
3.127 +# Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
3.128 +# the previous build was successfull. To ba able to move the logfile there,
3.129 +# switch them back to read/write
3.130 +chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
3.131
3.132 # Redirect log to the actual log file now we can
3.133 # It's quite understandable that the log file will be installed in the install
3.134 @@ -191,127 +218,134 @@
3.135 ,*) rm -f "${tmp_log_file}"
3.136 ;;
3.137 y,/*) mkdir -p "`dirname \"${CT_LOG_FILE}\"`"
3.138 - mv "${tmp_log_file}" "${CT_LOG_FILE}"
3.139 + cat "${tmp_log_file}" >>"${CT_LOG_FILE}"
3.140 + rm -f "${tmp_log_file}"
3.141 exec >>"${CT_LOG_FILE}"
3.142 ;;
3.143 y,*) mkdir -p "`pwd`/`dirname \"${CT_LOG_FILE}\"`"
3.144 - mv "${tmp_log_file}" "`pwd`/${CT_LOG_FILE}"
3.145 + cat "${tmp_log_file}" >>"`pwd`/${CT_LOG_FILE}"
3.146 + rm -f "${tmp_log_file}"
3.147 exec >>"${CT_LOG_FILE}"
3.148 ;;
3.149 esac
3.150
3.151 -# Determine build system if not set by the user
3.152 -CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
3.153 -CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`"
3.154 +# Setting up the rest of the environment only is not restarting
3.155 +if [ -z "${CT_RESTART}" ]; then
3.156 + # Determine build system if not set by the user
3.157 + CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
3.158 + CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`"
3.159
3.160 -# Arrange paths depending on wether we use sys-root or not.
3.161 -if [ "${CT_USE_SYSROOT}" = "y" ]; then
3.162 - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
3.163 - CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
3.164 - BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.165 - CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.166 - CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.167 - LIBC_SYSROOT_ARG=""
3.168 - # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
3.169 - # confused when $sysroot/usr/include is not present.
3.170 - # Note: --prefix=/usr is magic!
3.171 - # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
3.172 -else
3.173 - # plain old way. All libraries in prefix/target/lib
3.174 - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
3.175 - CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
3.176 - # hack! Always use --with-sysroot for binutils.
3.177 - # binutils 2.14 and later obey it, older binutils ignore it.
3.178 - # Lets you build a working 32->64 bit cross gcc
3.179 - BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.180 - # Use --with-headers, else final gcc will define disable_glibc while
3.181 - # building libgcc, and you'll have no profiling
3.182 - CC_CORE_SYSROOT_ARG="--without-headers"
3.183 - CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
3.184 - LIBC_SYSROOT_ARG="prefix="
3.185 + # Arrange paths depending on wether we use sys-root or not.
3.186 + if [ "${CT_USE_SYSROOT}" = "y" ]; then
3.187 + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
3.188 + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
3.189 + BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.190 + CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.191 + CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.192 + LIBC_SYSROOT_ARG=""
3.193 + # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
3.194 + # confused when $sysroot/usr/include is not present.
3.195 + # Note: --prefix=/usr is magic!
3.196 + # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
3.197 + else
3.198 + # plain old way. All libraries in prefix/target/lib
3.199 + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
3.200 + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
3.201 + # hack! Always use --with-sysroot for binutils.
3.202 + # binutils 2.14 and later obey it, older binutils ignore it.
3.203 + # Lets you build a working 32->64 bit cross gcc
3.204 + BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.205 + # Use --with-headers, else final gcc will define disable_glibc while
3.206 + # building libgcc, and you'll have no profiling
3.207 + CC_CORE_SYSROOT_ARG="--without-headers"
3.208 + CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
3.209 + LIBC_SYSROOT_ARG="prefix="
3.210 + fi
3.211 +
3.212 + # Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
3.213 + # 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
3.214 + # "ld: cannot open crti.o: No such file or directory"
3.215 + mkdir -p "${CT_SYSROOT_DIR}/lib"
3.216 + mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
3.217 +
3.218 + # Canadian-cross are really picky on the way they are built. Tweak the values.
3.219 + if [ "${CT_CANADIAN}" = "y" ]; then
3.220 + # Arrange so that gcc never, ever think that build system == host system
3.221 + CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
3.222 + # We shall have a compiler for this target!
3.223 + # Do test here...
3.224 + else
3.225 + CT_HOST="${CT_BUILD}"
3.226 + CT_CANADIAN_OPT=
3.227 + # Add the target toolchain in the path so that we can build the C library
3.228 + export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
3.229 + fi
3.230 +
3.231 + # Modify GCC_HOST to never be equal to $BUILD or $TARGET
3.232 + # This strange operation causes gcc to always generate a cross-compiler
3.233 + # even if the build machine is the same kind as the host.
3.234 + # This is why CC has to be set when doing a canadian cross; you can't find a
3.235 + # host compiler by appending -gcc to our whacky $GCC_HOST
3.236 + # Kludge: it is reported that the above causes canadian crosses with cygwin
3.237 + # hosts to fail, so avoid it just in that one case. It would be cleaner to
3.238 + # just move this into the non-canadian case above, but I'm afraid that might
3.239 + # cause some configure script somewhere to decide that since build==host, they
3.240 + # could run host binaries.
3.241 + # (Copied almost as-is from original crosstool):
3.242 + case "${CT_KERNEL},${CT_CANADIAN}" in
3.243 + cygwin,y) ;;
3.244 + *) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
3.245 + esac
3.246 +
3.247 + # Ah! Recent versions of binutils need some of the build and/or host system
3.248 + # (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
3.249 + # Do that:
3.250 + CT_DoLog EXTRA "Making build system tools available"
3.251 + mkdir -p "${CT_PREFIX_DIR}/bin"
3.252 + for tool in ar as dlltool gcc g++ gnatbind gnatmake ld nm ranlib strip windres objcopy objdump; do
3.253 + if [ -n "`which ${tool}`" ]; then
3.254 + ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
3.255 + case "${CT_TOOLCHAIN_TYPE}" in
3.256 + cross|native) ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}";;
3.257 + esac
3.258 + fi
3.259 + done
3.260 +
3.261 + # Ha. cygwin host have an .exe suffix (extension) for executables.
3.262 + [ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
3.263 +
3.264 + # Transform the ARCH into a kernel-understandable ARCH
3.265 + case "${CT_ARCH}" in
3.266 + x86) CT_KERNEL_ARCH=i386;;
3.267 + ppc) CT_KERNEL_ARCH=powerpc;;
3.268 + *) CT_KERNEL_ARCH="${CT_ARCH}";;
3.269 + esac
3.270 +
3.271 + # Build up the TARGET_CFLAGS from user-provided options
3.272 + # Override with user-specified CFLAGS
3.273 + [ -n "${CT_ARCH_CPU}" ] && CT_TARGET_CFLAGS="-mcpu=${CT_ARCH_CPU} ${CT_TARGET_CFLAGS}"
3.274 + [ -n "${CT_ARCH_TUNE}" ] && CT_TARGET_CFLAGS="-mtune=${CT_ARCH_TUNE} ${CT_TARGET_CFLAGS}"
3.275 + [ -n "${CT_ARCH_ARCH}" ] && CT_TARGET_CFLAGS="-march=${CT_ARCH_ARCH} ${CT_TARGET_CFLAGS}"
3.276 + [ -n "${CT_ARCH_FPU}" ] && CT_TARGET_CFLAGS="-mfpu=${CT_ARCH_FPU} ${CT_TARGET_CFLAGS}"
3.277 +
3.278 + # Help gcc
3.279 + CT_CFLAGS_FOR_HOST=
3.280 + [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
3.281 +
3.282 + # And help make go faster
3.283 + PARALLELMFLAGS=
3.284 + [ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
3.285 + [ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
3.286 +
3.287 + CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
3.288 + CT_DoLog EXTRA "Building a toolchain for:"
3.289 + CT_DoLog EXTRA " build = ${CT_BUILD}"
3.290 + CT_DoLog EXTRA " host = ${CT_HOST}"
3.291 + CT_DoLog EXTRA " target = ${CT_TARGET}"
3.292 + set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
3.293 + CT_EndStep
3.294 fi
3.295
3.296 -# Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
3.297 -# 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
3.298 -# "ld: cannot open crti.o: No such file or directory"
3.299 -mkdir -p "${CT_SYSROOT_DIR}/lib"
3.300 -mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
3.301 -
3.302 -# Canadian-cross are really picky on the way they are built. Tweak the values.
3.303 -if [ "${CT_CANADIAN}" = "y" ]; then
3.304 - # Arrange so that gcc never, ever think that build system == host system
3.305 - CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
3.306 - # We shall have a compiler for this target!
3.307 - # Do test here...
3.308 -else
3.309 - CT_HOST="${CT_BUILD}"
3.310 - CT_CANADIAN_OPT=
3.311 - # Add the target toolchain in the path so that we can build the C library
3.312 - export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
3.313 -fi
3.314 -
3.315 -# Modify GCC_HOST to never be equal to $BUILD or $TARGET
3.316 -# This strange operation causes gcc to always generate a cross-compiler
3.317 -# even if the build machine is the same kind as the host.
3.318 -# This is why CC has to be set when doing a canadian cross; you can't find a
3.319 -# host compiler by appending -gcc to our whacky $GCC_HOST
3.320 -# Kludge: it is reported that the above causes canadian crosses with cygwin
3.321 -# hosts to fail, so avoid it just in that one case. It would be cleaner to
3.322 -# just move this into the non-canadian case above, but I'm afraid that might
3.323 -# cause some configure script somewhere to decide that since build==host, they
3.324 -# could run host binaries.
3.325 -# (Copied almost as-is from original crosstool):
3.326 -case "${CT_KERNEL},${CT_CANADIAN}" in
3.327 - cygwin,y) ;;
3.328 - *) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
3.329 -esac
3.330 -
3.331 -# Ah! Recent versions of binutils need some of the build and/or host system
3.332 -# (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
3.333 -# Do that:
3.334 -CT_DoLog EXTRA "Making build system tools available"
3.335 -mkdir -p "${CT_PREFIX_DIR}/bin"
3.336 -for tool in ar gcc; do
3.337 - ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
3.338 - case "${CT_TOOLCHAIN_TYPE}" in
3.339 - cross|native) ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}";;
3.340 - esac
3.341 -done
3.342 -
3.343 -# Ha. cygwin host have an .exe suffix (extension) for executables.
3.344 -[ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
3.345 -
3.346 -# Transform the ARCH into a kernel-understandable ARCH
3.347 -case "${CT_ARCH}" in
3.348 - x86) CT_KERNEL_ARCH=i386;;
3.349 - ppc) CT_KERNEL_ARCH=powerpc;;
3.350 - *) CT_KERNEL_ARCH="${CT_ARCH}";;
3.351 -esac
3.352 -
3.353 -# Build up the TARGET_CFLAGS from user-provided options
3.354 -# Override with user-specified CFLAGS
3.355 -[ -n "${CT_ARCH_CPU}" ] && CT_TARGET_CFLAGS="-mcpu=${CT_ARCH_CPU} ${CT_TARGET_CFLAGS}"
3.356 -[ -n "${CT_ARCH_TUNE}" ] && CT_TARGET_CFLAGS="-mtune=${CT_ARCH_TUNE} ${CT_TARGET_CFLAGS}"
3.357 -[ -n "${CT_ARCH_ARCH}" ] && CT_TARGET_CFLAGS="-march=${CT_ARCH_ARCH} ${CT_TARGET_CFLAGS}"
3.358 -[ -n "${CT_ARCH_FPU}" ] && CT_TARGET_CFLAGS="-mfpu=${CT_ARCH_FPU} ${CT_TARGET_CFLAGS}"
3.359 -
3.360 -# Help gcc
3.361 -CT_CFLAGS_FOR_HOST=
3.362 -[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
3.363 -
3.364 -# And help make go faster
3.365 -PARALLELMFLAGS=
3.366 -[ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
3.367 -[ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
3.368 -
3.369 -CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
3.370 -CT_DoLog EXTRA "Building a toolchain for:"
3.371 -CT_DoLog EXTRA " build = ${CT_BUILD}"
3.372 -CT_DoLog EXTRA " host = ${CT_HOST}"
3.373 -CT_DoLog EXTRA " target = ${CT_TARGET}"
3.374 -set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
3.375 -CT_EndStep
3.376 -
3.377 # Include sub-scripts instead of calling them: that way, we do not have to
3.378 # export any variable, nor re-parse the configuration and functions files.
3.379 . "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh"
3.380 @@ -322,64 +356,84 @@
3.381 . "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
3.382 . "${CT_TOP_DIR}/scripts/build/debug.sh"
3.383
3.384 -# Now for the job by itself. Go have a coffee!
3.385 -CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
3.386 -do_kernel_get
3.387 -do_binutils_get
3.388 -do_cc_core_get
3.389 -do_libfloat_get
3.390 -do_libc_get
3.391 -do_cc_get
3.392 -do_debug_get
3.393 -CT_EndStep
3.394 -
3.395 -if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
3.396 - if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
3.397 - mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
3.398 - nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1
3.399 - fi
3.400 - CT_DoStep INFO "Extracting and patching toolchain components"
3.401 - do_kernel_extract
3.402 - do_binutils_extract
3.403 - do_cc_core_extract
3.404 - do_libfloat_extract
3.405 - do_libc_extract
3.406 - do_cc_extract
3.407 - do_debug_extract
3.408 +if [ -z "${CT_RESTART}" ]; then
3.409 + CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
3.410 + do_kernel_get
3.411 + do_binutils_get
3.412 + do_cc_core_get
3.413 + do_libfloat_get
3.414 + do_libc_get
3.415 + do_cc_get
3.416 + do_debug_get
3.417 CT_EndStep
3.418
3.419 - if [ "${CT_ONLY_EXTRACT}" != "y" ]; then
3.420 - do_libc_check_config
3.421 - do_kernel_check_config
3.422 - do_kernel_headers
3.423 - do_binutils
3.424 - do_libc_headers
3.425 - do_cc_core
3.426 - do_libfloat
3.427 - do_libc
3.428 - do_cc
3.429 - do_libc_finish
3.430 - do_debug
3.431 + if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
3.432 + if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
3.433 + mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
3.434 + nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1
3.435 + fi
3.436 + CT_DoStep INFO "Extracting and patching toolchain components"
3.437 + do_kernel_extract
3.438 + do_binutils_extract
3.439 + do_cc_core_extract
3.440 + do_libfloat_extract
3.441 + do_libc_extract
3.442 + do_cc_extract
3.443 + do_debug_extract
3.444 + CT_EndStep
3.445 + fi
3.446 +fi
3.447
3.448 - # Create the aliases to the target tools
3.449 - if [ -n "${CT_TARGET_ALIAS}" ]; then
3.450 - CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
3.451 - CT_Pushd "${CT_PREFIX_DIR}/bin"
3.452 - for t in "${CT_TARGET}-"*; do
3.453 - _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
3.454 - CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
3.455 - ln -s "${t}" "${_t}"
3.456 - done
3.457 - CT_Popd
3.458 +# Now for the job by itself. Go have a coffee!
3.459 +if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
3.460 + # Because of CT_RESTART, this becomes quite complex
3.461 + [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
3.462 + for step in libc_check_config \
3.463 + kernel_check_config \
3.464 + kernel_headers \
3.465 + binutils \
3.466 + libc_headers \
3.467 + cc_core \
3.468 + libfloat \
3.469 + libc \
3.470 + cc \
3.471 + libc_finish \
3.472 + debug \
3.473 + ; do
3.474 + if [ ${do_it} -eq 0 ]; then
3.475 + if [ "${CT_RESTART}" = "${step}" ]; then
3.476 + CT_DoLoadState "${step}"
3.477 + do_it=1
3.478 + fi
3.479 + else
3.480 + CT_DoSaveState ${step}
3.481 fi
3.482 + if [ ${do_it} -eq 1 ]; then
3.483 + do_${step}
3.484 + if [ "${CTDEBUG_CT_PAUSE_STEPS}" = "y" ]; then
3.485 + CT_DoPause "Step \"${step}\" finished"
3.486 + fi
3.487 + fi
3.488 + done
3.489
3.490 - # Remove the generated documentation files
3.491 - if [ "${CT_REMOVE_DOCS}" = "y" ]; then
3.492 - CT_DoLog INFO "Removing installed documentation"
3.493 - rm -rf "${CT_PREFIX_DIR}/"{,usr/}{man,info}
3.494 - rm -rf "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
3.495 - rm -rf "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
3.496 - fi
3.497 + # Create the aliases to the target tools
3.498 + if [ -n "${CT_TARGET_ALIAS}" ]; then
3.499 + CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
3.500 + CT_Pushd "${CT_PREFIX_DIR}/bin"
3.501 + for t in "${CT_TARGET}-"*; do
3.502 + _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
3.503 + CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
3.504 + ln -s "${t}" "${_t}"
3.505 + done
3.506 + CT_Popd
3.507 + fi
3.508 +
3.509 + # Remove the generated documentation files
3.510 + if [ "${CT_REMOVE_DOCS}" = "y" ]; then
3.511 + CT_DoLog INFO "Removing installed documentation"
3.512 + rm -rf "${CT_PREFIX_DIR}/"{,usr/}{man,info}
3.513 + rm -rf "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
3.514 + rm -rf "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
3.515 fi
3.516 fi
3.517
4.1 --- a/scripts/functions Tue May 22 20:42:21 2007 +0000
4.2 +++ b/scripts/functions Tue May 22 20:46:07 2007 +0000
4.3 @@ -304,7 +304,7 @@
4.4 if [ -r "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" -a \
4.5 "${CT_FORCE_DOWNLOAD}" != "y" ]; then
4.6 CT_DoLog EXTRA "Copying \"${file}\" from local copy"
4.7 - cp -v "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" "${file}${ext}" |CT_DoLog DEBUG
4.8 + cp -v "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" "${file}${ext}" |CT_DoLog ALL
4.9 return 0
4.10 fi
4.11 done
4.12 @@ -460,3 +460,112 @@
4.13 esac
4.14 CT_TARGET="`${CT_TOP_DIR}/tools/config.sub ${CT_TARGET}`"
4.15 }
4.16 +
4.17 +# This function does pause the build until the user strikes "Return"
4.18 +# Usage: CT_DoPause [optional_message]
4.19 +CT_DoPause() {
4.20 + local foo
4.21 + local message="${1:-Pausing for your pleasure}"
4.22 + CT_DoLog INFO "${message}"
4.23 + read -p "Press \"Enter\" to continue, or Ctrl-C to stop..." foo >&6
4.24 + return 0
4.25 +}
4.26 +
4.27 +# This function saves the state of the toolchain to be able to restart
4.28 +# at any one point
4.29 +# Usage: CT_DoSaveState <next_step_name>
4.30 +CT_DoSaveState() {
4.31 + [ "${CT_DEBUG_CT_SAVE_STEPS}" = "y" ] || return 0
4.32 + local state_name="$1"
4.33 + local state_dir="${CT_STATE_DIR}/${state_name}"
4.34 +
4.35 + CT_DoLog DEBUG "Saving state to restart at step \"${state_name}\"..."
4.36 + rm -rf "${state_dir}"
4.37 + mkdir -p "${state_dir}"
4.38 +
4.39 + case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
4.40 + y) tar_opt=czf; tar_ext=".tar.gz";;
4.41 + *) tar_opt=cf; tar_ext=".tar";;
4.42 + esac
4.43 +
4.44 + CT_DoLog DEBUG " Saving environment and aliases"
4.45 + # We must omit shell functions
4.46 + # 'isgrep' is here because I don't seem to
4.47 + # be able to remove the functions names.
4.48 + set |awk '
4.49 + BEGIN { _p = 1; }
4.50 + $0~/^[^ ] ()/ { _p = 0; }
4.51 + _p == 1
4.52 + $0 == "}" { _p = 1; }
4.53 + ' |egrep -v '^[^ ]+ \(\)' >"${state_dir}/env.sh"
4.54 +
4.55 + CT_DoLog DEBUG " Saving CT_CC_CORE_PREFIX_DIR=\"${CT_CC_CORE_PREFIX_DIR}\""
4.56 + CT_Pushd "${CT_CC_CORE_PREFIX_DIR}"
4.57 + tar ${tar_opt} "${state_dir}/cc_core_prefix_dir${tar_ext}" .
4.58 + CT_Popd
4.59 +
4.60 + CT_DoLog DEBUG " Saving CT_PREFIX_DIR=\"${CT_PREFIX_DIR}\""
4.61 + CT_Pushd "${CT_PREFIX_DIR}"
4.62 + tar ${tar_opt} "${state_dir}/prefix_dir${tar_ext}" .
4.63 + CT_Popd
4.64 +
4.65 + if [ "${CT_LOG_TO_FILE}" = "y" ]; then
4.66 + CT_DoLog DEBUG " Saving log file"
4.67 + exec >/dev/null
4.68 + case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
4.69 + y) gzip -3 -c "${CT_LOG_FILE}" >"${state_dir}/log.gz";;
4.70 + *) cat "${CT_LOG_FILE}" >"${state_dir}/log";;
4.71 + esac
4.72 + exec >>"${CT_LOG_FILE}"
4.73 + fi
4.74 +}
4.75 +
4.76 +# This functions restores a previously saved state
4.77 +# Usage: CT_DoLoadState <state_name>
4.78 +CT_DoLoadState(){
4.79 + local state_name="$1"
4.80 + local state_dir="${CT_STATE_DIR}/${state_name}"
4.81 +
4.82 + # We need to do something special with the log file!
4.83 + if [ "${CT_LOG_TO_FILE}" = "y" ]; then
4.84 + exec >"${state_dir}/tail.log"
4.85 + fi
4.86 + CT_DoLog DEBUG "Restoring state at step \"${state_name}\"..."
4.87 +
4.88 + case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
4.89 + y) tar_opt=xzf; tar_ext=".tar.gz";;
4.90 + *) tar_opt=cf; tar_ext=".tar";;
4.91 + esac
4.92 +
4.93 + CT_DoLog DEBUG " Removing previous build directories"
4.94 + chmod -R u+rwX "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
4.95 + rm -rf "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
4.96 + mkdir -p "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
4.97 +
4.98 + CT_DoLog DEBUG " Restoring CT_PREFIX_DIR=\"${CT_PREFIX_DIR}\""
4.99 + CT_Pushd "${CT_PREFIX_DIR}"
4.100 + tar ${tar_opt} "${state_dir}/prefix_dir${tar_ext}"
4.101 + CT_Popd
4.102 +
4.103 + CT_DoLog DEBUG " Restoring CT_CC_CORE_PREFIX_DIR=\"${CT_CC_CORE_PREFIX_DIR}\""
4.104 + CT_Pushd "${CT_CC_CORE_PREFIX_DIR}"
4.105 + tar ${tar_opt} "${state_dir}/cc_core_prefix_dir${tar_ext}"
4.106 + CT_Popd
4.107 +
4.108 + # Restore the environment, discarding any error message
4.109 + # (for example, read-only bash internals)
4.110 + CT_DoLog DEBUG " Restoring environment"
4.111 + . "${state_dir}/env.sh" >/dev/null 2>&1 || true
4.112 +
4.113 + if [ "${CT_LOG_TO_FILE}" = "y" ]; then
4.114 + CT_DoLog DEBUG " Restoring log file"
4.115 + exec >/dev/null
4.116 + case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
4.117 + y) zcat "${state_dir}/log.gz" >"${CT_LOG_FILE}";;
4.118 + *) cat "${state_dir}/log" >"${CT_LOG_FILE}";;
4.119 + esac
4.120 + cat "${state_dir}/tail.log" >>"${CT_LOG_FILE}"
4.121 + exec >>"${CT_LOG_FILE}"
4.122 + rm -f "${state_dir}/tail.log"
4.123 + fi
4.124 +}