view native-compiler.sh @ 1532:a2e491cd0800

Fix source/target confusion that bites Fedora host = target builds. The gcc build exports an LD_LIBRARY_PATH full of target libraries and then calls /bin/sh in the configure stage. If you configure before building, this doesn't cause a problem because the libraries aren't there yet, but c++ has dependencies that trigger a C build before running configuration even if you reorder the steps. On ubuntu this doesn't cause a problem because /bin/sh doesn't link against anything in this LD_LIBRARY PATH, and when building a different architecture the foreign binaries are ignored by the dynamic linker. But on Fedora when host == target /bin/sh links against libgcc_s.so.1 which is in LD_LIBRARY_PATH linked against libc.so.0 which isn't installed on the host, and the attempt to run the shell dies saying it can't find uClibc. The fix is to override the make variable SHELL = sh so it calls ash out of build/host.
author Rob Landley <rob@landley.net>
date Thu, 16 Aug 2012 21:59:27 -0500
parents b74d36876c0a
children 35b8949e9d9c
line wrap: on
line source

#!/bin/bash

# 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.

# The new compiler is built --with-shared, with thread support, has uClibc++
# installed, and is linked against uClibc (see BUILD_STATIC in config).

source sources/include.sh && load_target "$1" || exit 1
check_for_base_arch || exit 0

check_prerequisite "${ARCH}-cc"

[ -z "$HOST_ARCH" ] && HOST_ARCH="$ARCH" || check_prerequisite "${HOST_ARCH}-cc"

mkdir -p "$STAGE_DIR/bin" || dienow

# Build C Library

build_section linux-headers
build_section uClibc

# Build binutils, gcc, and ccwrap

build_section binutils
build_section gcc
build_section ccwrap

# Tell future packages to link against the libraries in the new compiler,
# rather than the ones in the simple compiler.

export "$(echo $ARCH | sed 's/-/_/g')"_CCWRAP_TOPDIR="$STAGE_DIR"

# Add C++ standard library

[ -z "$NO_CPLUSPLUS" ] && build_section uClibc++

# For a native compiler, build make, bash, and distcc.  (Yes, this is an old
# version of Bash.  It's intentional.)

if [ -z "$TOOLCHAIN_PREFIX" ]
then
  build_section make
  build_section bash
  build_section distcc
fi

# Delete some unneeded files

[ -z "$SKIP_STRIP" ] &&
  rm -rf "$STAGE_DIR"/{info,man,libexec/gcc/*/*/install-tools}

create_stage_tarball