Merge "crazy_linker: Fix IsSystemLibrary() implementation."
diff --git a/build/tools/build-gcc.sh b/build/tools/build-gcc.sh
index 241e0b9..174c0f0 100755
--- a/build/tools/build-gcc.sh
+++ b/build/tools/build-gcc.sh
@@ -538,6 +538,10 @@
 run rm -rf $TOOLCHAIN_PATH/$ABI_CONFIGURE_TARGET/lib/*/libiberty.a
 run rm -rf $TOOLCHAIN_PATH/$ABI_CONFIGURE_TARGET/lib/*/*/libiberty.a
 find $TOOLCHAIN_PATH -name "*.la" -exec rm -f {} \;
+# Remove host install in cross compilation
+if [ "$ABI_CONFIGURE_HOST" != "$ABI_CONFIGURE_TARGET" ]; then
+    run rm -rf "$TOOLCHAIN_PATH/$ABI_CONFIGURE_HOST"
+fi
 
 # Remove libstdc++ for now (will add it differently later)
 # We had to build it to get libsupc++ which we keep.
diff --git a/build/tools/toolchain-patches/mclinker/0001-Fixed-darwin-ld.mcld-GNU-m-emulation-fail.patch b/build/tools/toolchain-patches/mclinker/0001-Fixed-darwin-ld.mcld-GNU-m-emulation-fail.patch
index b062599..23c2423 100644
--- a/build/tools/toolchain-patches/mclinker/0001-Fixed-darwin-ld.mcld-GNU-m-emulation-fail.patch
+++ b/build/tools/toolchain-patches/mclinker/0001-Fixed-darwin-ld.mcld-GNU-m-emulation-fail.patch
@@ -1,21 +1,21 @@
-From db1cf96ebd1c8b8749b4c5b4461aac5af98558ea Mon Sep 17 00:00:00 2001
+From 453d37f5244ab5763b9406a86a13e484354b4a4c Mon Sep 17 00:00:00 2001
 From: Andrew Hsieh <andrewhsieh@google.com>
-Date: Tue, 14 Jan 2014 14:45:14 -0800
+Date: Mon, 14 Apr 2014 11:14:14 -0700
 Subject: [PATCH 1/3] Fixed darwin ld.mcld GNU -m emulation fail
 
-Change-Id: I95fb07db7b58db94328f24a46f8e6b292c38dd21
+Change-Id: Ibdddad13aca0d2986755d7390ca6aa9b364e3528
 ---
  tools/lite/lib/TripleOptions.cpp | 4 ++--
  tools/mcld/main.cpp              | 4 ++--
  2 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/tools/lite/lib/TripleOptions.cpp b/tools/lite/lib/TripleOptions.cpp
-index 20ab3b1..3a20e2b 100644
+index bf37b01..f360c27 100644
 --- a/tools/lite/lib/TripleOptions.cpp
 +++ b/tools/lite/lib/TripleOptions.cpp
-@@ -85,12 +85,12 @@ ParseEmulation(llvm::Triple& pTriple, const std::string& pEmulation)
- {
+@@ -86,12 +86,12 @@ ParseEmulation(llvm::Triple& pTriple, const std::string& pEmulation)
    llvm::Triple triple = llvm::StringSwitch<llvm::Triple>(pEmulation)
+     .Case("aarch64linux",      llvm::Triple("aarch64", "", "linux", "gnu"))
      .Case("armelf_linux_eabi", llvm::Triple("arm", "", "linux", "gnueabi"))
 -    .Case("elf_i386",          llvm::Triple("i386", "", "", "gnu"))
 +    .Case("elf_i386",          llvm::Triple("i386", "", "linux", "gnu"))
@@ -29,12 +29,12 @@
  
    if (triple.getArch()        == llvm::Triple::UnknownArch &&
 diff --git a/tools/mcld/main.cpp b/tools/mcld/main.cpp
-index dcb8140..854aaa9 100644
+index 97da737..6a28c91 100644
 --- a/tools/mcld/main.cpp
 +++ b/tools/mcld/main.cpp
-@@ -1037,12 +1037,12 @@ static Triple ParseEmulation(const std::string& pEmulation)
- {
+@@ -1043,12 +1043,12 @@ static Triple ParseEmulation(const std::string& pEmulation)
    Triple result = StringSwitch<Triple>(pEmulation)
+     .Case("aarch64linux",      Triple("aarch64", "", "linux", "gnu"))
      .Case("armelf_linux_eabi", Triple("arm", "", "linux", "gnueabi"))
 -    .Case("elf_i386",          Triple("i386", "", "", "gnu"))
 +    .Case("elf_i386",          Triple("i386", "", "linux", "gnu"))
@@ -48,5 +48,5 @@
  
    if (result.getArch()        == Triple::UnknownArch &&
 -- 
-1.8.5.2
+1.9.1.423.g4596e3a
 
diff --git a/build/tools/toolchain-patches/mclinker/0002-Compile-only-lite-mclinker.patch b/build/tools/toolchain-patches/mclinker/0002-Compile-only-lite-mclinker.patch
index b156e39..ebac095 100644
--- a/build/tools/toolchain-patches/mclinker/0002-Compile-only-lite-mclinker.patch
+++ b/build/tools/toolchain-patches/mclinker/0002-Compile-only-lite-mclinker.patch
@@ -1,9 +1,9 @@
-From c2c44f326a82ffab6208edf08f7e4c91610a4607 Mon Sep 17 00:00:00 2001
+From 4c86cbb6f8108c06c4ec57be120fc1fcb050866a Mon Sep 17 00:00:00 2001
 From: Andrew Hsieh <andrewhsieh@google.com>
-Date: Tue, 14 Jan 2014 14:45:54 -0800
+Date: Mon, 14 Apr 2014 11:14:41 -0700
 Subject: [PATCH 2/3] Compile only "lite" mclinker
 
-Change-Id: I91ccf3a2280bbb0cf56957da1552e7e59052a4b8
+Change-Id: I20be83e0418af331ea752e2c1dfe5b83aa53958c
 ---
  tools/Makefile.am | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
@@ -18,5 +18,5 @@
 -SUBDIRS = lite mcld
 +SUBDIRS = lite # mcld
 -- 
-1.8.5.2
+1.9.1.423.g4596e3a
 
diff --git a/build/tools/toolchain-patches/mclinker/0003-Allow-multiple-no-warn-mismatch.patch b/build/tools/toolchain-patches/mclinker/0003-Allow-multiple-no-warn-mismatch.patch
index 470ca1f..8cee0f2 100644
--- a/build/tools/toolchain-patches/mclinker/0003-Allow-multiple-no-warn-mismatch.patch
+++ b/build/tools/toolchain-patches/mclinker/0003-Allow-multiple-no-warn-mismatch.patch
@@ -1,19 +1,19 @@
-From c3f91ccde6e77a4349c7fa0a67a95eebc0151a5c Mon Sep 17 00:00:00 2001
+From 1f7116320843169cc9ea4b4a65a5e4c66db1bd10 Mon Sep 17 00:00:00 2001
 From: Andrew Hsieh <andrewhsieh@google.com>
-Date: Tue, 14 Jan 2014 14:46:16 -0800
+Date: Mon, 14 Apr 2014 11:15:08 -0700
 Subject: [PATCH 3/3] Allow multiple --no-warn-mismatch
 
-Change-Id: I28eba502b7ff63bb5bb994eabe63cf75458ee4b4
+Change-Id: I72ab8f2aa28d94e53d429e9d3e9c6fae91518082
 ---
  tools/lite/lib/OutputFormatOptions.cpp | 1 +
  tools/mcld/main.cpp                    | 1 +
  2 files changed, 2 insertions(+)
 
 diff --git a/tools/lite/lib/OutputFormatOptions.cpp b/tools/lite/lib/OutputFormatOptions.cpp
-index cfc6c04..f2cfb87 100644
+index 40ac2dc..902fac1 100644
 --- a/tools/lite/lib/OutputFormatOptions.cpp
 +++ b/tools/lite/lib/OutputFormatOptions.cpp
-@@ -148,6 +148,7 @@ llvm::cl::opt<mcld::GeneralOptions::HashStyle> ArgHashStyle("hash-style",
+@@ -149,6 +149,7 @@ llvm::cl::opt<mcld::GeneralOptions::HashStyle> ArgHashStyle("hash-style",
         clEnumValEnd));
  
  llvm::cl::opt<bool> ArgNoWarnMismatch("no-warn-mismatch",
@@ -22,10 +22,10 @@
    llvm::cl::init(false));
  
 diff --git a/tools/mcld/main.cpp b/tools/mcld/main.cpp
-index 854aaa9..38e2531 100644
+index 6a28c91..b8795dd 100644
 --- a/tools/mcld/main.cpp
 +++ b/tools/mcld/main.cpp
-@@ -731,6 +731,7 @@ ArgARMCompatibility("p",
+@@ -734,6 +734,7 @@ ArgARMCompatibility("p",
  
  static cl::opt<bool>
  ArgNoWarnMismatch("no-warn-mismatch",
@@ -34,5 +34,5 @@
                    cl::init(false));
  
 -- 
-1.8.5.2
+1.9.1.423.g4596e3a