1From 3bc3328f89915cde33c26cec91a57b79109420f0 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 19 May 2016 23:11:45 -0700
4Subject: [PATCH] compiler-rt: Simplify cross-compilation. Don't use
5 native-compiled llvm-config.
6
7    Note: AddLLVM.cmake does not expose the LLVM source directory.
8    So if you want to run the test suite, you need to either:
9
10    1) set LLVM_MAIN_SRC_DIR explicitly (to find lit.py)
11    2) change AddLLVM.cmake to point to an installed 'lit'.
12    3) add_subdirectory(compiler-rt/test) from clang instead of compiler-rt.
13
14https://us.codeaurora.org/patches/quic/llvm/50683/compiler-rt-cross-compilation.patch
15
16Signed-off-by: Greg Fitzgerald <gregf@codeaurora.org>
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18---
19 compiler-rt/CMakeLists.txt | 11 ++++++++++-
20 1 file changed, 10 insertions(+), 1 deletion(-)
21
22diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
23index 3a41aa43e406..3bbfbca1f645 100644
24--- a/compiler-rt/CMakeLists.txt
25+++ b/compiler-rt/CMakeLists.txt
26@@ -67,7 +67,16 @@ set(COMPILER_RT_BAREMETAL_BUILD OFF CACHE BOOL
27   "Build for a bare-metal target.")
28
29 if (COMPILER_RT_STANDALONE_BUILD)
30-  load_llvm_config()
31+  find_package(LLVM REQUIRED)
32+  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
33+
34+  # Variables that AddLLVM.cmake depends on (included by AddCompilerRT)
35+  set(LLVM_TOOLS_BINARY_DIR "${LLVM_INSTALL_PREFIX}/bin")
36+  set(LLVM_LIBRARY_DIR "${LLVM_INSTALL_PREFIX}/lib")
37+
38+  set(LLVM_LIBRARY_OUTPUT_INTDIR
39+    ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
40+
41   if (TARGET intrinsics_gen)
42     # Loading the llvm config causes this target to be imported so place it
43     # under the appropriate folder in an IDE.
44