Merge "Add LLVM/CLANG-3.2 toolchain"
diff --git a/build/tools/build-llvm.sh b/build/tools/build-llvm.sh
index 98ae68a..10c8095 100755
--- a/build/tools/build-llvm.sh
+++ b/build/tools/build-llvm.sh
@@ -146,6 +146,8 @@
 
 TOOLCHAIN_BUILD_PREFIX=$BUILD_OUT/prefix
 
+ARCH=$HOST_ARCH
+
 # Note that the following 2 flags only apply for BUILD_CC in canadian cross build
 CFLAGS_FOR_BUILD="-O2 -I$TOOLCHAIN_BUILD_PREFIX/include"
 LDFLAGS_FOR_BUILD="-L$TOOLCHAIN_BUILD_PREFIX/lib"
@@ -153,7 +155,7 @@
 CFLAGS="$CFLAGS $CFLAGS_FOR_BUILD $HOST_CFLAGS"
 CXXFLAGS="$CXXFLAGS $CFLAGS_FOR_BUILD $HOST_CFLAGS"  # polly doesn't look at CFLAGS !
 LDFLAGS="$LDFLAGS $LDFLAGS_FOR_BUILD $HOST_LDFLAGS"
-export CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_FOR_BUILD LDFLAGS_FOR_BUILD REQUIRES_RTTI=1
+export CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_FOR_BUILD LDFLAGS_FOR_BUILD REQUIRES_RTTI=1 ARCH
 
 if [ "$DARWIN" = "yes" ]; then
     # To stop /usr/bin/install -s calls strip on darwin binary
@@ -215,6 +217,12 @@
     fail_panic "Couldn't install cloog to $TOOLCHAIN_BUILD_PREFIX"
 
     EXTRA_CONFIG_FLAGS="--with-cloog=$TOOLCHAIN_BUILD_PREFIX --with-isl=$TOOLCHAIN_BUILD_PREFIX"
+
+    # Allow text relocs when linking LLVMPolly.dylib against statically linked libgmp.a
+    if [ "$HOST_TAG32" = "darwin-x86" -o "$DARWIN" = "yes" ]; then   # -a "$HOST_ARCH" = "x86"
+        LDFLAGS="$LDFLAGS -read_only_relocs suppress"
+        export LDFLAGS
+    fi
 fi # POLLY = yes
 
 # configure the toolchain