From 8edea46b44eaef50d012bd97677cdad80ed0e761 Mon Sep 17 00:00:00 2001 From: Oscar Fuentes Date: Sun, 13 Sep 2009 22:18:38 +0000 Subject: [PATCH] CMake: New user-settable variable LLVM_TARGET_ARCH useful when cross-compiling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Xerxes RĂ„nby! llvm-svn: 81722 --- CMakeLists.txt | 3 +++ cmake/config-ix.cmake | 13 +++++++++---- docs/CMake.html | 10 ++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6036f02bd0..4e48ef6b594 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,9 @@ else( MSVC ) CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") endif( MSVC ) +set(LLVM_TARGET_ARCH "host" + CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.") + option(LLVM_ENABLE_THREADS "Use threads if available." ON) if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 85f94708745..5b63778e8ad 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -92,13 +92,18 @@ get_target_triple(LLVM_HOSTTRIPLE) message(STATUS "LLVM_HOSTTRIPLE: ${LLVM_HOSTTRIPLE}") # Determine the native architecture. -# FIXME: this will have to change for cross-compiling. -string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOSTTRIPLE}) +string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH) +if( LLVM_NATIVE_ARCH STREQUAL "host" ) + string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOSTTRIPLE}) +endif () + if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86") set(LLVM_NATIVE_ARCH X86) -elseif (LLVM_NATIVE_ARCH STREQUAL amd64) +elseif (LLVM_NATIVE_ARCH STREQUAL "x86") set(LLVM_NATIVE_ARCH X86) -elseif (LLVM_NATIVE_ARCH STREQUAL x86_64) +elseif (LLVM_NATIVE_ARCH STREQUAL "amd64") + set(LLVM_NATIVE_ARCH X86) +elseif (LLVM_NATIVE_ARCH STREQUAL "x86_64") set(LLVM_NATIVE_ARCH X86) elseif (LLVM_NATIVE_ARCH MATCHES "sparc") set(LLVM_NATIVE_ARCH Sparc) diff --git a/docs/CMake.html b/docs/CMake.html index 741e8dac0b6..25f471081f5 100644 --- a/docs/CMake.html +++ b/docs/CMake.html @@ -273,6 +273,13 @@ option is available only on some 64-bits unix systems. Defaults to OFF. +
LLVM_TARGET_ARCH:STRING
+
LLVM target to use for native code generation. This is required + for JIT generation. It defaults to "host", meaning that it shall + pick the architecture of the machine where LLVM is being built. If + you are cross-compiling, set it to the target architecture + name.
+
LLVM_TABLEGEN:STRING
Full path to a native TableGen executable (usually named tblgen). This is intented for cross-compiling: if the @@ -311,6 +318,9 @@ this section for a quick solution.

+

Also see the LLVM-specific variables + section for variables used when cross-compiling.

+