[PATCH] D26653: [compiler-rt] Support building builtins for a single target
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 15:24:28 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289489: [compiler-rt] Support building builtins for a single target (authored by phosek).
Changed prior to commit:
https://reviews.llvm.org/D26653?vs=78296&id=81152#toc
Repository:
rL LLVM
https://reviews.llvm.org/D26653
Files:
compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/trunk/cmake/base-config-ix.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
@@ -100,6 +100,13 @@
set(${out_var} ${archs} PARENT_SCOPE)
endfunction()
+# Add $arch as supported with no additional flags.
+macro(add_default_target_arch arch)
+ set(TARGET_${arch}_CFLAGS "")
+ set(CAN_TARGET_${arch} 1)
+ list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})
+endmacro()
+
function(check_compile_definition def argstring out_var)
if("${def}" STREQUAL "")
set(${out_var} TRUE PARENT_SCOPE)
@@ -223,8 +230,16 @@
endmacro()
macro(construct_compiler_rt_default_triple)
- set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${TARGET_TRIPLE} CACHE STRING
- "Default triple for which compiler-rt runtimes will be built.")
+ if(COMPILER_RT_DEFAULT_TARGET_ONLY)
+ if(DEFINED COMPILER_RT_DEFAULT_TARGET_TRIPLE)
+ message(FATAL_ERROR "COMPILER_RT_DEFAULT_TARGET_TRIPLE isn't supported when building for default target only")
+ endif()
+ set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${CMAKE_C_COMPILER_TARGET})
+ else()
+ set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${TARGET_TRIPLE} CACHE STRING
+ "Default triple for which compiler-rt runtimes will be built.")
+ endif()
+
if(DEFINED COMPILER_RT_TEST_TARGET_TRIPLE)
# Backwards compatibility: this variable used to be called
# COMPILER_RT_TEST_TARGET_TRIPLE.
@@ -234,7 +249,10 @@
string(REPLACE "-" ";" TARGET_TRIPLE_LIST ${COMPILER_RT_DEFAULT_TARGET_TRIPLE})
list(GET TARGET_TRIPLE_LIST 0 COMPILER_RT_DEFAULT_TARGET_ARCH)
list(GET TARGET_TRIPLE_LIST 1 COMPILER_RT_DEFAULT_TARGET_OS)
- list(GET TARGET_TRIPLE_LIST 2 COMPILER_RT_DEFAULT_TARGET_ABI)
+ list(LENGTH TARGET_TRIPLE_LIST TARGET_TRIPLE_LIST_LENGTH)
+ if(TARGET_TRIPLE_LIST_LENGTH GREATER 2)
+ list(GET TARGET_TRIPLE_LIST 2 COMPILER_RT_DEFAULT_TARGET_ABI)
+ endif()
# Determine if test target triple is specified explicitly, and doesn't match the
# default.
if(NOT COMPILER_RT_DEFAULT_TARGET_TRIPLE STREQUAL TARGET_TRIPLE)
Index: compiler-rt/trunk/cmake/config-ix.cmake
===================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake
+++ compiler-rt/trunk/cmake/config-ix.cmake
@@ -96,13 +96,6 @@
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")
-# Add $arch as supported with no additional flags.
-macro(add_default_target_arch arch)
- set(TARGET_${arch}_CFLAGS "")
- set(CAN_TARGET_${arch} 1)
- list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})
-endmacro()
-
# 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
Index: compiler-rt/trunk/cmake/base-config-ix.cmake
===================================================================
--- compiler-rt/trunk/cmake/base-config-ix.cmake
+++ compiler-rt/trunk/cmake/base-config-ix.cmake
@@ -84,6 +84,8 @@
option(COMPILER_RT_ENABLE_IOS "Enable building for iOS" On)
option(COMPILER_RT_ENABLE_WATCHOS "Enable building for watchOS - Experimental" Off)
option(COMPILER_RT_ENABLE_TVOS "Enable building for tvOS - Experimental" Off)
+else()
+ option(COMPILER_RT_DEFAULT_TARGET_ONLY "Build builtins only for the default target" Off)
endif()
if(WIN32 AND NOT MINGW AND NOT CYGWIN)
@@ -127,7 +129,9 @@
detect_target_arch()
set(COMPILER_RT_OS_SUFFIX "-android")
elseif(NOT APPLE) # Supported archs for Apple platforms are generated later
- if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "i[2-6]86|x86|amd64")
+ if(COMPILER_RT_DEFAULT_TARGET_ONLY)
+ add_default_target_arch(${COMPILER_RT_DEFAULT_TARGET_ARCH})
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "i[2-6]86|x86|amd64")
if(NOT MSVC)
test_target_arch(x86_64 "" "-m64")
# FIXME: We build runtimes for both i686 and i386, as "clang -m32" may
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26653.81152.patch
Type: text/x-patch
Size: 4166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161212/163d7048/attachment.bin>
More information about the llvm-commits
mailing list