$ svn merge -c 83029 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk --- Merging r83029 into '.': U build_gcc llvm-svn: 84045
diff --git a/llvm-gcc-4.2/build_gcc b/llvm-gcc-4.2/build_gcc index 0765359..f26f45a 100755 --- a/llvm-gcc-4.2/build_gcc +++ b/llvm-gcc-4.2/build_gcc
@@ -256,6 +256,17 @@ fi # LLVM LOCAL end +# If the user has set CC or CXX, respect their wishes. If not, +# compile with LLVM-GCC/LLVM-G++ if available; if LLVM is not +# available, fall back to usual GCC/G++ default. +savedPATH=$PATH ; PATH="$PATH:/Developer/usr/bin" +XTMPCC=$(which llvm-gcc) +if [ x$CC = x -a x$XTMPCC != x ] ; then export CC=$XTMPCC forcedCC=1 ; fi +XTMPCC=$(which llvm-g++) +if [ x$CXX = x -a x$XTMPCC != x ] ; then export CXX=$XTMPCC forcedCXX=1 ; fi +PATH=$savedPATH +unset XTMPCC savedPATH + # Build the native GCC. Do this even if the user didn't ask for it # because it'll be needed for the bootstrap. mkdir -p $DIR/obj-$BUILD-$BUILD $DIR/dst-$BUILD-$BUILD || exit 1 @@ -265,6 +276,7 @@ $NON_ARM_CONFIGFLAGS \ --host=$BUILD-apple-darwin$DARWIN_VERS --target=$BUILD-apple-darwin$DARWIN_VERS || exit 1 fi + # Unset RC_DEBUG_OPTIONS because it causes the bootstrap to fail. # Also keep unset for cross compilers so that the cross built libraries are # comparable to the native built libraries. @@ -274,6 +286,11 @@ make $MAKEFLAGS DESTDIR=$DIR/dst-$BUILD-$BUILD install-gcc install-target \ CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1 +# Now that we've built a native compiler, un-kludge these so that +# subsequent cross-hosted compilers can be found normally. +if [ x$forcedCC != x ] ; then unset CC forcedCC ; fi +if [ x$forcedCXX != x ] ; then unset CXX forcedCXX ; fi + # Add the compiler we just built to the path, giving it appropriate names. # LLVM LOCAL begin Support for non /usr $DEST_ROOT D=$DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin