enable Hexagon target from cmake
authorSebastian Pop <spop@codeaurora.org>
Wed, 8 Aug 2012 17:45:43 +0000 (17:45 +0000)
committerSebastian Pop <spop@codeaurora.org>
Wed, 8 Aug 2012 17:45:43 +0000 (17:45 +0000)
This patch allows us to use cmake to specify a cross compiler for Hexagon.

In particular, the patch adds a missing case for the target Hexagon in
cmake/config-ix.cmake, and it moves LLVM_DEFAULT_TARGET_TRIPLE and TARGET_TRIPLE
variables from cmake/config-ix.cmake to the toplevel CMakeLists.txt to make them
available at configure time. Here is the command line that I have used to test
my patches:

$ cmake -G Ninja -D BUILD_SHARED_LIBS:BOOL=ON -D LLVM_TARGETS_TO_BUILD:STRING=Hexagon -D TARGET_TRIPLE:STRING=hexagon-unknown-linux-gnu -D LLVM_DEFAULT_TARGET_TRIPLE:STRING=hexagon-unknown-linux-gnu -D LLVM_TARGET_ARCH:STRING=hexagon-unknown-linux-gnu -D LLVM_ENABLE_PIC:BOOL=OFF ..
$ ninja check

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161504 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
cmake/config-ix.cmake

index ed230aee5bad8aa1849a534fb79afecde22c7f99..a3aee58d8d9509c32f6df4e9b7f0fe04c15a64ab 100644 (file)
@@ -116,8 +116,15 @@ option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpret
 set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so")
 set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h")
 
-set(LLVM_TARGET_ARCH "host"
-  CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.")
+set(LLVM_TARGET_ARCH "host" CACHE STRING
+  "Set target to use for LLVM JIT or use \"host\" for automatic detection.")
+
+# By default, we target the host, but this can be overridden at CMake
+# invocation time.
+set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_TARGET_ARCH}" CACHE STRING
+  "Default target for which LLVM will generate code." )
+set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE STRING
+  "Default target for which LLVM will generate code." )
 
 option(LLVM_ENABLE_THREADS "Use threads if available." ON)
 
index 25d6211ac6f29cc7ba80cd269777db194217a74c..1fe009fb07dfa32776808fedd3dccaa40d5b77b2 100755 (executable)
@@ -291,12 +291,7 @@ check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG)
 
 include(GetHostTriple)
 get_host_triple(LLVM_HOST_TRIPLE)
-
-# By default, we target the host, but this can be overridden at CMake
-# invocation time.
-set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}")
 set(LLVM_HOSTTRIPLE "${LLVM_HOST_TRIPLE}")
-set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
 
 # Determine the native architecture.
 string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)
@@ -324,6 +319,8 @@ elseif (LLVM_NATIVE_ARCH MATCHES "xcore")
   set(LLVM_NATIVE_ARCH XCore)
 elseif (LLVM_NATIVE_ARCH MATCHES "msp430")
   set(LLVM_NATIVE_ARCH MSP430)
+elseif (LLVM_NATIVE_ARCH MATCHES "hexagon")
+  set(LLVM_NATIVE_ARCH Hexagon)
 else ()
   message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}")
 endif ()