Merge "Use HOST_CFLAGS more consistently"
diff --git a/build/tools/build-gcc.sh b/build/tools/build-gcc.sh
index 629a818..d73d479 100755
--- a/build/tools/build-gcc.sh
+++ b/build/tools/build-gcc.sh
@@ -168,8 +168,10 @@
 
 set_toolchain_ndk $NDK_DIR $TOOLCHAIN
 
-dump "Using C compiler: $CC"
-dump "Using C++ compiler: $CXX"
+if [ "$MINGW" != "yes" ] ; then
+    dump "Using C compiler: $CC"
+    dump "Using C++ compiler: $CXX"
+fi
 
 rm -rf $BUILD_OUT
 mkdir -p $BUILD_OUT
@@ -222,7 +224,7 @@
 export ABI=$HOST_GMP_ABI
 # -Wno-error is needed because our gdb-6.6 sources use -Werror by default
 # and fail to build with recent GCC versions.
-export CFLAGS="-Wno-error"
+export CFLAGS=$HOST_CFLAGS" -O2 -s -Wno-error"
 
 # This extra flag is used to slightly speed up the build
 EXTRA_CONFIG_FLAGS="--disable-bootstrap"
diff --git a/build/tools/build-host-awk.sh b/build/tools/build-host-awk.sh
index 4a79b33..0fe10a1 100755
--- a/build/tools/build-host-awk.sh
+++ b/build/tools/build-host-awk.sh
@@ -64,6 +64,7 @@
 prepare_mingw_toolchain $BUILD_DIR
 log "Building $HOST_TAG awk"
 export HOST_CC="$CC" &&
+export CFLAGS=$HOST_CFLAGS" -O2 -s" &&
 run $GNUMAKE \
     -C "$AWK_SRCDIR" \
     -j $NUM_JOBS \
diff --git a/build/tools/build-llvm.sh b/build/tools/build-llvm.sh
index c27f8f6..2da41ea 100755
--- a/build/tools/build-llvm.sh
+++ b/build/tools/build-llvm.sh
@@ -136,15 +136,14 @@
 
 TOOLCHAIN_BUILD_PREFIX=$BUILD_OUT/prefix
 
-CFLAGS="$CFLAGS -I$TOOLCHAIN_BUILD_PREFIX/include"
+CFLAGS="$HOST_CFLAGS $CFLAGS -I$TOOLCHAIN_BUILD_PREFIX/include"
 CXXFLAGS="$CXXFLAGS -I$TOOLCHAIN_BUILD_PREFIX/include"  # polly doesn't look at CFLAGS !
 LDFLAGS="$LDFLAGS -L$TOOLCHAIN_BUILD_PREFIX/lib"
 export CC CXX CFLAGS CXXFLAGS LDFLAGS REQUIRES_RTTI=1
 
 EXTRA_CONFIG_FLAGS=
-if [ "$POLLY" != "yes" ]; then
-    rm -f $SRC_DIR/$TOOLCHAIN/llvm/tools/polly
-else
+rm -rf $SRC_DIR/$TOOLCHAIN/llvm/tools/polly
+if [ "$POLLY" = "yes" ]; then
     # crate symbolic link
     ln -s ../../polly $SRC_DIR/$TOOLCHAIN/llvm/tools
 
@@ -215,11 +214,25 @@
 run make -j$NUM_JOBS
 fail_panic "Couldn't compile llvm toolchain"
 
-# run the regression test
-dump "Running  : llvm toolchain regression test"
-cd $LLVM_BUILD_OUT
-run make check-all
-#fail_panic "Couldn't pass all regression test"
+if [ "$MINGW" != "yes" ] ; then
+    # run the regression test
+    dump "Running  : llvm toolchain regression test"
+    cd $LLVM_BUILD_OUT
+    run make check-all
+    if [ $? != 0 ] ; then
+        dump "ERROR: Couldn't pass all llvm regression test"
+        #exit 1
+    fi
+    if [ "$POLLY" = "yes" ]; then
+        dump "Running  : polly toolchain regression test"
+        cd $LLVM_BUILD_OUT
+        run make polly-test -C tools/polly/test
+        if [ $? != 0 ] ; then
+            dump "ERROR: Couldn't pass all polly regression test"
+            #exit 1
+        fi
+    fi
+fi
 
 # install the toolchain to its final location
 dump "Install  : llvm toolchain binaries."
diff --git a/build/tools/build-ndk-stack.sh b/build/tools/build-ndk-stack.sh
index fb31ee9..b4c0669 100755
--- a/build/tools/build-ndk-stack.sh
+++ b/build/tools/build-ndk-stack.sh
@@ -86,6 +86,7 @@
 SRCDIR=$ANDROID_NDK_ROOT/sources/host-tools/ndk-stack
 
 # Let's roll
+export CFLAGS=$HOST_CFLAGS" -O2 -s"
 run $GNUMAKE -C $SRCDIR -f $SRCDIR/GNUMakefile \
     -B -j$NUM_JOBS \
     PROGNAME="$OUT" \
diff --git a/build/tools/prebuilt-common.sh b/build/tools/prebuilt-common.sh
index 3c53f3a..b882ef7 100644
--- a/build/tools/prebuilt-common.sh
+++ b/build/tools/prebuilt-common.sh
@@ -750,8 +750,8 @@
     STRIP=${STRIP:-strip}
     case $HOST_TAG in
         darwin-*)
-            if check_darwin_sdk /Developer/SDKs/MacOSX10.5.sdk 10.5; then
-                log "Generating Leopard-compatible binaries!"
+            if check_darwin_sdk /Developer/SDKs/MacOSX10.6.sdk 10.6; then
+                log "Generating Snow Leopard-compatible binaries!"
             else
                 local version=`sw_vers -productVersion`
                 log "Generating $version-compatible binaries!"