[PATCH] D47169: [CMake] Use a different source depending on C++ support
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 21 18:05:57 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332924: [CMake] Use a different source depending on C++ support (authored by phosek, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D47169?vs=147910&id=147928#toc
Repository:
rL LLVM
https://reviews.llvm.org/D47169
Files:
compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/trunk/cmake/config-ix.cmake
Index: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
===================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
@@ -125,6 +125,19 @@
# 2) simple file can be successfully built.
# If successful, saves target flags for this architecture.
macro(test_target_arch arch def)
+ string(RANDOM TARGET_${arch}_NAME)
+ set(TARGET_${arch}_NAME "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cmTC_${TARGET_${arch}_NAME}.dir")
+ file(MAKE_DIRECTORY ${TARGET_${arch}_NAME})
+ if(SANITIZER_CXX_ABI_INTREE)
+ # We're using in tree C++ ABI, only test the C compiler for now.
+ set(TARGET_${arch}_FILENAME "${TARGET_${arch}_NAME}/CheckTarget.c")
+ file(WRITE "${TARGET_${arch}_FILENAME}" "#include <stdlib.h>\nint main() { void *p = malloc(1); return 0; }\n")
+ else()
+ # We're using the system C++ ABI, test that we can build C++ programs.
+ set(TARGET_${arch}_FILENAME "${TARGET_${arch}_NAME}/CheckTarget.cpp")
+ file(WRITE "${TARGET_${arch}_FILENAME}" "#include <new>\nint main() { int *p = new int; return 0; }\n")
+ endif()
+
set(TARGET_${arch}_CFLAGS ${ARGN})
set(TARGET_${arch}_LINK_FLAGS ${ARGN})
set(argstring "")
@@ -144,7 +157,7 @@
endif()
set(SAVED_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${argstring}")
- try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE}
+ try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${TARGET_${arch}_FILENAME}
COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS} ${FLAG_NO_EXCEPTIONS}"
OUTPUT_VARIABLE TARGET_${arch}_OUTPUT)
set(CMAKE_EXE_LINKER_FLAGS ${SAVED_CMAKE_EXE_LINKER_FLAGS})
@@ -157,6 +170,8 @@
# Bail out if we cannot target the architecture we plan to test.
message(FATAL_ERROR "Cannot compile for ${arch}:\n${TARGET_${arch}_OUTPUT}")
endif()
+
+ file(REMOVE_RECURSE ${TARGET_${arch}_NAME})
endmacro()
macro(detect_target_arch)
Index: compiler-rt/trunk/cmake/config-ix.cmake
===================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake
+++ compiler-rt/trunk/cmake/config-ix.cmake
@@ -121,13 +121,6 @@
# List of all architectures we can target.
set(COMPILER_RT_SUPPORTED_ARCH)
-# Try to compile a very simple source file to ensure we can target the given
-# 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)
-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
# the correct commandline flags needed to attempt to target 32-bit and 64-bit.
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 4 AND
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47169.147928.patch
Type: text/x-patch
Size: 3035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180522/3bd93cda/attachment.bin>
More information about the llvm-commits
mailing list