crossgcc: Update to clang 4.0

Drop Edward's cfe patch because it has been implemented by
upstream clang differently. Instead of

 $ clang --print-librt-file-name

the right way to get ahold of the compiler-rt builtin library is

 $ clang -rtlib=compiler-rt --print-libgcc-file-name

Change-Id: I8aac5256da5bfb6f7bebeff0959f16b53867c581
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-on: https://review.coreboot.org/20274
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index c095d0e..f232e83 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -47,7 +47,7 @@
 PYTHON_VERSION=3.5.1
 EXPAT_VERSION=2.1.1
 # CLANG version number
-CLANG_VERSION=3.9.1
+CLANG_VERSION=4.0.0
 MAKE_VERSION=4.2.1
 CMAKE_VERSION=3.9.0-rc3
 
@@ -868,8 +868,8 @@
 		;;
 	CLANG|clang)
 		NAME=clang
-		PACKAGES="LLVM CFE CRT CTE"
-		CMAKE=$(searchtool cmake "cmake") || exit $?
+		PACKAGES="CMAKE LLVM CFE CRT CTE"
+		CMAKE=${DESTDIR}${TARGETDIR}/bin/cmake
 		;;
 	IASL|iasl)
 		NAME="IASL ACPI compiler"
diff --git a/util/crossgcc/patches/cfe-3.9.1.src_frontend.patch b/util/crossgcc/patches/cfe-3.9.1.src_frontend.patch
deleted file mode 100644
index 3b8e6b7..0000000
--- a/util/crossgcc/patches/cfe-3.9.1.src_frontend.patch
+++ /dev/null
@@ -1,79 +0,0 @@
-Frontend driver patch from Edward O'Callaghan
-
-https://llvm.org/bugs/show_bug.cgi?id=21538
-
-Index: include/clang/Driver/Driver.h
-===================================================================
---- cfe-3.7.1.src/include/clang/Driver/Driver.h	(revision 211898)
-+++ cfe-3.8.0.src/include/clang/Driver/Driver.h	(working copy)
-@@ -357,6 +357,14 @@
-   // FIXME: This should be in CompilationInfo.
-   std::string GetFilePath(const char *Name, const ToolChain &TC) const;
- 
-+  /// GetCompilerRTPath - Find Compiler-RT library path
-+  ///
-+  /// \param TC - The provided tool chain for additional information on
-+  /// directories to search.
-+  //
-+  // FIXME: This should be in CompilationInfo.
-+  std::string GetCompilerRTPath(const ToolChain &TC) const;
-+
-   /// GetProgramPath - Lookup \p Name in the list of program search paths.
-   ///
-   /// \param TC - The provided tool chain for additional information on
-Index: include/clang/Driver/Options.td
-===================================================================
---- cfe-3.7.1.src/include/clang/Driver/Options.td	(revision 211898)
-+++ cfe-3.8.0.src/include/clang/Driver/Options.td	(working copy)
-@@ -1669,6 +1669,8 @@
-   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
- def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-   HelpText<"Print the library path for \"libgcc.a\"">;
-+def print_librt_file_name : Flag<["-", "--"], "print-librt-file-name">,
-+  HelpText<"Print the library path for \"libclang_rt.builtins-ARCH.a\"">;
- def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
- def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
- def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">;
-Index: lib/Driver/Driver.cpp
-===================================================================
---- cfe-3.7.1.src/lib/Driver/Driver.cpp	(revision 211898)
-+++ cfe-3.8.0.src/lib/Driver/Driver.cpp	(working copy)
-@@ -910,6 +910,11 @@
-     return false;
-   }
- 
-+  if (C.getArgs().hasArg(options::OPT_print_librt_file_name)) {
-+    llvm::outs() << GetCompilerRTPath(TC) << "\n";
-+    return false;
-+  }
-+
-   if (C.getArgs().hasArg(options::OPT_print_multi_lib)) {
-     for (const Multilib &Multilib : TC.getMultilibs())
-       llvm::outs() << Multilib << "\n";
-@@ -2153,6 +2158,26 @@
-   return false;
- }
- 
-+std::string Driver::GetCompilerRTPath(const ToolChain &TC) const {
-+  // The runtimes are located in the OS-specific resource directory.
-+  SmallString<128> Res(TC.getDriver().ResourceDir);
-+  const llvm::Triple &Triple = TC.getTriple();
-+
-+  // TC.getOS() yield "freebsd10.0" whereas "freebsd" is expected.
-+  StringRef OSLibName = (Triple.getOS() == llvm::Triple::FreeBSD) ?
-+    "freebsd" : TC.getOS();
-+  llvm::sys::path::append(Res, "lib", OSLibName);
-+
-+  StringRef archName = TC.getArchName();
-+  // Until ARM libraries are build separately, we have them all in one library
-+  if (TC.getArch() == llvm::Triple::arm ||
-+      TC.getArch() == llvm::Triple::armeb)
-+    archName = "arm";
-+
-+  llvm::sys::path::append(Res, Twine("libclang_rt.builtins-") + archName + ".a");
-+  return Res.str();
-+}
-+
- std::string Driver::GetProgramPath(const char *Name,
-                                    const ToolChain &TC) const {
-   SmallVector<std::string, 2> TargetSpecificExecutables;
diff --git a/util/crossgcc/sum/cfe-3.9.1.src.tar.xz.cksum b/util/crossgcc/sum/cfe-3.9.1.src.tar.xz.cksum
deleted file mode 100644
index 69cb0d2..0000000
--- a/util/crossgcc/sum/cfe-3.9.1.src.tar.xz.cksum
+++ /dev/null
@@ -1 +0,0 @@
-95e4be54b70f32cf98a8de36821ea5495b84add8  tarballs/cfe-3.9.1.src.tar.xz
diff --git a/util/crossgcc/sum/cfe-4.0.0.src.tar.xz.cksum b/util/crossgcc/sum/cfe-4.0.0.src.tar.xz.cksum
new file mode 100644
index 0000000..00a5596
--- /dev/null
+++ b/util/crossgcc/sum/cfe-4.0.0.src.tar.xz.cksum
@@ -0,0 +1 @@
+e2762800c93d9335781ea6a45af3f80845542ef5  tarballs/cfe-4.0.0.src.tar.xz
diff --git a/util/crossgcc/sum/clang-tools-extra-3.9.1.src.tar.xz.cksum b/util/crossgcc/sum/clang-tools-extra-3.9.1.src.tar.xz.cksum
deleted file mode 100644
index 3ecdd5f..0000000
--- a/util/crossgcc/sum/clang-tools-extra-3.9.1.src.tar.xz.cksum
+++ /dev/null
@@ -1 +0,0 @@
-f24e5ceb226a72e781cefde4e30f2d7be09ea305  tarballs/clang-tools-extra-3.9.1.src.tar.xz
diff --git a/util/crossgcc/sum/clang-tools-extra-4.0.0.src.tar.xz.cksum b/util/crossgcc/sum/clang-tools-extra-4.0.0.src.tar.xz.cksum
new file mode 100644
index 0000000..dbf642c
--- /dev/null
+++ b/util/crossgcc/sum/clang-tools-extra-4.0.0.src.tar.xz.cksum
@@ -0,0 +1 @@
+bdb543c4bb87bd80fe65711114ca0a5c25329ae3  tarballs/clang-tools-extra-4.0.0.src.tar.xz
diff --git a/util/crossgcc/sum/compiler-rt-3.9.1.src.tar.xz.cksum b/util/crossgcc/sum/compiler-rt-3.9.1.src.tar.xz.cksum
deleted file mode 100644
index 5d2c1b7..0000000
--- a/util/crossgcc/sum/compiler-rt-3.9.1.src.tar.xz.cksum
+++ /dev/null
@@ -1 +0,0 @@
-938921d076e28943f5d5b653514f2ce36a88a55e  tarballs/compiler-rt-3.9.1.src.tar.xz
diff --git a/util/crossgcc/sum/compiler-rt-4.0.0.src.tar.xz.cksum b/util/crossgcc/sum/compiler-rt-4.0.0.src.tar.xz.cksum
new file mode 100644
index 0000000..95da514
--- /dev/null
+++ b/util/crossgcc/sum/compiler-rt-4.0.0.src.tar.xz.cksum
@@ -0,0 +1 @@
+a879b610e427ef3bba482bdc031ae371cabab81e  tarballs/compiler-rt-4.0.0.src.tar.xz
diff --git a/util/crossgcc/sum/llvm-3.9.1.src.tar.xz.cksum b/util/crossgcc/sum/llvm-3.9.1.src.tar.xz.cksum
deleted file mode 100644
index 59fd6e8..0000000
--- a/util/crossgcc/sum/llvm-3.9.1.src.tar.xz.cksum
+++ /dev/null
@@ -1 +0,0 @@
-ce801cf456b8dacd565ce8df8288b4d90e7317ff  tarballs/llvm-3.9.1.src.tar.xz
diff --git a/util/crossgcc/sum/llvm-4.0.0.src.tar.xz.cksum b/util/crossgcc/sum/llvm-4.0.0.src.tar.xz.cksum
new file mode 100644
index 0000000..410f95f
--- /dev/null
+++ b/util/crossgcc/sum/llvm-4.0.0.src.tar.xz.cksum
@@ -0,0 +1 @@
+aee4524e2407f9fe5afc6f70c753180b907011d0  tarballs/llvm-4.0.0.src.tar.xz