Update compiler-rt aosp/master for 3.5 (r209699) rebase.

Change-Id: I158a30186f0faea2e2400e9dfdd878db2eb40e90
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index fd117ac..69c30e3 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -1,4 +1,5 @@
 include(AddLLVM)
+include(ExternalProject)
 include(LLVMParseArguments)
 include(CompilerRTUtils)
 
@@ -13,7 +14,7 @@
     parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN})
     add_library(${name}.${arch} OBJECT ${LIB_SOURCES})
     set_target_compile_flags(${name}.${arch}
-      ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
+      ${CMAKE_CXX_FLAGS} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
     set_property(TARGET ${name}.${arch} APPEND PROPERTY
       COMPILE_DEFINITIONS ${LIB_DEFS})
   else()
@@ -37,34 +38,41 @@
     COMPILE_DEFINITIONS ${LIB_DEFS})
 endmacro()
 
-# Adds static runtime for a given architecture and puts it in the proper
-# directory in the build and install trees.
-# add_compiler_rt_static_runtime(<name> <arch>
-#                                SOURCES <source files>
-#                                CFLAGS <compile flags>
-#                                DEFS <compile definitions>)
-macro(add_compiler_rt_static_runtime name arch)
+# Adds static or shared runtime for a given architecture and puts it in the
+# proper directory in the build and install trees.
+# add_compiler_rt_runtime(<name> <arch> {STATIC,SHARED}
+#                         SOURCES <source files>
+#                         CFLAGS <compile flags>
+#                         DEFS <compile definitions>)
+macro(add_compiler_rt_runtime name arch type)
   if(CAN_TARGET_${arch})
-    parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN})
-    add_library(${name} STATIC ${LIB_SOURCES})
+    parse_arguments(LIB "SOURCES;CFLAGS;DEFS;OUTPUT_NAME" "" ${ARGN})
+    add_library(${name} ${type} ${LIB_SOURCES})
     # Setup compile flags and definitions.
     set_target_compile_flags(${name}
       ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
+    set_target_link_flags(${name}
+      ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
     set_property(TARGET ${name} APPEND PROPERTY
       COMPILE_DEFINITIONS ${LIB_DEFS})
     # Setup correct output directory in the build tree.
     set_target_properties(${name} PROPERTIES
-      ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+      ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+      LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+    if (LIB_OUTPUT_NAME)
+      set_target_properties(${name} PROPERTIES
+        OUTPUT_NAME ${LIB_OUTPUT_NAME})
+    endif()
     # Add installation command.
     install(TARGETS ${name}
-      ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
-    add_dependencies(compiler-rt ${name})
+      ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
+      LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
   else()
     message(FATAL_ERROR "Archtecture ${arch} can't be targeted")
   endif()
 endmacro()
 
-# Same as add_compiler_rt_static_runtime, but creates a universal library
+# Same as add_compiler_rt_runtime(... STATIC), but creates a universal library
 # for several architectures.
 # add_compiler_rt_osx_static_runtime(<name> ARCH <architectures>
 #                                    SOURCES <source files>
@@ -81,7 +89,6 @@
     ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
   install(TARGETS ${name}
     ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
-  add_dependencies(compiler-rt ${name})
 endmacro()
 
 # Adds dynamic runtime library on osx/iossim, which supports multiple
@@ -104,20 +111,19 @@
     LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
   install(TARGETS ${name}
     LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
-  add_dependencies(compiler-rt ${name})
 endmacro()
 
 # Unittests support.
 set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
 set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc)
-set(COMPILER_RT_GTEST_INCLUDE_CFLAGS
+set(COMPILER_RT_GTEST_CFLAGS
   -DGTEST_NO_LLVM_RAW_OSTREAM=1
   -I${COMPILER_RT_GTEST_PATH}/include
   -I${COMPILER_RT_GTEST_PATH}
 )
 
-# Use Clang to link objects into a single executable with just-built
-# Clang, using specific link flags. Make executable a part of provided
+# Link objects into a single executable with COMPILER_RT_TEST_COMPILER,
+# using specified link flags. Make executable a part of provided
 # test_suite.
 # add_compiler_rt_test(<test_suite> <test_name>
 #                      OBJECTS <object files>
@@ -126,20 +132,99 @@
 macro(add_compiler_rt_test test_suite test_name)
   parse_arguments(TEST "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN})
   set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${test_name}")
+  # Use host compiler in a standalone build, and just-built Clang otherwise.
+  if(NOT COMPILER_RT_STANDALONE_BUILD)
+    list(APPEND TEST_DEPS clang)
+  endif()
+  # If we're not on MSVC, include the linker flags from CMAKE but override them
+  # with the provided link flags. This ensures that flags which are required to
+  # link programs at all are included, but the changes needed for the test
+  # trump. With MSVC we can't do that because CMake is set up to run link.exe
+  # when linking, not the compiler. Here, we hack it to use the compiler
+  # because we want to use -fsanitize flags.
+  if(NOT MSVC)
+    set(TEST_LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TEST_LINK_FLAGS}")
+    separate_arguments(TEST_LINK_FLAGS)
+  endif()
   add_custom_target(${test_name}
-    COMMAND clang ${TEST_OBJECTS} -o "${output_bin}"
+    # MSVS CL doesn't allow a space between -Fe and the output file name.
+    COMMAND ${COMPILER_RT_TEST_COMPILER} ${TEST_OBJECTS}
+            ${COMPILER_RT_TEST_COMPILER_EXE}"${output_bin}"
             ${TEST_LINK_FLAGS}
-    DEPENDS clang ${TEST_DEPS})
+    DEPENDS ${TEST_DEPS})
   # Make the test suite depend on the binary.
   add_dependencies(${test_suite} ${test_name})
 endmacro()
 
 macro(add_compiler_rt_resource_file target_name file_name)
   set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}")
-  set(dst_file "${CLANG_RESOURCE_DIR}/${file_name}")
-  add_custom_target(${target_name}
+  set(dst_file "${COMPILER_RT_OUTPUT_DIR}/${file_name}")
+  add_custom_command(OUTPUT ${dst_file}
+    DEPENDS ${src_file}
     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file}
-    DEPENDS ${file_name})
+    COMMENT "Copying ${file_name}...")
+  add_custom_target(${target_name} DEPENDS ${dst_file})
   # Install in Clang resource directory.
-  install(FILES ${file_name} DESTINATION ${LIBCLANG_INSTALL_PATH})
+  install(FILES ${file_name} DESTINATION ${COMPILER_RT_INSTALL_PATH})
+endmacro()
+
+macro(add_compiler_rt_script name)
+  set(dst ${COMPILER_RT_EXEC_OUTPUT_DIR}/${name})
+  set(src ${CMAKE_CURRENT_SOURCE_DIR}/${name})
+  add_custom_command(OUTPUT ${dst}
+    DEPENDS ${src}
+    COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+    COMMENT "Copying ${name}...")
+  add_custom_target(${name} DEPENDS ${dst})
+  install(FILES ${dst}
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+    DESTINATION ${COMPILER_RT_INSTALL_PATH}/bin)
+endmacro(add_compiler_rt_script src name)
+
+# Builds custom version of libc++ and installs it in <prefix>.
+# Can be used to build sanitized versions of libc++ for running unit tests.
+# add_custom_libcxx(<name> <prefix>
+#                   DEPS <list of build deps>
+#                   CFLAGS <list of compile flags>)
+macro(add_custom_libcxx name prefix)
+  if(NOT COMPILER_RT_HAS_LIBCXX_SOURCES)
+    message(FATAL_ERROR "libcxx not found!")
+  endif()
+
+  parse_arguments(LIBCXX "DEPS;CFLAGS" "" ${ARGN})
+  foreach(flag ${LIBCXX_CFLAGS})
+    set(flagstr "${flagstr} ${flag}")
+  endforeach()
+  set(LIBCXX_CFLAGS ${flagstr})
+
+  if(NOT COMPILER_RT_STANDALONE_BUILD)
+    list(APPEND LIBCXX_DEPS clang)
+  endif()
+
+  ExternalProject_Add(${name}
+    PREFIX ${prefix}
+    SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH}
+    CMAKE_ARGS -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER}
+               -DCMAKE_CXX_COMPILER=${COMPILER_RT_TEST_COMPILER}
+               -DCMAKE_C_FLAGS=${LIBCXX_CFLAGS}
+               -DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS}
+               -DCMAKE_BUILD_TYPE=Release
+               -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+    LOG_BUILD 1
+    LOG_CONFIGURE 1
+    LOG_INSTALL 1
+    )
+
+  ExternalProject_Add_Step(${name} force-reconfigure
+    DEPENDERS configure
+    ALWAYS 1
+    )
+
+  ExternalProject_Add_Step(${name} clobber
+    COMMAND ${CMAKE_COMMAND} -E remove_directory <BINARY_DIR>
+    COMMAND ${CMAKE_COMMAND} -E make_directory <BINARY_DIR>
+    COMMENT "Clobberring ${name} build directory..."
+    DEPENDERS configure
+    DEPENDS ${LIBCXX_DEPS}
+    )
 endmacro()
diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake
index 2794cab..4885c82 100644
--- a/cmake/Modules/CompilerRTCompile.cmake
+++ b/cmake/Modules/CompilerRTCompile.cmake
@@ -1,6 +1,6 @@
 include(LLVMParseArguments)
 
-# Compile a source into an object file with just-built Clang using
+# Compile a source into an object file with COMPILER_RT_TEST_COMPILER using
 # a provided compile flags and dependenices.
 # clang_compile(<object> <source>
 #               CFLAGS <list of compile flags>
@@ -8,9 +8,25 @@
 macro(clang_compile object_file source)
   parse_arguments(SOURCE "CFLAGS;DEPS" "" ${ARGN})
   get_filename_component(source_rpath ${source} REALPATH)
+  if(NOT COMPILER_RT_STANDALONE_BUILD)
+    list(APPEND SOURCE_DEPS clang)
+  endif()
+  string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
+  if(is_cxx)
+    string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}")
+  else()
+    string(REPLACE " " ";" global_flags "${CMAKE_C_FLAGS}")
+  endif()
+  # Ignore unknown warnings. CMAKE_CXX_FLAGS may contain GCC-specific options
+  # which are not supported by Clang.
+  list(APPEND global_flags -Wno-unknown-warning-option)
+  set(compile_flags ${global_flags} ${SOURCE_CFLAGS})
   add_custom_command(
     OUTPUT ${object_file}
-    COMMAND clang ${SOURCE_CFLAGS} -c -o "${object_file}" ${source_rpath}
+    # MSVS CL doesn't allow a space between -Fo and the object file name.
+    COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c
+            ${COMPILER_RT_TEST_COMPILER_OBJ}"${object_file}"
+            ${source_rpath}
     MAIN_DEPENDENCY ${source}
-    DEPENDS clang ${SOURCE_DEPS})
+    DEPENDS ${SOURCE_DEPS})
 endmacro()
diff --git a/cmake/Modules/CompilerRTLink.cmake b/cmake/Modules/CompilerRTLink.cmake
index 85030a7..0f0e53a 100644
--- a/cmake/Modules/CompilerRTLink.cmake
+++ b/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()
diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
index fce37e3..e22e775 100644
--- a/cmake/Modules/CompilerRTUtils.cmake
+++ b/cmake/Modules/CompilerRTUtils.cmake
@@ -18,7 +18,7 @@
 # Check if a given flag is present in a space-separated flag_string.
 # Store the result in out_var.
 function(find_flag_in_string flag_string flag out_var)
-  string(REPLACE " " ";" flag_list ${flag_string})
+  string(REPLACE " " ";" flag_list "${flag_string}")
   list(FIND flag_list ${flag} flag_pos)
   if(NOT flag_pos EQUAL -1)
     set(${out_var} TRUE PARENT_SCOPE)
@@ -36,3 +36,26 @@
     set(${var}_PYBOOL False)
   endif()
 endmacro()
+
+# Appends value to all lists in ARGN, if the condition is true.
+macro(append_if condition value)
+  if(${condition})
+    foreach(list ${ARGN})
+      list(APPEND ${list} ${value})
+    endforeach()
+  endif()
+endmacro()
+
+# Appends value to all strings in ARGN, if the condition is true.
+macro(append_string_if condition value)
+  if(${condition})
+    foreach(str ${ARGN})
+      set(${str} "${${str}} ${value}")
+    endforeach()
+  endif()
+endmacro()
+
+macro(append_no_rtti_flag list)
+  append_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
+  append_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
+endmacro()
diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake
index 0836ede..1ebc703 100644
--- a/cmake/Modules/SanitizerUtils.cmake
+++ b/cmake/Modules/SanitizerUtils.cmake
@@ -12,21 +12,36 @@
 # symbol names that should be exported as well.
 #   add_sanitizer_rt_symbols(<name> <files with extra symbols to export>)
 macro(add_sanitizer_rt_symbols name)
-  get_target_property(libfile ${name} LOCATION)
-  set(symsfile "${libfile}.syms")
-  add_custom_command(OUTPUT ${symsfile}
+  set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${name}.syms-stamp)
+  add_custom_command(OUTPUT ${stamp}
     COMMAND ${PYTHON_EXECUTABLE}
-      ${SANITIZER_GEN_DYNAMIC_LIST} ${libfile} ${ARGN}
-      > ${symsfile}
+      ${SANITIZER_GEN_DYNAMIC_LIST} $<TARGET_FILE:${name}> ${ARGN}
+      > $<TARGET_FILE:${name}>.syms
+    COMMAND ${CMAKE_COMMAND} -E touch ${stamp}
     DEPENDS ${name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN}
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     COMMENT "Generating exported symbols for ${name}"
     VERBATIM)
   add_custom_target(${name}-symbols ALL
-    DEPENDS ${symsfile}
+    DEPENDS ${stamp}
     SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN})
-  install(FILES ${symsfile} DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
-  add_dependencies(compiler-rt ${name}-symbols)
+
+  if(NOT CMAKE_VERSION VERSION_LESS 3.0)
+    install(FILES $<TARGET_FILE:${name}>.syms
+            DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+  else()
+    # Per-config install location.
+    if(CMAKE_CONFIGURATION_TYPES)
+      foreach(c ${CMAKE_CONFIGURATION_TYPES})
+        get_target_property(libfile ${name} LOCATION_${c})
+        install(FILES ${libfile}.syms CONFIGURATIONS ${c}
+          DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+      endforeach()
+    else()
+      get_target_property(libfile ${name} LOCATION_${CMAKE_BUILD_TYPE})
+      install(FILES ${libfile}.syms DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+    endif()
+  endif()
 endmacro()
 
 # Add target to check code style for sanitizer runtimes.
@@ -34,6 +49,7 @@
   add_custom_target(SanitizerLintCheck
     COMMAND LLVM_CHECKOUT=${LLVM_MAIN_SRC_DIR} SILENT=1 TMPDIR=
       PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
+      COMPILER_RT=${COMPILER_RT_SOURCE_DIR}
       ${SANITIZER_LINT_SCRIPT}
     DEPENDS ${SANITIZER_LINT_SCRIPT}
     COMMENT "Running lint check for sanitizer sources..."
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
new file mode 100644
index 0000000..9902b44
--- /dev/null
+++ b/cmake/config-ix.cmake
@@ -0,0 +1,50 @@
+include(CheckCXXCompilerFlag)
+include(CheckLibraryExists)
+include(CheckSymbolExists)
+
+# CodeGen options.
+check_cxx_compiler_flag(-fPIC                COMPILER_RT_HAS_FPIC_FLAG)
+check_cxx_compiler_flag(-fPIE                COMPILER_RT_HAS_FPIE_FLAG)
+check_cxx_compiler_flag(-fno-builtin         COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
+check_cxx_compiler_flag(-fno-exceptions      COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG)
+check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG)
+check_cxx_compiler_flag(-funwind-tables      COMPILER_RT_HAS_FUNWIND_TABLES_FLAG)
+check_cxx_compiler_flag(-fno-stack-protector COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG)
+check_cxx_compiler_flag(-fvisibility=hidden  COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG)
+check_cxx_compiler_flag(-fno-rtti            COMPILER_RT_HAS_FNO_RTTI_FLAG)
+check_cxx_compiler_flag(-ffreestanding       COMPILER_RT_HAS_FFREESTANDING_FLAG)
+check_cxx_compiler_flag("-Werror -fno-function-sections" COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG)
+check_cxx_compiler_flag(-std=c++11           COMPILER_RT_HAS_STD_CXX11_FLAG)
+check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
+
+check_cxx_compiler_flag(/GR COMPILER_RT_HAS_GR_FLAG)
+check_cxx_compiler_flag(/GS COMPILER_RT_HAS_GS_FLAG)
+check_cxx_compiler_flag(/MT COMPILER_RT_HAS_MT_FLAG)
+check_cxx_compiler_flag(/Oy COMPILER_RT_HAS_Oy_FLAG)
+
+# Debug info flags.
+check_cxx_compiler_flag(-gline-tables-only COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG)
+check_cxx_compiler_flag(-g COMPILER_RT_HAS_G_FLAG)
+check_cxx_compiler_flag(/Zi COMPILER_RT_HAS_Zi_FLAG)
+ 
+# Warnings.
+check_cxx_compiler_flag(-Wall COMPILER_RT_HAS_WALL_FLAG)
+check_cxx_compiler_flag(-Werror COMPILER_RT_HAS_WERROR_FLAG)
+check_cxx_compiler_flag("-Werror -Wframe-larger-than=512" COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG)
+check_cxx_compiler_flag("-Werror -Wglobal-constructors"   COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG)
+check_cxx_compiler_flag("-Werror -Wno-c99-extensions"     COMPILER_RT_HAS_WNO_C99_EXTENSIONS_FLAG)
+check_cxx_compiler_flag("-Werror -Wno-gnu"                COMPILER_RT_HAS_WNO_GNU_FLAG)
+check_cxx_compiler_flag("-Werror -Wno-non-virtual-dtor"   COMPILER_RT_HAS_WNO_NON_VIRTUAL_DTOR_FLAG)
+check_cxx_compiler_flag("-Werror -Wno-variadic-macros"    COMPILER_RT_HAS_WNO_VARIADIC_MACROS_FLAG)
+
+check_cxx_compiler_flag(/W3 COMPILER_RT_HAS_W3_FLAG)
+check_cxx_compiler_flag(/WX COMPILER_RT_HAS_WX_FLAG)
+check_cxx_compiler_flag(/wd4722 COMPILER_RT_HAS_WD4722_FLAG)
+
+# Symbols.
+check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL)
+
+# Libraries.
+check_library_exists(m pow "" COMPILER_RT_HAS_LIBM)
+check_library_exists(dl dlopen "" COMPILER_RT_HAS_LIBDL)
+check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD)