# HG changeset patch # User Rob Landley # Date 1269561270 18000 # Node ID 48784ae8533e14614e46decc446d21845638b648 # Parent f99d25daec6a53becb7bdca4582a1da3d387d605 Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there. diff -r f99d25daec6a -r 48784ae8533e build.sh --- a/build.sh Thu Mar 25 15:19:10 2010 -0500 +++ b/build.sh Thu Mar 25 18:54:30 2010 -0500 @@ -39,21 +39,22 @@ # Do we need to build the simple cross compiler? -# This version has no thread support, no libgcc_s.so, doesn't include -# uClibc++, and is dynamically linked against the host's shared libraries. - if not_already simple-cross-compiler then # If we need to build cross compiler, assume root filesystem is stale. rm -rf "$BUILD/root-filesystem-$ARCH.tar.bz2" time ./simple-cross-compiler.sh "$ARCH" || exit 1 + + if [ ! -z "$CROSS_SMOKE_TEST" ] + then + sources/more/cross-smoke-test.sh "$ARCH" || exit 1 + fi fi -# Optionally, we can build a statically linked compiler via canadian cross. - -# We don't autodetect the host because i686 is more portable (running on -# both 64 and 32 bit hosts), but x86_64 is (slightly) faster on a 64 bit host. +# Optionally, we can build a more capable statically linked compiler via +# canadian cross. (It's more powerful than we need here, but if you're going +# to use the cross compiler in other contexts this is probably what you want.) if [ ! -z "$STATIC_CC_HOST" ] && not_already cross-compiler then @@ -67,6 +68,11 @@ BUILD_STATIC=1 FROM_ARCH="$STATIC_CC_HOST" STAGE_NAME=cross-compiler \ ./native-compiler.sh "$ARCH" || exit 1 + + if [ ! -z "$CROSS_SMOKE_TEST" ] + then + sources/more/cross-smoke-test.sh "$ARCH" || exit 1 + fi fi # Build a native compiler. It's statically linked by default so it can be diff -r f99d25daec6a -r 48784ae8533e native-compiler.sh --- a/native-compiler.sh Thu Mar 25 15:19:10 2010 -0500 +++ b/native-compiler.sh Thu Mar 25 18:54:30 2010 -0500 @@ -1,10 +1,21 @@ #!/bin/bash -# Build a compiler for a given target +# Build a compiler for a given target, using one or more existing simple +# cross compilers. + +# This can be used to build a native compiler for an aribitrary target, or to +# build a more portable and capable cross compiler for an arbitrary host. -source sources/include.sh || exit 1 -read_arch_dir "$1" +# The new compiler is built --with-shared and has uClibc++ installed, and is +# statically linked against uClibc (for portability) unless BUILD_STATIC=none. + +source sources/include.sh && read_arch_dir "$1" || exit 1 check_for_base_arch || exit 0 + +# Building a cross compiler requires _two_ existing simple compilers: one for +# the host (to build the executables), and one for the target (to build +# the libraries). For native compilers both checks test for the same thing. + check_prerequisite "${ARCH}-cc" check_prerequisite "${FROM_ARCH}-cc" diff -r f99d25daec6a -r 48784ae8533e simple-cross-compiler.sh --- a/simple-cross-compiler.sh Thu Mar 25 15:19:10 2010 -0500 +++ b/simple-cross-compiler.sh Thu Mar 25 18:54:30 2010 -0500 @@ -1,6 +1,14 @@ #!/bin/bash -# Build a cross compiler for the specified target. +# Build a simple cross compiler for the specified target. + +# This simple compiler has no thread support, no libgcc_s.so, doesn't include +# uClibc++, and is dynamically linked against the host's shared libraries. + +# Its stripped down nature makes it easy to build on an arbitrary host, and +# provides just enough capability to build a root filesystem, and to be used +# as a distcc accelerator from within that system. + # Get lots of predefined environment variables and shell functions. @@ -63,12 +71,7 @@ echo "Sanity test: building Hello World." "${ARCH}-gcc" -Os "${SOURCES}/toys/hello.c" -o "$WORK"/hello && -"${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello && -if [ ! -z "$CROSS_SMOKE_TEST" ] && which qemu-"${QEMU_TEST}" > /dev/null -then - [ x"$(qemu-"${QEMU_TEST}" "${WORK}"/hello)" == x"Hello world!" ] && - echo Cross-toolchain seems to work. -fi +"${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello || dienow [ $? -ne 0 ] && dienow diff -r f99d25daec6a -r 48784ae8533e sources/more/cross-smoke-test.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/more/cross-smoke-test.sh Thu Mar 25 18:54:30 2010 -0500 @@ -0,0 +1,27 @@ +#!/bin/bash + +source sources/include.sh && read_arch_dir "$1" || exit 1 + +# Build statically linked hello world, if necessary + +if [ ! -e "$WORK/hello" ] +then + "${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello + + if [ $? -ne 0 ] + then + echo "Compiler doesn't seem to work" >&2 + dienow + fi +fi + +# Attempt to run statically linked hello world + +RESULT="$(PATH="$OLDPATH" qemu-"$QEMU_TEST" "$WORK/hello")" +if [ "$RESULT" == "Hello world!" ] +then + echo "Cross toolchain seems to work." +else + echo "Can't run hello world" >&2 + dienow +fi diff -r f99d25daec6a -r 48784ae8533e sources/targets/powerpc/settings --- a/sources/targets/powerpc/settings Thu Mar 25 15:19:10 2010 -0500 +++ b/sources/targets/powerpc/settings Thu Mar 25 18:54:30 2010 -0500 @@ -2,7 +2,7 @@ KERNEL_PATH=vmlinux GCC_FLAGS="--enable-sjlj-exceptions" BINUTILS_FLAGS= -QEMU_TEST= #ppc +QEMU_TEST=ppc ROOT=hda CONSOLE=ttyS0