[compiler-rt] r334903 - Revert "[CMake] Use a different source depending on C++ support"
Jonas Hahnfeld via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 17 02:51:33 PDT 2018
Author: hahnfeld
Date: Sun Jun 17 02:51:33 2018
New Revision: 334903
URL: http://llvm.org/viewvc/llvm-project?rev=334903&view=rev
Log:
Revert "[CMake] Use a different source depending on C++ support"
This reverts commit r332924 and followup r332936 silencing a warning.
The change breaks the build on x86 if there is no 32-bit version of the
C++ libraries, see discussion in https://reviews.llvm.org/D47169.
Modified:
compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/trunk/cmake/config-ix.cmake
Modified: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake?rev=334903&r1=334902&r2=334903&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake Sun Jun 17 02:51:33 2018
@@ -125,19 +125,6 @@ endfunction()
# 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)malloc(sizeof(int)); 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() { (void) new int; return 0; }\n")
- endif()
-
set(TARGET_${arch}_CFLAGS ${ARGN})
set(TARGET_${arch}_LINK_FLAGS ${ARGN})
set(argstring "")
@@ -157,7 +144,7 @@ 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}")
- try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${TARGET_${arch}_FILENAME}
+ try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE}
COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS} ${FLAG_NO_EXCEPTIONS}"
OUTPUT_VARIABLE TARGET_${arch}_OUTPUT)
set(CMAKE_EXE_LINKER_FLAGS ${SAVED_CMAKE_EXE_LINKER_FLAGS})
@@ -170,8 +157,6 @@ macro(test_target_arch arch def)
# 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)
Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=334903&r1=334902&r2=334903&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Sun Jun 17 02:51:33 2018
@@ -123,6 +123,13 @@ endif()
# 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
More information about the llvm-commits
mailing list