summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-05-17 23:50:35 +0000
committerPetr Hosek <phosek@chromium.org>2018-05-17 23:50:35 +0000
commit3eb71831e551f913cd2492001858594bed18c8bb (patch)
treec9d936ce7c8a234775709970e43ff7bf5f90512e
parentAdd initial support for half precision builtins (diff)
downloadllvm-project-3eb71831e551f913cd2492001858594bed18c8bb.tar.gz
llvm-project-3eb71831e551f913cd2492001858594bed18c8bb.tar.bz2
llvm-project-3eb71831e551f913cd2492001858594bed18c8bb.zip
[CMake] Reland "Make simple source used for CMake checks a C file"
The source being compiled is plain C, but using .cc extension forces it to be compiled as C++ which requires a working C++ compiler including C++ library which may not be the case when we're building compiler-rt together with libcxx as part of runtimes build. Differential Revision: https://reviews.llvm.org/D47031 llvm-svn: 332679
-rw-r--r--compiler-rt/CMakeLists.txt1
-rw-r--r--compiler-rt/cmake/Modules/CompilerRTUtils.cmake4
-rw-r--r--compiler-rt/cmake/config-ix.cmake2
3 files changed, 6 insertions, 1 deletions
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 57045c206475..84a7dcd81e5d 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -145,6 +145,7 @@ if (SANITIZER_CXX_ABI STREQUAL "default")
set(SANITIZER_CXX_ABI_SYSTEM 1)
else()
set(SANITIZER_CXX_ABI_LIBNAME "libstdc++")
+ set(SANITIZER_CXX_ABI_SYSTEM 1)
endif()
else()
set(SANITIZER_CXX_ABI_LIBNAME "${SANITIZER_CXX_ABI}")
diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index f567202faa61..7ef1fc8d9ff4 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -144,8 +144,12 @@ macro(test_target_arch arch def)
endif()
set(SAVED_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${argstring}")
+ if(SANITIZER_CXX_ABI_SYSTEM)
+ set(FLAG_LINK_LIBRARIES ${SANITIZER_CXX_ABI_LIBRARY})
+ endif()
try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE}
COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS} ${FLAG_NO_EXCEPTIONS}"
+ LINK_LIBRARIES ${FLAG_LINK_LIBRARIES}
OUTPUT_VARIABLE TARGET_${arch}_OUTPUT)
set(CMAKE_EXE_LINKER_FLAGS ${SAVED_CMAKE_EXE_LINKER_FLAGS})
endif()
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index ee387dc2267a..4a9d840b2e0f 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -125,7 +125,7 @@ set(COMPILER_RT_SUPPORTED_ARCH)
# platform. We use the results of these tests to build only the various target
# runtime libraries supported by our current compilers cross-compiling
# abilities.
-set(SIMPLE_SOURCE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/simple.cc)
+set(SIMPLE_SOURCE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/simple.c)
file(WRITE ${SIMPLE_SOURCE} "#include <stdlib.h>\n#include <stdio.h>\nint main() { printf(\"hello, world\"); }\n")
# Detect whether the current target platform is 32-bit or 64-bit, and setup