# HG changeset patch # User Rob Landley # Date 1239880910 18000 # Node ID db04bd3c11e0d951c624d15de6a74ccc267312e3 # Parent 9282f84b31a1e5dad95baf5c1eef866325e4a5b6 First pass at canadian cross toolchain build. Result doesn't actually work yet, but it builds. diff -r 9282f84b31a1 -r db04bd3c11e0 config --- a/config Fri Apr 10 03:32:41 2009 -0500 +++ b/config Thu Apr 16 06:21:50 2009 -0500 @@ -27,9 +27,9 @@ # export RECORD_COMMANDS=1 -# If this is set, the cross-compiler stage is compiled with --static. +# If this is set, the compiler is built with --static. -# export CROSS_BUILD_STATIC=1 +# export BUILD_STATIC=1 # This may be set by the target's "details" file, but you can override it here. # You can set it to ext2, initramfs, or squashfs. It defaults to ext2 if blank. diff -r 9282f84b31a1 -r db04bd3c11e0 cross-compiler.sh --- a/cross-compiler.sh Fri Apr 10 03:32:41 2009 -0500 +++ b/cross-compiler.sh Thu Apr 16 06:21:50 2009 -0500 @@ -14,7 +14,7 @@ rm -rf "${CROSS}" mkdir -p "${CROSS}" || dienow -[ -z "$CROSS_BUILD_STATIC" ] || STATIC_FLAGS='--static' +[ -z "$BUILD_STATIC" ] || STATIC_FLAGS='--static' # Build and install binutils diff -r 9282f84b31a1 -r db04bd3c11e0 root-filesystem.sh --- a/root-filesystem.sh Fri Apr 10 03:32:41 2009 -0500 +++ b/root-filesystem.sh Thu Apr 16 06:21:50 2009 -0500 @@ -82,15 +82,18 @@ else +[ "$FROM_ARCH" != "$ARCH" ] && PROGRAM_PREFIX="${ARCH}-" +[ -z "$BUILD_STATIC" ] || STATIC_FLAGS='--static' + # Build and install native binutils setupfor binutils build-binutils -CC="${ARCH}-gcc" AR="${ARCH}-ar" "${CURSRC}/configure" --prefix="${TOOLS}" \ - --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --target="${CROSS_TARGET}" \ - --disable-nls --disable-shared --disable-multilib --program-prefix= \ - --disable-werror $BINUTILS_FLAGS && +CC="${FROM_ARCH}-gcc" AR="${FROM_ARCH}-ar" "${CURSRC}/configure" --prefix="${TOOLS}" \ + --build="${CROSS_HOST}" --host="${FROM_HOST}" --target="${CROSS_TARGET}" \ + --disable-nls --disable-shared --disable-multilib --disable-werror \ + --program-prefix="$PROGRAM_PREFIX" $BINUTILS_FLAGS && make -j $CPUS configure-host && -make -j $CPUS && +make -j $CPUS CFLAGS="-O2 $STATIC_FLAGS" && make -j $CPUS install && cd .. && mkdir -p "${TOOLS}/include" && @@ -108,22 +111,24 @@ # GCC has some deep assumptions about the name of the cross-compiler it should # be using. These assumptions are wrong, and lots of redundant corrections # are required to make it stop. -CC="${ARCH}-gcc" GCC_FOR_TARGET="${ARCH}-gcc" CC_FOR_TARGET="${ARCH}-gcc" \ - AR="${ARCH}-ar" AR_FOR_TARGET="${ARCH}-ar" AS="${ARCH}-as" LD="${ARCH}-ld" \ +CC="${FROM_ARCH}-gcc" AR="${FROM_ARCH}-ar" AS="${FROM_ARCH}-as" \ + LD="${FROM_ARCH}-ld" NM="${FROM_ARCH}-nm" \ + CC_FOR_TARGET="${ARCH}-cc" AR_FOR_TARGET="${ARCH}-ar" \ + NM_FOR_TARGET="${ARCH}-nm" GCC_FOR_TARGET="${ARCH}-gcc" \ + CXX_FOR_TARGET="${ARCH}-g++" \ ac_cv_path_AR_FOR_TARGET="${ARCH}-ar" \ ac_cv_path_RANLIB_FOR_TARGET="${ARCH}-ranlib" \ ac_cv_path_NM_FOR_TARGET="${ARCH}-nm" \ - NM="${ARCH}-nm" NM_FOR_TARGET="${ARCH}-nm" CXX_FOR_TARGET="${ARCH}-g++" \ "${CURSRC}/configure" --prefix="${TOOLS}" --disable-multilib \ --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --target="${CROSS_TARGET}" \ --enable-long-long --enable-c99 --enable-shared --enable-threads=posix \ --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \ - --disable-libstdcxx-pch --program-prefix="" \ + --disable-libstdcxx-pch --program-prefix="$PROGRAM_PREFIX" \ $GCC_FLAGS && mkdir gcc && ln -s `which "${ARCH}-gcc"` gcc/xgcc && make -j $CPUS configure-host && -make -j $CPUS all-gcc && +make -j $CPUS all-gcc LDFLAGS="$STATIC_FLAGS" && # Work around gcc bug; we disabled multilib but it doesn't always notice. ln -s lib "$TOOLS/lib64" && make -j $CPUS install-gcc && @@ -146,15 +151,16 @@ mkdir -p "${TOOLS}"/gcc && mv "${TOOLS}"/lib/gcc/*/*/include "${TOOLS}"/gcc/include && mv "${TOOLS}"/lib/gcc/*/* "${TOOLS}"/gcc/lib && -mv "${TOOLS}/bin/gcc" "${TOOLS}/bin/rawgcc" && -"${ARCH}-gcc" "${SOURCES}"/toys/ccwrap.c -Os -s -o "${TOOLS}/bin/gcc" \ - -DGCC_UNWRAPPED_NAME='"rawgcc"' -DGIMME_AN_S && +mv "${TOOLS}/bin/${PROGRAM_PREFIX}gcc" "${TOOLS}/bin/${PROGRAM_PREFIX}rawgcc" && +"${FROM_ARCH}-gcc" "${SOURCES}"/toys/ccwrap.c -Os -s \ + -o "${TOOLS}/bin/${PROGRAM_PREFIX}gcc" -DGIMME_AN_S $STATIC_FLAGS \ + -DGCC_UNWRAPPED_NAME='"'"${PROGRAM_PREFIX}rawgcc"'"' && # Wrap C++ -mv "${TOOLS}/bin/g++" "${TOOLS}/bin/rawg++" && -ln "${TOOLS}/bin/gcc" "${TOOLS}/bin/g++" && -rm "${TOOLS}/bin/c++" && -ln -s g++ "${TOOLS}/bin/c++" +mv "${TOOLS}/bin/${PROGRAM_PREFIX}g++" "${TOOLS}/bin/${PROGRAM_PREFIX}rawg++" && +ln "${TOOLS}/bin/${PROGRAM_PREFIX}gcc" "${TOOLS}/bin/${PROGRAM_PREFIX}g++" && +rm "${TOOLS}/bin/${PROGRAM_PREFIX}c++" && +ln -s "${PROGRAM_PREFIX}g++" "${TOOLS}/bin/${PROGRAM_PREFIX}c++" cleanup "${TOOLS}"/{lib/gcc,gcc/lib/install-tools,bin/${ARCH}-unknown-*} diff -r 9282f84b31a1 -r db04bd3c11e0 sources/include.sh --- a/sources/include.sh Fri Apr 10 03:32:41 2009 -0500 +++ b/sources/include.sh Thu Apr 16 06:21:50 2009 -0500 @@ -97,10 +97,17 @@ [ -z "$CROSS_HOST" ] && export CROSS_HOST=`uname -m`-walrus-linux [ -z "$CROSS_TARGET" ] && export CROSS_TARGET=${ARCH}-unknown-linux + # Override these to perform a canadian cross in root-filesystem.sh + + [ -z "$FROM_ARCH" ] && FROM_ARCH="${ARCH}" + [ -z "$FROM_HOST" ] && FROM_HOST="${FROM_ARCH}"-walrus-linux + # Setup directories and add the cross compiler to the start of the path. [ -z "$NATIVE_ROOT" ] && export NATIVE_ROOT="${BUILD}/root-filesystem-$ARCH" export PATH="${BUILD}/cross-compiler-$ARCH/bin:$PATH" + [ "$FROM_ARCH" != "$ARCH" ] && + PATH="${BUILD}/cross-compiler-${FROM_ARCH}/bin:$PATH" if [ ! -z "${NATIVE_TOOLSDIR}" ] then