[CMake] Use host compiler to build unittests in standalone mode

llvm-svn: 201672
diff --git a/compiler-rt/cmake/Modules/CompilerRTLink.cmake b/compiler-rt/cmake/Modules/CompilerRTLink.cmake
index 85030a7..0f0e53a 100644
--- a/compiler-rt/cmake/Modules/CompilerRTLink.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTLink.cmake
@@ -1,14 +1,18 @@
 include(LLVMParseArguments)
 
-# Link a shared library with just-built Clang.
+# Link a shared library with COMPILER_RT_TEST_COMPILER.
 # clang_link_shared(<output.so>
 #                   OBJECTS <list of input objects>
 #                   LINKFLAGS <list of link flags>
 #                   DEPS <list of dependencies>)
 macro(clang_link_shared so_file)
   parse_arguments(SOURCE "OBJECTS;LINKFLAGS;DEPS" "" ${ARGN})
+  if(NOT COMPILER_RT_STANDALONE_BUILD)
+    list(APPEND SOURCE_DEPS clang)
+  endif()
   add_custom_command(
     OUTPUT ${so_file}
-    COMMAND clang -o "${so_file}" -shared ${SOURCE_LINKFLAGS} ${SOURCE_OBJECTS}
-    DEPENDS clang ${SOURCE_DEPS})
+    COMMAND ${COMPILER_RT_TEST_COMPILER} -o "${so_file}" -shared
+            ${SOURCE_LINKFLAGS} ${SOURCE_OBJECTS}
+    DEPENDS ${SOURCE_DEPS})
 endmacro()